Re: Wait for a keypress before continuing?

2011-08-16 Thread Seebs
On 2011-08-17, John Doe wrote: > Context is lost when you quote only one level. Not significantly. > I was not answering a question about my code. I was pointing out > the fact that my questioner's terminology is strange/corrupt. Well, that's the thing. There was a question there, with perf

Re: Wait for a keypress before continuing?

2011-08-16 Thread John Doe
Seebs wrote: > John Doe wrote: >> Using "does your code have a GUI" produces zero search results. >> Maybe that works better in some other language. > > You shouldn't need a search engine to answer a question about > your code. Context is lost when you quote only one level. I was not a

Re: Wait for a keypress before continuing?

2011-08-16 Thread Seebs
On 2011-08-17, John Doe wrote: > Using "does your code have a GUI" produces zero search results. > Maybe that works better in some other language. You shouldn't need a search engine to answer a question about your code. If you do, it suggests that perhaps one or more of the terms are unfamiliar

Re: testing if a list contains a sublist

2011-08-16 Thread ChasBrown
On Aug 16, 1:37 am, Steven D'Aprano wrote: > 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

Re: Wait for a keypress before continuing?

2011-08-16 Thread John Doe
Jerry Hill wrote: > John Doe wrote: >> No. I am running this from within Windows, all sorts of >> Windows. > > What does that mean? You snipped the context, Benny. > You seem very resistant to answering anyone's questions about > your code. No one else has had a problem with my co

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

2011-08-16 Thread Seebs
On 2011-08-17, Steven D'Aprano wrote: > Seebs wrote: >> On 2011-08-16, Steven D'Aprano >> wrote: >>> *My* objects certainly are, because I write documentation for my code. My >>> docs are no less official than Python's docs. >> Sure they are. I can't get yours from python.org. > And what makes

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

2011-08-16 Thread Philip Semanchuk
On Aug 16, 2011, at 10:15 PM, Terry Reedy wrote: > On 8/16/2011 8:18 PM, Philip Semanchuk wrote: > >> Hi Terry, >> To generalize from your example, are you saying that there's a mild >> admonition > > against shadowing builtins with unrelated variable names in standard lib > > code? > > I wou

Re: Ten rules to becoming a Python community member.

2011-08-16 Thread Jason Swails
On Tue, Aug 16, 2011 at 9:14 PM, Steven D'Aprano < steve+comp.lang.pyt...@pearwood.info> wrote: > David Monaghan wrote: > > > On Tue, 16 Aug 2011 13:13:10 -0700 (PDT), rantingrick > > wrote: > > > >>If conciseness is all you seek then perhaps you prefer the following? > >> > >>ORIGINAL: "I used t

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

2011-08-16 Thread Terry Reedy
On 8/16/2011 8:18 PM, Philip Semanchuk wrote: Hi Terry, To generalize from your example, are you saying that there's a mild admonition > against shadowing builtins with unrelated variable names in standard lib code? I would expect that there might be. I would have to check PEP8. Here's an e

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

2011-08-16 Thread Philip Semanchuk
On Aug 16, 2011, at 9:29 PM, Steven D'Aprano wrote: > I have no objection to lint tools. But separation of concerns should apply: > the Python compiler should just compile what I tell it to, the linter > should warn me if I'm running with scissors. This point (also made by Ethan) I can agree wit

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

2011-08-16 Thread MRAB
On 17/08/2011 01:14, gc wrote: On Aug 16, 4:39 pm, "Martin P. Hellwig" wrote: On 03/08/2011 02:45, gc wrote: a,b,c,d,e = *dict() where * in this context means something like "assign separately to all. . . . it has a certain code smell to it. I would love to see an example where you wo

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

2011-08-16 Thread Terry Reedy
On 8/16/2011 7:49 PM, Seebs wrote: On 2011-08-16, Terry Reedy wrote: On 8/16/2011 2:56 PM, Seebs wrote: I wonder whether there's a way to mitigate the cost of these things by messing with -W settings, such that runtime that wants to be fast can omit the checks, but the default could still be t

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

