Re: python scripts for web

2012-10-18 Thread chip9munk
On Thursday, October 18, 2012 11:10:45 PM UTC+2, Zero Piraeus wrote: > WSGI would enable you to write a persistent application that sits > around waiting for requests and returns responses for them as and > when, as opposed to a simple CGI script that gets started each time a > request comes in, an

Re: A desperate lunge for on-topic-ness

2012-10-18 Thread Steven D'Aprano
On Thu, 18 Oct 2012 20:35:20 -0700, rusi wrote: (extracting the text without the ASCII-art) > > “When I get new information, I change my position. What, sir, > > do you do with new information?” —John Maynard Keynes > > “Anyone who believes exponential growth can go on forever in a > > finite wor

Testing against multiple versions of Python

2012-10-18 Thread Michele Simionato
Yesterday I released a new version of the decorator module. It should run under Python 2.4, 2.5, 2.6, 2.7, 3.0, 3.1, 3.2, 3.3. I did not have the will to install on my machine 8 different versions of Python, so I just tested it with Python 2.7 and 3.3. But I do not feel happy with that. Is there

Re: A desperate lunge for on-topic-ness

2012-10-18 Thread rusi
>  \       “When I get new information, I change my position. What, sir, | >   `\             do you do with new information?” —John Maynard Keynes | > _o__)                                                                  | > \ “Anyone who believes exponential growth can go on forever in a

Re: How to access the document for __call__ from command line?

2012-10-18 Thread Terry Reedy
On 10/18/2012 10:30 PM, Peng Yu wrote: Hi, reference.pdf from python document has the following description. It is not accessible from help() in the command line. Is there an alternative so that I can quickly access these class attributes or method names from the command line? object.__call__(s

How to access the document for __call__ from command line?

2012-10-18 Thread Peng Yu
Hi, reference.pdf from python document has the following description. It is not accessible from help() in the command line. Is there an alternative so that I can quickly access these class attributes or method names from the command line? object.__call__(self [, args... ]) Called when the instanc

Re: A desperate lunge for on-topic-ness

2012-10-18 Thread Dave Angel
On 10/18/2012 09:20 PM, Steven D'Aprano wrote: > On Thu, 18 Oct 2012 12:47:48 -0400, Dave Angel wrote: > >> I never use the backslash at end-of-line to continue a statement to the >> next. Not only is it a readability problem, but if your editor doesn't >> have visible spaces, you can accidentally

Re: Add if...else... switch to doctest?

2012-10-18 Thread Steven D'Aprano
On Thu, 18 Oct 2012 17:08:37 -0700, David wrote: > Hello, how to add if...else... switch to doctest? Step 1): Write your doctest with the switch. Don't forget to test both branches: >>> global_var = True >>> if global_var: ... function() ... else: ... function()

Re: A desperate lunge for on-topic-ness

2012-10-18 Thread Steven D'Aprano
On Thu, 18 Oct 2012 17:36:57 -0400, Zero Piraeus wrote: > The accepted rule in print is that lines of prose should be between 45 > and 90 characters, with 66 being ideal for readability. Code is not > prose, and the combination of fixed-width and much more variable line > length aids readability,

Re: A desperate lunge for on-topic-ness

2012-10-18 Thread Steven D'Aprano
On Thu, 18 Oct 2012 15:59:18 +0200, Jean-Michel Pichavant wrote: > - Original Message - >> On 2012-10-18, Zero Piraeus wrote: >> >> > What are people's preferred strategies for dealing with lines that go >> > over 79 characters? A few I can think of off the bat: >> >> I try to do what's

Re: Add if...else... switch to doctest?

2012-10-18 Thread Terry Reedy
On 10/18/2012 8:08 PM, David wrote: Hello, how to add if...else... switch to doctest? E.g. function outputs different value when global_var change. """ if (global_var == True): function() [1,2] else: function() [1,2,3] """ doctests should/must be self contained. IE, you would have to set t

Re: Add if...else... switch to doctest?

2012-10-18 Thread Ben Finney
David writes: > Hello, how to add if...else... switch to doctest? > E.g. function outputs different value when global_var change. > > """ > if (global_var == True): > >>> function() > [1,2] > else: > >>> function() > [1,2,3] > """ > > Thank you very much. You write the code in a doctest as it wo

Re: len() on mutables vs. immutables

2012-10-18 Thread Terry Reedy
On 10/18/2012 2:42 PM, Demian Brecht wrote: Awesome. Pretty much what I figured. Of course, I'll have to dig around the source just to confirm this with my own eyes (more just curiosity than anything), If you do, please followup with a report. -- Terry Jan Reedy -- http://mail.python.org/mai

Re: len() on mutables vs. immutables

2012-10-18 Thread Terry Reedy
On 10/18/2012 3:18 PM, Prasad, Ramit wrote: Terry Reedy wrote: On 10/18/2012 1:23 PM, Demian Brecht wrote: When len() is called passing an immutable built-in type (such as a string), I'd assume that the overhead in doing so is simply a function call and there are no on-call calculations done.

Re: A desperate lunge for on-topic-ness

2012-10-18 Thread Steven D'Aprano
On Thu, 18 Oct 2012 12:47:48 -0400, Dave Angel wrote: > I never use the backslash at end-of-line to continue a statement to the > next. Not only is it a readability problem, but if your editor doesn't > have visible spaces, you can accidentally have whitespace after the > backslash, and wonder wh

Re: A desperate lunge for on-topic-ness

2012-10-18 Thread Ben Finney
Jean-Michel Pichavant writes: > The 79 char limit purpose is to allow someone to read the code on a 80 > char terminal (and allow old printers to print the code). There is a very good reason for a strict line width limit regardless of terminal size: scanning long lines is cognitively more diffic

Re: A desperate lunge for on-topic-ness

2012-10-18 Thread Ben Finney
Hans Mulder writes: > On 18/10/12 08:31:51, Steven D'Aprano wrote: > > some_variable = spam('x') + ham( > > some_longer_variables, here_and_here, > > and_here_also) The indentation level for continuation lines shouldn't be dependent on the content of the

Re: A desperate lunge for on-topic-ness

2012-10-18 Thread Ben Finney
Zero Piraeus writes: > : > (Why is this colon appearing at the top of your messages? Can you remove it if it's not germane?) > What are people's preferred strategies for dealing with lines that go > over 79 characters? A few I can think of off the bat: > 1. Say "screw it" and go past 79, PEP8

When to clear elements using cElementTree

2012-10-18 Thread Ben Temperton
Hi there, I am parsing some huge xml files (1.8 Gb) that look like this: some data some data some data What I am trying to do is build up a dictionary of lists where the key is the parent scan num and the members of the list are the child scan nums. I ha

Add if...else... switch to doctest?

2012-10-18 Thread David
Hello, how to add if...else... switch to doctest? E.g. function outputs different value when global_var change. """ if (global_var == True): >>> function() [1,2] else: >>> function() [1,2,3] """ Thank you very much. -- http://mail.python.org/mailman/listinfo/python-list

Re: A desperate lunge for on-topic-ness

2012-10-18 Thread Gene Heskett
On Thursday 18 October 2012 18:40:52 Grant Edwards did opine: > On 2012-10-18, Den wrote: > > On Wednesday, October 17, 2012 11:06:43 PM UTC-7, Zero Piraeus wrote: > >> What are people's preferred strategies for dealing with lines that go > > > >> over 79 characters? A few I can think of off the

Re: pip fails to install packages on moutain loin (Mac OS 10.8.2)

2012-10-18 Thread Ned Deily
In article <5b80dd153d7d744689f57f4fb69af4741671d...@scacmx008.exchad.jpmchase.net> , "Prasad, Ramit" wrote: > I would install python+virtualenv+pip from MacPorts to keep > it separate from the OS X system Python. MacPorts will take > care of everything for you as long as you have Xcode install

Re: pip fails to install packages on moutain loin (Mac OS 10.8.2)

2012-10-18 Thread Ned Deily
In article <53b38fa2-ea8b-4225-bdf3-b9bcbde31...@o5g2000yqi.googlegroups.com>, Peng Yu wrote: > Hi, > > I installed Python using python-2.7.3-macosx10.6.dmg on my Mac OS > 10.8.2. > > When try to use pip to install packages, I get the following message. > Then the installation fails. > > gcc

Re: len() on mutables vs. immutables

2012-10-18 Thread Demian Brecht
On Thu, Oct 18, 2012 at 12:43 PM, Daniel Urban wrote: > The source is usually in Objects/*object.c (e.g., the source for list > is in Objects/listobject.c, dict is in dictobject.c and so on). The > implementation of __len__ is usually in a method called > whatever_length (e.g., dict.__len__ is cal

RE: pip fails to install packages on moutain loin (Mac OS 10.8.2)

2012-10-18 Thread Prasad, Ramit
Peng Yu wrote > Hi, > > I installed Python using python-2.7.3-macosx10.6.dmg on my Mac OS > 10.8.2. > > When try to use pip to install packages, I get the following message. > Then the installation fails. > > gcc-4.2 not found, using clang instead > > > I then create a link from /usr/bin/gcc t

pip fails to install packages on moutain loin (Mac OS 10.8.2)

2012-10-18 Thread Peng Yu
Hi, I installed Python using python-2.7.3-macosx10.6.dmg on my Mac OS 10.8.2. When try to use pip to install packages, I get the following message. Then the installation fails. gcc-4.2 not found, using clang instead I then create a link from /usr/bin/gcc to gcc-4.2. Then I run pip again, I get

Re: A desperate lunge for on-topic-ness

2012-10-18 Thread Zero Piraeus
: On 18 October 2012 11:55, Den wrote: > [...] I'm amused by the whole question, and others related > to PEP8. A quick aside, the width of our roads all go back to the > width of a two horse rig. The suggested maximum of 80 characters goes > back to teletype machines, and IBM cards, and charact

Re: python scripts for web

2012-10-18 Thread Zero Piraeus
: On 18 October 2012 12:03, wrote: > yes, but as I have just answered to Zero, is using mod_wsgi a better strategy? WSGI would enable you to write a persistent application that sits around waiting for requests and returns responses for them as and when, as opposed to a simple CGI script that ge

Re: A desperate lunge for on-topic-ness

2012-10-18 Thread Ian Kelly
On Thu, Oct 18, 2012 at 10:47 AM, Dave Angel wrote: > I never use the backslash at end-of-line to continue a statement to the > next. Not only is it a readability problem, but if your editor doesn't > have visible spaces, you can accidentally have whitespace after the > backslash, and wonder what

RE: len() on mutables vs. immutables

2012-10-18 Thread Prasad, Ramit
Ian Kelly wrote: > Sent: Thursday, October 18, 2012 2:39 PM > To: Python > Subject: Re: len() on mutables vs. immutables > > On Thu, Oct 18, 2012 at 1:18 PM, Prasad, Ramit > wrote: > > Why does pointer arithmetic work for dicts? I would think the position > > of a value would be based on the hash

Re: len() on mutables vs. immutables

2012-10-18 Thread Daniel Urban
On Thu, Oct 18, 2012 at 8:42 PM, Demian Brecht wrote: >> str, bytes, bytearrays, arrays, sets, frozensets, dicts, dictviews, and >> ranges should all return len in O(1) time. That includes the possibility >> of a subtraction as indicated above. > > Awesome. Pretty much what I figured. Of course, I

Re: len() on mutables vs. immutables

2012-10-18 Thread Ian Kelly
On Thu, Oct 18, 2012 at 1:18 PM, Prasad, Ramit wrote: > Why does pointer arithmetic work for dicts? I would think the position > of a value would be based on the hash of the key and thus "random" for > the context of this conversation. It doesn't. len() on CPython dicts is O(1) because the dict

RE: len() on mutables vs. immutables

2012-10-18 Thread Prasad, Ramit
Terry Reedy wrote: > On 10/18/2012 1:23 PM, Demian Brecht wrote: > > > When len() is called passing an immutable built-in type (such as a > > string), I'd assume that the overhead in doing so is simply a function > > call and there are no on-call calculations done. Is that correct? > > See below.

RE: A desperate lunge for on-topic-ness

2012-10-18 Thread Prasad, Ramit
Hans Mulder wrote: > On 18/10/12 08:31:51, Steven D'Aprano wrote: > > On Thu, 18 Oct 2012 02:06:19 -0400, Zero Piraeus wrote: > >> 3. Say "well, at least it's not a backslash" and break the line using > >> > parentheses. > > I mostly do this. Since most lines include a bracket of some sort, I > > r

RE: len() on mutables vs. immutables

2012-10-18 Thread Nick Cash
> I'm curious as to the implementation (I'd be happy to dig through the > source, just don't have the time right now). I've seen various > implementations across interpreters in the past (some which have been > rather shocking) and I'd like to get some insight into Python (well, > CPython at this p

RE: OT Questions

2012-10-18 Thread Prasad, Ramit
David Hutto wrote: > On Wed, Oct 17, 2012 at 12:38 PM, Prasad, Ramit > wrote: > > David Hutto wrote: > >> On Wed, Oct 17, 2012 at 2:06 AM, Demian Brecht > >> wrote: [snip] > > > The question is whose opinion matters. Yours? Mine? Others? Personally, > > I heartily second the recommendation to

RE: OT Questions

2012-10-18 Thread Prasad, Ramit
David Hutto wrote: > On Wed, Oct 17, 2012 at 7:12 PM, Steven D'Aprano > wrote: > > On Wed, 17 Oct 2012 18:05:12 -0400, Dwight Hutto wrote: > > > >> this was just a confidence statement that I'm > >> intelligent as well, so don't get uppity with me. > > > > Please tone down the aggression. > > > >

RE: A desperate lunge for on-topic-ness

2012-10-18 Thread Prasad, Ramit
Chris Angelico wrote: > On Fri, Oct 19, 2012 at 3:13 AM, Neil Cerutti wrote: > > Though technology has moved along swiftly, keeping your code > > accessible to the guy using a crummy old console xterm might > > still be worthwhile, and it makes printouts easy to create. > > And keeping your inte

Re: A desperate lunge for on-topic-ness

2012-10-18 Thread Joshua Landau
On 18 October 2012 12:05, Tim Chase wrote: > On 10/18/12 04:33, wxjmfa...@gmail.com wrote: > > I use a "double indentation". > > > if 'asdf' and 'asdf' and 'asdf' \ > > ... 'asdf' and 'asdf' and \ > > ... 'asdf' and 'asdf': > > ... print('do if') > > ... s = 'asdf' >

RE: A desperate lunge for on-topic-ness

2012-10-18 Thread Prasad, Ramit
Den wrote: > On Wednesday, October 17, 2012 11:06:43 PM UTC-7, Zero Piraeus wrote: > > : > > > > > > What are people's preferred strategies for dealing with lines that go > > > > over 79 characters? A few I can think of off the bat: > > > > I personally just keep typing until my statement is finis

Re: len() on mutables vs. immutables

2012-10-18 Thread Demian Brecht
On 10/18/2012 11:29 AM, Terry Reedy wrote:> Or the length could be the difference of two pointers -- address of the > first empty slot minus address of first item. That would assume contiguous blocks of memory, which I would find to be rather dangerous (of an assumption that is) in most dynamic

Re: len() on mutables vs. immutables

2012-10-18 Thread Demian Brecht
On 10/18/2012 11:28 AM, Nick Cash wrote: It appears that list has len() complexity of O(1) source: http://wiki.python.org/moin/TimeComplexity It may be worth mentioning that lists in Python are implemented using arrays instead of linked lists. It's reasonable to assume that other built-in colle

Re: len() on mutables vs. immutables

2012-10-18 Thread Terry Reedy
On 10/18/2012 1:23 PM, Demian Brecht wrote: When len() is called passing an immutable built-in type (such as a string), I'd assume that the overhead in doing so is simply a function call and there are no on-call calculations done. Is that correct? See below. I'd also assume that mutable buil

Re: A desperate lunge for on-topic-ness

2012-10-18 Thread Grant Edwards
On 2012-10-18, Den wrote: > On Wednesday, October 17, 2012 11:06:43 PM UTC-7, Zero Piraeus wrote: > >> What are people's preferred strategies for dealing with lines that go >> >> over 79 characters? A few I can think of off the bat: > > I personally just keep typing until my statement is finished

len() on mutables vs. immutables

2012-10-18 Thread Demian Brecht
I'm curious as to the implementation (I'd be happy to dig through the source, just don't have the time right now). I've seen various implementations across interpreters in the past (some which have been rather shocking) and I'd like to get some insight into Python (well, CPython at this point a

Re: A desperate lunge for on-topic-ness

2012-10-18 Thread Dave Angel
On 10/18/2012 12:58 PM, Chris Kaynor wrote: > On Thu, Oct 18, 2012 at 9:47 AM, Dave Angel wrote: > >> >> But both C++ and Python have automatic concatenation of adjacent >> strings. So you can just start and end each line with a quote, and >> leave off the backslash. >> > That will work in C++ a

Re: A desperate lunge for on-topic-ness

2012-10-18 Thread Chris Kaynor
On Thu, Oct 18, 2012 at 9:47 AM, Dave Angel wrote: > On 10/18/2012 12:26 PM, Chris Angelico wrote: > > On Fri, Oct 19, 2012 at 3:16 AM, Evan Driscoll > wrote: > >>Python isn't as bad as C++ though (my main other language), where > >>80 characters can go by *very* quickly. > >> > >> 2. Ba

Re: A desperate lunge for on-topic-ness

2012-10-18 Thread Dave Angel
On 10/18/2012 12:26 PM, Chris Angelico wrote: > On Fri, Oct 19, 2012 at 3:16 AM, Evan Driscoll wrote: >>Python isn't as bad as C++ though (my main other language), where >>80 characters can go by *very* quickly. >> >> 2. Backslash continuations are *terrible*. I hate them with a firery >>

Re: A desperate lunge for on-topic-ness

2012-10-18 Thread Chris Angelico
On Fri, Oct 19, 2012 at 3:16 AM, Evan Driscoll wrote: >Python isn't as bad as C++ though (my main other language), where >80 characters can go by *very* quickly. > > 2. Backslash continuations are *terrible*. I hate them with a firery >passion. :-) A line could be 1000 characters long

Re: A desperate lunge for on-topic-ness

2012-10-18 Thread Chris Angelico
On Fri, Oct 19, 2012 at 3:13 AM, Neil Cerutti wrote: > Though technology has moved along swiftly, keeping your code > accessible to the guy using a crummy old console xterm might > still be worthwhile, and it makes printouts easy to create. And keeping your interface accessible to someone who can

Re: A desperate lunge for on-topic-ness

2012-10-18 Thread Chris Angelico
On Fri, Oct 19, 2012 at 2:49 AM, Dan Stromberg wrote: > In fact, I tend to do lots of "otherwise pointless" variables, because I > want to be able to quickly and easily insert print statements/functions > without having to split up large commands, during debugging. When will we next have a langu

Re: A desperate lunge for on-topic-ness

2012-10-18 Thread Evan Driscoll
Ooo, a good religious war. How could I resist? :-) Bear in mind that what I say is relative to layout issues, which in the grand scheme of things. So even if I say I really disklike something, it's still not so bad in practice. Except for backslash continuations. :-) On 10/18/2012 01:06 AM, Zero

Re: A desperate lunge for on-topic-ness

2012-10-18 Thread Neil Cerutti
On 2012-10-18, Den wrote: > But I have to say I'm amused by the whole question, and others > related to PEP8. A quick aside, the width of our roads all go > back to the width of a two horse rig. The suggested maximum of > 80 characters goes back to teletype machines, and IBM cards, > and charact

Re: python scripts for web

2012-10-18 Thread chip9munk
thank you guys for pointing the double posting issue out, I am having some issues with the news server i am using, so I am doing this via google.groups at the time! :) i think i managed to fix it -- http://mail.python.org/mailman/listinfo/python-list

Re: Aggressive language on python-list

2012-10-18 Thread Curt
On 2012-10-17, Dwight Hutto wrote: >> Instead of "diabetic", try inserting the word "black" or "female". >> There's no shame in those either, yet I think that the offensiveness >> of either of those words used in that context should be obvious. > > To take it a little further, what if I said I got

Re: python scripts for web

2012-10-18 Thread chip9munk
On Thursday, October 18, 2012 12:02:40 PM UTC+2, Zero Piraeus wrote: > Assuming your scripts accept the request as sent and return an > appropriate response, they are CGI scripts (unless there's some > wrinkle in the precise definition of CGI that escapes me right now). yes, they are, but, I came

Re: python scripts for web

2012-10-18 Thread chip9munk
thank you for the answer! On Thursday, October 18, 2012 12:03:02 PM UTC+2, Chris Angelico wrote: > CGI is a protocol between Apache and your script. What you want to do > is set up Apache to call your CGI scripts. yes, but as I have just answered to Zero, is using mod_wsgi a better strategy? --

Re: A desperate lunge for on-topic-ness

2012-10-18 Thread Den
On Wednesday, October 17, 2012 11:06:43 PM UTC-7, Zero Piraeus wrote: > : > > > What are people's preferred strategies for dealing with lines that go > > over 79 characters? A few I can think of off the bat: > I personally just keep typing until my statement is finished. This is my program,

Re: A desperate lunge for on-topic-ness

2012-10-18 Thread Dan Stromberg
On Wed, Oct 17, 2012 at 11:06 PM, Zero Piraeus wrote: > : > > Okay, so, first thing vaguely Python-related that comes to mind [so > probably not even slightly original, but then that's not really the > point]: > > What are people's preferred strategies for dealing with lines that go > over 79 cha

Re: locking files on Linux

2012-10-18 Thread Oscar Benjamin
On 18 October 2012 16:08, andrea crotti wrote: > 2012/10/18 Oscar Benjamin : >> >> Why not come up with a test that actually shows you if it works? Here >> are two suggestions: >> >> 1) Use time.sleep() so that you know how long the lock is held for. >> 2) Write different data into the file from e

Re: use of exec()

2012-10-18 Thread Chris Angelico
On Fri, Oct 19, 2012 at 2:00 AM, lars van gemerden wrote: > I get your point, since in this case having the custom code option makes the > system a whole lot less complex and flexible, i will leave the option in. The > future customer will be informed that they should handle the security around

Re: python scripts for web

2012-10-18 Thread rurpy
On 10/18/2012 04:02 AM, Zero Piraeus wrote:> On 18 October 2012 05:22, wrote: >>[...] > By the way: are you using Google Groups? It's just that I'm led to > understand that it's recently started to misbehave [more than it used > to], and your replies are addressed to both > and , > which is red

Re: Inheritance Question

2012-10-18 Thread Jeff Jeffries
On Thu, Oct 18, 2012 at 10:51 AM, Dave Angel wrote: > On 10/18/2012 10:10 AM, Jeff Jeffries wrote: > > Hello everybody > > > > When I set "AttributeChanges" in my example, it sets the same value for > all > > other subclasses. Can someone help me with what the name of this behavior > > is (mutabl

Re: locking files on Linux

2012-10-18 Thread andrea crotti
2012/10/18 Oscar Benjamin : > > Why not come up with a test that actually shows you if it works? Here > are two suggestions: > > 1) Use time.sleep() so that you know how long the lock is held for. > 2) Write different data into the file from each process and see what > you end up with. > Ok thank

Re: locking files on Linux

2012-10-18 Thread Oscar Benjamin
On 18 October 2012 15:49, andrea crotti wrote: > 2012/10/18 Grant Edwards : >> >> If what you're guarding against is multiple instances of your >> application modifying the file, then either of the advisory file >> locking schemes or the separate lock file should work fine. > > Ok so I tried a sma

Re: use of exec()

2012-10-18 Thread lars van gemerden
On Thursday, October 18, 2012 4:29:45 PM UTC+2, Chris Angelico wrote: > On Fri, Oct 19, 2012 at 1:07 AM, lars van gemerden > wrote: > > > Thanks, Chris, > > > > > > That works like a charm (after replacig "return ns.function" with "return > > ns['function']" ;-) ). > > > > Err, yes, I forg

Re: Inheritance Question

2012-10-18 Thread Dave Angel
On 10/18/2012 10:10 AM, Jeff Jeffries wrote: > Hello everybody > > When I set "AttributeChanges" in my example, it sets the same value for all > other subclasses. Can someone help me with what the name of this behavior > is (mutable class global?) ? I don't know any keywords... having > troubl

Re: Inheritance Question

2012-10-18 Thread Oscar Benjamin
On 18 October 2012 15:10, Jeff Jeffries wrote: > Hello everybody > > When I set "AttributeChanges" in my example, it sets the same value for all > other subclasses. Can someone help me with what the name of this behavior is > (mutable class global?) ? I don't know any keywords... having troub

Re: use of exec()

2012-10-18 Thread Chris Angelico
On Fri, Oct 19, 2012 at 1:07 AM, lars van gemerden wrote: > Thanks, Chris, > > That works like a charm (after replacig "return ns.function" with "return > ns['function']" ;-) ). Err, yes, I forget sometimes that Python doesn't do that. JavaScript and Pike both let you (though Pike uses -> instea

Re: use of exec()

2012-10-18 Thread lars van gemerden
On Thursday, October 18, 2012 1:49:35 PM UTC+2, Chris Angelico wrote: > On Thu, Oct 18, 2012 at 10:41 PM, lars van gemerden > > wrote: > > > NameError: name 'function' is not defined > > > > > > which seems an odd error, but i think some global variable is necessary for > > this to work (if i

Re: A desperate lunge for on-topic-ness

2012-10-18 Thread Jean-Michel Pichavant
- Original Message - > On 2012-10-18, Zero Piraeus wrote: > > > What are people's preferred strategies for dealing with lines that > > go > > over 79 characters? A few I can think of off the bat: > > I try to do what's easiest to read and understand. Sometimes that > means using a line

Re: locking files on Linux

2012-10-18 Thread Grant Edwards
On 2012-10-18, andrea crotti wrote: > 2012/10/18 Grant Edwards : >> On 2012-10-18, andrea crotti wrote: >> >> File locks under Unix have historically been "advisory". That means >> that programs have to _choose_ to pay attention to them. Most >> programs do not. >> >> Linux does support mandato

Re: locking files on Linux

2012-10-18 Thread Oscar Benjamin
On 18 October 2012 14:44, andrea crotti wrote: > 2012/10/18 Grant Edwards : >> On 2012-10-18, andrea crotti wrote: >> >> >> File locks under Unix have historically been "advisory". That means >> that programs have to _choose_ to pay attention to them. Most >> programs do not. >> >> Linux does s

Re: locking files on Linux

2012-10-18 Thread andrea crotti
2012/10/18 Grant Edwards : > On 2012-10-18, andrea crotti wrote: > > > File locks under Unix have historically been "advisory". That means > that programs have to _choose_ to pay attention to them. Most > programs do not. > > Linux does support mandatory locking, but it's rarely used and must be

Re: locking files on Linux

2012-10-18 Thread Grant Edwards
On 2012-10-18, andrea crotti wrote: > I'm trying to understand how I can lock a file while writing on it, > because I might have multiple processes working on it at the same time. > > I found the fcntl.lockf function but if I do this: > > In [109]: locked = open('locked.txt', 'w') > > In [110]: f

Re: A desperate lunge for on-topic-ness

2012-10-18 Thread Grant Edwards
On 2012-10-18, Zero Piraeus wrote: > What are people's preferred strategies for dealing with lines that go > over 79 characters? A few I can think of off the bat: I try to do what's easiest to read and understand. Sometimes that means using a line thats 120 characters long, sometimes that means

Python Web Frameworks PEP8 Consistency

2012-10-18 Thread Andriy Kornatskyy
The code is read much more often than it is written. The PEP8 guidelines are intended to improve the readability of code. We will take a look at web frameworks source code readability (bottle, cherrypy, circuits, django, flask, pyramid, tornado, web.py, web2py and wheezy.web): http://mindref.

[ANN] PyPyODBC 0.8.7 released

2012-10-18 Thread 江文
PyPyODBC - A Pure Python ctypes ODBC module Features -Pure Python, compatible with IronPython and PyPy (tested on Win32) -Almost totally same usage as pyodbc -Simple and small - the whole module is implemented in a less than 2000 lines python script You can simply try pypy

Re: use of exec()

2012-10-18 Thread Chris Angelico
On Thu, Oct 18, 2012 at 10:41 PM, lars van gemerden wrote: > NameError: name 'function' is not defined > > which seems an odd error, but i think some global variable is necessary for > this to work (if i put in globals() instead of {}, it works). The def statement simply adds a name to the curre

use of exec()

2012-10-18 Thread lars van gemerden
I am trying to implement a way to let users give a limited possibility to define functions in text, that wille be stored and executed at a later time. I use exec() to transform the text to a function. The code is as follows: class code(str): def __call__(self, *args): try:

Re: A desperate lunge for on-topic-ness

2012-10-18 Thread Tim Chase
On 10/18/12 04:33, wxjmfa...@gmail.com wrote: > I use a "double indentation". > if 'asdf' and 'asdf' and 'asdf' \ > ... 'asdf' and 'asdf' and \ > ... 'asdf' and 'asdf': > ... print('do if') > ... s = 'asdf' > ... ss = 'asdf' > ... > do if if looks_like_it

Re: A desperate lunge for on-topic-ness

2012-10-18 Thread Zero Piraeus
: There seems to be a consensus [to the extent there ever is, anyway] around using parentheses etc., then ... On 18 October 2012 02:31, Steven D'Aprano wrote: > I've been burnt enough by word-wrapping in editors that don't handle word- > wrapping that well that it makes me really uncomfortable t

Re: Remove uncide notation

2012-10-18 Thread Ashish Jain
On Thursday, 18 October 2012 15:10:33 UTC+5:30, Chris Rebert wrote: > On Thu, Oct 18, 2012 at 2:27 AM, Ashish Jain wrote: > > > Hi, > > > > > > I have a html string in an object, when I do repr() of that object, I get > > value as: > > > > > > {'Id' : 1, 'Body': u' Hello '} > > > > > > I d

Re: Change computername

2012-10-18 Thread Chris Angelico
On Thu, Oct 18, 2012 at 7:22 PM, Anatoli Hristov wrote: > It does not work the result is "0" > > And I don't find any documentation about it :( Microsoft's official documentation can usually be found at the other end of a web search. In this case: http://msdn.microsoft.com/en-us/library/windows/

Re: python scripts for web

2012-10-18 Thread Chris Angelico
On Thu, Oct 18, 2012 at 8:22 PM, wrote: > On Thursday, October 18, 2012 10:42:56 AM UTC+2, Zero Piraeus wrote: >> That is exactly what a webserver does. Is there some reason you don't >> want to use e.g. Apache to handle the requests? > > no reason at all. so i guess the solution is much easier t

Re: Aggressive language on python-list

2012-10-18 Thread Robert Kern
On 10/18/12 6:43 AM, David Hutto wrote: On Thu, Oct 18, 2012 at 1:29 AM, Steven D'Aprano wrote: David, While I acknowledge and appreciate your efforts to be less aggressive on this list, I think you have crossed a line by forwarding the contents of an obviously personal email containing CLEARL

Re: python scripts for web

2012-10-18 Thread Zero Piraeus
: On 18 October 2012 05:22, wrote: > So i guess in that case i do not need cgi or anything? Assuming your scripts accept the request as sent and return an appropriate response, they are CGI scripts (unless there's some wrinkle in the precise definition of CGI that escapes me right now). > Than

Re: A desperate lunge for on-topic-ness

2012-10-18 Thread Chris Angelico
On Thu, Oct 18, 2012 at 8:07 PM, Hans Mulder wrote: > > if looks_like_it_might_be_spam( > some_longer_variables, > here_and_here, and_here_also): > logger.notice("might be spam") > move_to_spam_folder(some_longer_variables) > update_spam_statistics(here_and_here) > This wants

Re: Aggressive language on python-list

2012-10-18 Thread Dave Angel
On 10/18/2012 02:19 AM, rusi wrote: > > > IOW the robustness principle http://en.wikipedia.org/wiki/Robustness_principle > is as good for human networking as for computers. > > The catch to that is that the software that is liberally accepting anything is quite vulnerable to attacks. Windows has

Re: Remove uncide notation

2012-10-18 Thread Chris Rebert
On Thu, Oct 18, 2012 at 2:27 AM, Ashish Jain wrote: > Hi, > > I have a html string in an object, when I do repr() of that object, I get > value as: > > {'Id' : 1, 'Body': u' Hello '} > > I don't wish to have 'u' as the character in my string representation. As > this is not a valid json notation

Re: A desperate lunge for on-topic-ness

2012-10-18 Thread wxjmfauth
Le jeudi 18 octobre 2012 11:07:25 UTC+2, Hans Mulder a écrit : > On 18/10/12 08:31:51, Steven D'Aprano wrote: > > > On Thu, 18 Oct 2012 02:06:19 -0400, Zero Piraeus wrote: > > >> 3. Say "well, at least it's not a backslash" and break the line using > > >> > parentheses. > > > I mostly do this.

Remove uncide notation

2012-10-18 Thread Ashish Jain
Hi, I have a html string in an object, when I do repr() of that object, I get value as: {'Id' : 1, 'Body': u' Hello '} I don't wish to have 'u' as the character in my string representation. As this is not a valid json notation now. Thanks for your help -Ashish -- http://mail.python.org/mail

Re: python scripts for web

2012-10-18 Thread chip9munk
On Thursday, October 18, 2012 10:42:56 AM UTC+2, Zero Piraeus wrote: > That is exactly what a webserver does. Is there some reason you don't > want to use e.g. Apache to handle the requests? no reason at all. so i guess the solution is much easier then I have anticipated. So i guess in that case

Re: A desperate lunge for on-topic-ness

2012-10-18 Thread Mark Lawrence
On 18/10/2012 07:06, Zero Piraeus wrote: : Okay, so, first thing vaguely Python-related that comes to mind [so probably not even slightly original, but then that's not really the point]: What are people's preferred strategies for dealing with lines that go over 79 characters? A few I can think

Re: A desperate lunge for on-topic-ness

2012-10-18 Thread Hans Mulder
On 18/10/12 08:31:51, Steven D'Aprano wrote: > On Thu, 18 Oct 2012 02:06:19 -0400, Zero Piraeus wrote: >> 3. Say "well, at least it's not a backslash" and break the line using >> > parentheses. > I mostly do this. Since most lines include a bracket of some sort, I > rarely need to add outer parent

Re: python scripts for web

2012-10-18 Thread Zero Piraeus
: On 18 October 2012 04:10, wrote: > I will give you an example. So let us say I create two simple python > scripts, one does the sum of two numbers > the other one does the multiplication. SO now I want to put these > scripts on the server. Now let us say there is a web page that would > like t

Re: Change computername

2012-10-18 Thread Anatoli Hristov
It does not work the result is "0" And I don't find any documentation about it :( On Thu, Oct 18, 2012 at 8:41 AM, Anatoli Hristov wrote: > Thank you, > > I will test this, will keep you posted. > > Anatoli > > On Wed, Oct 17, 2012 at 7:47 PM, Ian Kelly wrote: >> On Wed, Oct 17, 2012 at 8:07 A

Re: python scripts for web

2012-10-18 Thread chip9munk
To explain, I am basically doing different algorithms and would like to make them work and be accessible as I mentioned in the example... and to add them to the functionality of a specific page... so I have experience in programming, just no experience in web development etc.. On Thursday, Oct

Re: python scripts for web

2012-10-18 Thread Zero Piraeus
: On 18 October 2012 03:18, wrote: > Here is what I need to do: on some webpage (done in php, or any other > different technology), user inputs some data, that data and the > request then goes to the server where python scripts calculate > something and return the result to the users end. > > No

Re: Aggressive language on python-list

2012-10-18 Thread rusi
On Oct 18, 11:27 am, David Hutto wrote: > > [BTW This was enunciated 2000 years ago by a clever chap: Love your > > enemies; drive them crazy > > That only works if they're not already insane. > Otherwise you're just prodding a cornered beast. Usually but not necessarily http://en.wikipedia.org/w

  1   2   >