2011-08-16 Thread Seebs
On 2011-08-17, Chris Angelico wrote: > On Wed, Aug 17, 2011 at 12:49 AM, Seebs wrote: >> Yes, but is it a *significant* cost? ?My assumption is that the suppression >> would be of checking, not just of displaying messages. > It mightn't be very significant, but there'd still be some cost. > Howe

Re: Ten rules to becoming a Python community member.

2011-08-16 Thread rantingrick
On Aug 16, 7:33 pm, John Gordon wrote: > In > rantingrick writes: > > > > "wore" means you have worn them in the past. > > > > "used to wear" means you have worn them in the past AND don't intend > > > to do so again. > > Actually that assertion is wrong. > > No one can predict the future. Not

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

2011-08-16 Thread Steven D'Aprano
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: Ten rules to becoming a Python community member.

2011-08-16 Thread Steven D'Aprano
David Monaghan wrote: > On Tue, 16 Aug 2011 13:13:10 -0700 (PDT), rantingrick > wrote: > >>If conciseness is all you seek then perhaps you prefer the following? >> >>ORIGINAL: "I used to wear wooden shoes" >>CONCISE: "I wore wooden shoes" > >>ORIGINAL: "I have become used to wearing wooden sho

Re: Ten rules to becoming a Python community member.

2011-08-16 Thread Chris Kaynor
On Tue, Aug 16, 2011 at 6:02 PM, Tim Chase wrote: > On 08/16/2011 07:33 PM, John Gordon wrote: >> >> I stand by my assertion that the phrase "I used to do X" carries the >> meaning that you have done X in the past but DO NOT INTEND to do so >> in the future. > > I'd tweak the meaning to be somethi

Re: Idea for pure-python templates using AST.

2011-08-16 Thread Paul Wray
> You code fail, see below for other comment > > Traceback (most recent call last): >   File "Download/pastie-2379978.rb", line 108, in >     make_template(template1) >   File "Download/pastie-2379978.rb", line 60, in make_template >     ast.fix_missing_locations(astFromSrc) >   File "/usr/lib/pyt

Re: Idea for pure-python templates using AST.

2011-08-16 Thread Paul Wray
On Aug 17, 5:23 am, Irmen de Jong wrote: > 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'

Re: Ten rules to becoming a Python community member.

2011-08-16 Thread Tim Chase
On 08/16/2011 07:33 PM, John Gordon wrote: I stand by my assertion that the phrase "I used to do X" carries the meaning that you have done X in the past but DO NOT INTEND to do so in the future. I'd tweak the meaning to be something like "I did X regularly in the past and I no longer do it reg

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

2011-08-16 Thread Steven D'Aprano
Seebs wrote: > 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

Re: why i cannot import djang?

2011-08-16 Thread Tim Roberts
smith jack wrote: > >this package is already in the site-packages directory, but i cannot >import it , it's really confusing ... The package is called "django". The name you put in the subject line is wrong. Does your code use the right spelling? -- Tim Roberts, t...@probo.com Providenza & Boe

Re: Idea for pure-python templates using AST.

2011-08-16 Thread Tim Roberts
"Paul Wray" wrote: > >Ive had what I think is a great idea for pure-python templates (I can almost >hear the groans, bear with me...) >... >The idea: >Python syntax allows a statement to be a bare literal or identifier. These >have no effect on the program. >... >So is this (within the appropria

Re: Ten rules to becoming a Python community member.

2011-08-16 Thread John Gordon
In rantingrick writes: > > "wore" means you have worn them in the past. > > > > "used to wear" means you have worn them in the past AND don't intend > > to do so again. > Actually that assertion is wrong. > No one can predict the future. Not even YOU can predict whether or not Of course -- t

Re: string to unicode

2011-08-16 Thread Tim Roberts
Artie Ziff wrote: > >if I am using the standard csv library to read contents of a csv file >which contains Unicode strings (short example: >'\xe8\x9f\x92\xe8\x9b\x87'), You need to be rather precise when talking about this. That's not a "Unicode string" in Python terms. It's an 8-bit string.

Re: parameterized-testcase 0.2

2011-08-16 Thread Ben Finney
Austin Bingham writes: > parameterized-testcase works with Python's standard unittest module to > provide a means to run TestCases with different "parameterizations". How is this different from what we already have in ‘testscenarios’ http://pypi.python.org/pypi/testscenarios/>? -- \

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

2011-08-16 Thread gc
On Aug 16, 4:39 pm, "Martin P. Hellwig" wrote: > On 03/08/2011 02:45, gc wrote: > > > > a,b,c,d,e = *dict() > > > where * in this context means something like "assign separately to > > all. > . . . it has a certain code smell to it. > I would love to see an example where you would need such a

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

2011-08-16 Thread Philip Semanchuk
On Aug 16, 2011, at 7:29 PM, Terry Reedy wrote: > On 8/16/2011 1:15 PM, Gerrat Rickert wrote: > >> I think that best practices would suggest that one shouldn't use >> variable >> names that shadow builtins (except in specific, special circumstances), >> so I don't really think this would be an a

Re: Wait for a keypress before continuing?

2011-08-16 Thread Jerry Hill
On Tue, Aug 16, 2011 at 5:59 PM, John Doe wrote: > No. I am running this from within Windows, all sorts of Windows. What does that mean? You seem very resistant to answering anyone's questions about your code. Is your code run from the command line, or does it have a GUI? If it has a GUI, what

Re: Idea for pure-python templates using AST.

2011-08-16 Thread Chris Angelico
On Wed, Aug 17, 2011 at 12:57 AM, Paul Wray wrote: > Thanks yes ama aware of docstrings but did not consider. > They are easy to strip out though. > Maybe. You'd have to take notice of what's a docstring and what's the first element to be outputted. Or alternatively, just forbid docstrings on tho

Re: Determine what msvcrt.getch() is getting?

2011-08-16 Thread Jerry Hill
On Tue, Aug 16, 2011 at 5:43 PM, John Doe wrote: > Whatever msvcrt.getch() is returning here in Windows, it's not within > the 1-255 number range. How can I determine what it is returning? > > I would like to see whatever it is getting. Just print it. Like this: import msvcrt ch = msvcrt.getch(

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

2011-08-16 Thread Chris Angelico
On Wed, Aug 17, 2011 at 12:49 AM, Seebs wrote: > Yes, but is it a *significant* cost?  My assumption is that the suppression > would be of checking, not just of displaying messages. > It mightn't be very significant, but there'd still be some cost. However, IMHO the greatest cost is the spammines

Re: Ten rules to becoming a Python community member.

2011-08-16 Thread rantingrick
On Aug 16, 6:25 pm, John Gordon wrote: > In > rantingrick writes: > > > > >  ORIGINAL1: "I used to wear wooden shoes" > > > > CONCISE_1a: "I wore wooden shoes" > > "wore" do

Re: Idea for pure-python templates using AST.

2011-08-16 Thread Paul Wray
On Aug 17, 2:14 am, Chris Angelico wrote: > 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, >

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

2011-08-16 Thread Seebs
On 2011-08-16, Terry Reedy wrote: > On 8/16/2011 2:56 PM, Seebs wrote: >> I wonder whether there's a way to mitigate the cost of these things by >> messing with -W settings, such that runtime that wants to be fast can >> omit the checks, but the default could still be to, well, prevent likely >> e

Re: Wait for a keypress before continuing?

2011-08-16 Thread John Doe
Okay... Looks like I need pyHook. -- http://mail.python.org/mailman/listinfo/python-list

Re: Ten rules to becoming a Python community member.

2011-08-16 Thread David Monaghan
On Tue, 16 Aug 2011 16:12:53 -0700 (PDT), rantingrick wrote: >On Aug 16, 4:55 pm, David Monaghan wrote: >> On Tue, 16 Aug 2011 13:13:10 -0700 (PDT), rantingrick >> >> wrote: >> >If conciseness is all you seek then perhaps you prefer the following? >> >> >ORIGINAL: "I used to wear wooden shoes"

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

2011-08-16 Thread Terry Reedy
On 8/16/2011 2:56 PM, Seebs wrote: I wonder whether there's a way to mitigate the cost of these things by messing with -W settings, such that runtime that wants to be fast can omit the checks, but the default could still be to, well, prevent likely errors. Warning messages have a cost even if

Re: Ten rules to becoming a Python community member.

2011-08-16 Thread John Gordon
In rantingrick writes: > > ORIGINAL1: "I used to wear wooden shoes" > > CONCISE_1a: "I wore wooden shoes" "wore" does not convey the same meaning as "used to wear." "wor

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

2011-08-16 Thread Terry Reedy
On 8/16/2011 1:15 PM, Gerrat Rickert wrote: I think that best practices would suggest that one shouldn't use variable names that shadow builtins (except in specific, special circumstances), so I don't really think this would be an annoyance at all. The number of *unwanted* warnings they'd get w

Re: Ten rules to becoming a Python community member.

2011-08-16 Thread rantingrick
On Aug 16, 4:55 pm, David Monaghan wrote: > On Tue, 16 Aug 2011 13:13:10 -0700 (PDT), rantingrick > > wrote: > >If conciseness is all you seek then perhaps you prefer the following? > > >ORIGINAL: "I used to wear wooden shoes" > >CONCISE:  "I wore wooden shoes" > >ORIGINAL: "I have become used to

Re: Wait for a keypress before continuing?

2011-08-16 Thread John Doe
Tim Roberts wrote: > John Doe wrote: > >>def wait_for_keystroke(): >> char=0 while not (char==chr(27) or char==chr(110)): >>char=msvcrt.getch() if char==0: >> return >> >>That freezes the process. > > That exact code works perfectly for me. The function returns as > soon as I

Re: Ten rules to becoming a Python community member.

2011-08-16 Thread David Monaghan
On Tue, 16 Aug 2011 13:13:10 -0700 (PDT), rantingrick wrote: >If conciseness is all you seek then perhaps you prefer the following? > >ORIGINAL: "I used to wear wooden shoes" >CONCISE: "I wore wooden shoes" >ORIGINAL: "I have become used to wearing wooden shoes" >CONCISE: "I like wearing woode

Re: Wait for a keypress before continuing?

2011-08-16 Thread Tim Roberts
John Doe wrote: >def wait_for_keystroke(): > char=0 > while not (char==chr(27) or char==chr(110)): >char=msvcrt.getch() >if char==0: > return > >That freezes the process. That exact code works perfectly for me. The function returns as soon as I press the escape key. You are runn

Determine what msvcrt.getch() is getting?

2011-08-16 Thread John Doe
Whatever msvcrt.getch() is returning here in Windows, it's not within the 1-255 number range. How can I determine what it is returning? I would like to see whatever it is getting. Thanks. -- http://mail.python.org/mailman/listinfo/python-list

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

2011-08-16 Thread Luis M . González
On Aug 16, 2:11 pm, Seebs wrote: > 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 goin

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

2011-08-16 Thread Martin P. Hellwig
On 03/08/2011 02:45, gc wrote: a,b,c,d,e = *dict() where * in this context means something like "assign separately to all. Any thoughts? Thanks! Well got a thought but I am afraid it is the opposite of helpful in the direct sense. So if you don't want to hear it skip it :-) Although I c

Re: allow line break at operators

2011-08-16 Thread Seebs
On 2011-08-16, Prasad, Ramit wrote: >What exactly is the downside to indentation as flow control? I think a lot of it is personal taste or differences in how peoples' brains work. I don't want "free form code", I don't want to write stuff that isn't correctly indented. I want a visual cue I can

Re: Ten rules to becoming a Python community member.

2011-08-16 Thread rantingrick
On Aug 16, 1:37 pm, "Martin P. Hellwig" wrote: > Well admittedly English isn't my native language, But indeed all > sentences seem correct to me. > > With the first sentence meaning: in the past I wore wooden shoes, but > presently I do not. > > With the second sentence meaning: in the past I was

Re: Wait for a keypress before continuing?

2011-08-16 Thread John Doe
def wait_for_keystroke(): char=0 while not (char==chr(27) or char==chr(110)): char=msvcrt.getch() if char==0: return That freezes the process. That means char=msvcrt.getch() is getting something? Could it have something to do with the formatting of the character? -- http://mail.

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

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 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: 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: 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: 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: 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: 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: 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: 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: 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: 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: 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 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

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: 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. >> >>

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: 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: 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: 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: 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 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 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 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 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, 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: 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 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.

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: 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]

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: 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 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 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: 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: 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: 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: 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: 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: 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: 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: 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: 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: 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: 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 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 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 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: 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: 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

  1   2   >