ANN: v0.3 of pipe_controller released; supports swapping pipe components at run time

2012-10-18 Thread vasudevram
I've released v0.3 of pipe_controller (*), my experimental tool to simulate pipes in Python: https://bitbucket.org/vasudevram/pipe_controller (*) I had earlier been calling it PipeController, but that is the name of the main class in the package. From now on I'm referring to it as

pyNVML - GPU Monitoring and Management

2012-10-18 Thread Robert Alexander
I'm pleased to announce the release of pyNVML 3.304: Python Bindings for the NVIDIA Management Library. pyNVML provides programmatic access to static information and monitoring data for NVIDIA GPUs, as well as management capabilities. It exposes the functionality of the NVML library. See

A desperate lunge for on-topic-ness

2012-10-18 Thread Zero Piraeus
: 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 of off the bat: 1. Say screw it and go

Re: A desperate lunge for on-topic-ness

2012-10-18 Thread Chris Angelico
On Thu, Oct 18, 2012 at 5:06 PM, Zero Piraeus sche...@gmail.com 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: 1. Say screw it and go past 79, PEP8 be damned. 6. Realise that if it's that long, it probably

Re: Aggressive language on python-list

2012-10-18 Thread rusi
On Oct 18, 10:18 am, Zero Piraeus sche...@gmail.com wrote: : On 18 October 2012 00:36, rusi rustompm...@gmail.com wrote: Unfortunately, I feel this whole discussion/thread has got derailed: Zero you started this thread about aggressive behavior. It does not seem to me that this was the

Re: Aggressive language on python-list

2012-10-18 Thread David Hutto
On Thu, Oct 18, 2012 at 2:19 AM, rusi rustompm...@gmail.com wrote: On Oct 18, 10:18 am, Zero Piraeus sche...@gmail.com wrote: : On 18 October 2012 00:36, rusi rustompm...@gmail.com wrote: Unfortunately, I feel this whole discussion/thread has got derailed: Zero you started this thread

Re: A desperate lunge for on-topic-ness

2012-10-18 Thread Steven D'Aprano
On Thu, 18 Oct 2012 02:06:19 -0400, 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: 1. Say screw it and go past 79, PEP8 be damned. I've been burnt enough by word-wrapping in editors that don't

Re: Change computername

2012-10-18 Thread Anatoli Hristov
Thank you, I will test this, will keep you posted. Anatoli On Wed, Oct 17, 2012 at 7:47 PM, Ian Kelly ian.g.ke...@gmail.com wrote: On Wed, Oct 17, 2012 at 8:07 AM, Anatoli Hristov toli...@gmail.com wrote: Hello, Can you please help me out how can I change the computername of windows XP

Re: A desperate lunge for on-topic-ness

2012-10-18 Thread Demian Brecht
3. Say well, at least it's not a backslash and break the line using parentheses. This. More times than not, there's a function call in that line, which makes sense to me when reading it if the args are on the next line. 4. Spend 45 minutes trying to think up shorter [but still sensible]

Re: unittest for system testing

2012-10-18 Thread Steven D'Aprano
Sorry for breaking threading, but the original post has not come through to me. On 18/10/2012 01:22, Rita wrote: Hi, Currently, I use a shell script to test how my system behaves before I deploy an application. For instance, I check if fileA, fileB, and fileC exist and if they do I go and

Re: A desperate lunge for on-topic-ness

2012-10-18 Thread rusi
On Oct 18, 11:06 am, Zero Piraeus sche...@gmail.com 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

Re: A desperate lunge for on-topic-ness

2012-10-18 Thread Paul Rubin
Zero Piraeus sche...@gmail.com writes: 2. Say screw it and break the line using a backslash. Often the line will break ok without a backslash, but I don't feel any particular pain in using a backslash in the other cases. I do pretty rigorously try to keep all lines shorter than 72 columns or

Re: Aggressive language on python-list

2012-10-18 Thread Zero Piraeus
: On 18 October 2012 02:19, rusi rustompm...@gmail.com wrote: I understood that your original post started after Etienne's outburst against Steven. Ah, I see. It was intended as a general request for politeness, but yes, IIRC that was the exchange that prompted it. IOW the robustness

python scripts for web

2012-10-18 Thread chip9munk
Hello all! Please help me start learning about this thing. Sorry for my inexperience! 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

Re: Aggressive language on python-list

2012-10-18 Thread rusi
On Oct 18, 11:27 am, David Hutto dwightdhu...@gmail.com 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

Re: python scripts for web

2012-10-18 Thread Zero Piraeus
: On 18 October 2012 03:18, chip9m...@gmail.com 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

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,

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 toli...@gmail.com wrote: Thank you, I will test this, will keep you posted. Anatoli On Wed, Oct 17, 2012 at 7:47 PM, Ian Kelly ian.g.ke...@gmail.com wrote: On

Re: python scripts for web

2012-10-18 Thread Zero Piraeus
: On 18 October 2012 04:10, chip9m...@gmail.com 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

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 parentheses

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

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'p Hello /p'} 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 --

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. Since most lines

Re: Remove uncide notation

2012-10-18 Thread Chris Rebert
On Thu, Oct 18, 2012 at 2:27 AM, Ashish Jain ashishjain@gmail.com 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'p Hello /p'} I don't wish to have 'u' as the character in my string representation. As this is not a

Re: Aggressive language on python-list

2012-10-18 Thread Dave Angel
On 10/18/2012 02:19 AM, rusi wrote: snip 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: A desperate lunge for on-topic-ness

2012-10-18 Thread Chris Angelico
On Thu, Oct 18, 2012 at 8:07 PM, Hans Mulder han...@xs4all.nl 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

Re: python scripts for web

2012-10-18 Thread Zero Piraeus
: On 18 October 2012 05:22, chip9m...@gmail.com 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

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 steve+comp.lang.pyt...@pearwood.info 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

Re: python scripts for web

2012-10-18 Thread Chris Angelico
On Thu, Oct 18, 2012 at 8:22 PM, chip9m...@gmail.com 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

Re: Change computername

2012-10-18 Thread Chris Angelico
On Thu, Oct 18, 2012 at 7:22 PM, Anatoli Hristov toli...@gmail.com 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:

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'p Hello /p'} I don't wish to have

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 steve+comp.lang.pyt...@pearwood.info wrote: I've been burnt enough by word-wrapping in editors that don't handle word- wrapping that well that

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_might_be_spam(

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: use of exec()

2012-10-18 Thread Chris Angelico
On Thu, Oct 18, 2012 at 10:41 PM, lars van gemerden l...@rational-it.com 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

[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

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

Re: A desperate lunge for on-topic-ness

2012-10-18 Thread Grant Edwards
On 2012-10-18, Zero Piraeus sche...@gmail.com 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,

Re: locking files on Linux

2012-10-18 Thread Grant Edwards
On 2012-10-18, andrea crotti andrea.crott...@gmail.com 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',

Re: locking files on Linux

2012-10-18 Thread andrea crotti
2012/10/18 Grant Edwards invalid@invalid.invalid: On 2012-10-18, andrea crotti andrea.crott...@gmail.com 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

Re: locking files on Linux

2012-10-18 Thread Oscar Benjamin
On 18 October 2012 14:44, andrea crotti andrea.crott...@gmail.com wrote: 2012/10/18 Grant Edwards invalid@invalid.invalid: On 2012-10-18, andrea crotti andrea.crott...@gmail.com wrote: File locks under Unix have historically been advisory. That means that programs have to _choose_ to pay

Re: locking files on Linux

2012-10-18 Thread Grant Edwards
On 2012-10-18, andrea crotti andrea.crott...@gmail.com wrote: 2012/10/18 Grant Edwards invalid@invalid.invalid: On 2012-10-18, andrea crotti andrea.crott...@gmail.com wrote: File locks under Unix have historically been advisory. That means that programs have to _choose_ to pay attention to

Re: A desperate lunge for on-topic-ness

2012-10-18 Thread Jean-Michel Pichavant
- Original Message - On 2012-10-18, Zero Piraeus sche...@gmail.com 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

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 l...@rational-it.com wrote: NameError: name 'function' is not defined which seems an odd error, but i think some global variable is necessary for this to

Re: use of exec()

2012-10-18 Thread Chris Angelico
On Fri, Oct 19, 2012 at 1:07 AM, lars van gemerden l...@rational-it.com 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

Re: Inheritance Question

2012-10-18 Thread Oscar Benjamin
On 18 October 2012 15:10, Jeff Jeffries jeff.jeffries@gmail.com 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

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 trouble

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 l...@rational-it.com wrote: Thanks, Chris, That works like a charm (after replacig return ns.function with return ns['function'] ;-) ). Err, yes, I

Re: locking files on Linux

2012-10-18 Thread Oscar Benjamin
On 18 October 2012 15:49, andrea crotti andrea.crott...@gmail.com wrote: 2012/10/18 Grant Edwards invalid@invalid.invalid: 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

Re: locking files on Linux

2012-10-18 Thread andrea crotti
2012/10/18 Oscar Benjamin oscar.j.benja...@gmail.com: 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

Re: Inheritance Question

2012-10-18 Thread Jeff Jeffries
On Thu, Oct 18, 2012 at 10:51 AM, Dave Angel d...@davea.name 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

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, chip9m...@gmail.com 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

Re: use of exec()

2012-10-18 Thread Chris Angelico
On Fri, Oct 19, 2012 at 2:00 AM, lars van gemerden l...@rational-it.com 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

Re: locking files on Linux

2012-10-18 Thread Oscar Benjamin
On 18 October 2012 16:08, andrea crotti andrea.crott...@gmail.com wrote: 2012/10/18 Oscar Benjamin oscar.j.benja...@gmail.com: 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)

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 sche...@gmail.com 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

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, not

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: 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: Aggressive language on python-list

2012-10-18 Thread Curt
On 2012-10-17, Dwight Hutto dwightdhu...@gmail.com 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

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: A desperate lunge for on-topic-ness

2012-10-18 Thread Neil Cerutti
On 2012-10-18, Den patents...@gmail.com 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

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 Chris Angelico
On Fri, Oct 19, 2012 at 2:49 AM, Dan Stromberg drsali...@gmail.com 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

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 ne...@norwich.edu 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

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 drisc...@cs.wisc.edu 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

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 drisc...@cs.wisc.edu 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

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 d...@davea.name wrote: On 10/18/2012 12:26 PM, Chris Angelico wrote: On Fri, Oct 19, 2012 at 3:16 AM, Evan Driscoll drisc...@cs.wisc.edu wrote: Python isn't as bad as C++ though (my main other language), where 80 characters can go by

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 d...@davea.name wrote: SNIP 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

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

Re: A desperate lunge for on-topic-ness

2012-10-18 Thread Grant Edwards
On 2012-10-18, Den patents...@gmail.com 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

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

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

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: 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 finished. This is my

Re: A desperate lunge for on-topic-ness

2012-10-18 Thread Joshua Landau
On 18 October 2012 12:05, Tim Chase python.l...@tim.thechases.com 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 =

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 ne...@norwich.edu 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

RE: OT Questions

2012-10-18 Thread Prasad, Ramit
David Hutto wrote: On Wed, Oct 17, 2012 at 7:12 PM, Steven D'Aprano steve+comp.lang.pyt...@pearwood.info 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

RE: OT Questions

2012-10-18 Thread Prasad, Ramit
David Hutto wrote: On Wed, Oct 17, 2012 at 12:38 PM, Prasad, Ramit ramit.pra...@jpmorgan.com wrote: David Hutto wrote: On Wed, Oct 17, 2012 at 2:06 AM, Demian Brecht demianbre...@gmail.com wrote: [snip] The question is whose opinion matters. Yours? Mine? Others? Personally, I

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 point

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 rarely need to

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. I'd

Re: len() on mutables vs. immutables

2012-10-18 Thread Ian Kelly
On Thu, Oct 18, 2012 at 1:18 PM, Prasad, Ramit ramit.pra...@jpmorgan.com 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

Re: len() on mutables vs. immutables

2012-10-18 Thread Daniel Urban
On Thu, Oct 18, 2012 at 8:42 PM, Demian Brecht demianbre...@gmail.com 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

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 ramit.pra...@jpmorgan.com wrote: Why does pointer arithmetic work for dicts? I would think the position of a value would be

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 d...@davea.name 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

Re: python scripts for web

2012-10-18 Thread Zero Piraeus
: On 18 October 2012 12:03, chip9m...@gmail.com 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

Re: A desperate lunge for on-topic-ness

2012-10-18 Thread Zero Piraeus
: On 18 October 2012 11:55, Den patents...@gmail.com 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

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

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 to gcc-4.2.

Re: len() on mutables vs. immutables

2012-10-18 Thread Demian Brecht
On Thu, Oct 18, 2012 at 12:43 PM, Daniel Urban urban.d...@gmail.com 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.,

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 pengyu...@gmail.com 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

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 ramit.pra...@jpmorgan.com 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

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 patents...@gmail.com 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

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

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: scan num='1' peakssome data/peaks scan num='2' peakssome data/peaks /scan scan num='3' peakssome data/peaks /scan /scan What I am trying to do is build up a dictionary of lists where the

Re: A desperate lunge for on-topic-ness

2012-10-18 Thread Ben Finney
Zero Piraeus sche...@gmail.com 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

Re: A desperate lunge for on-topic-ness

2012-10-18 Thread Ben Finney
Hans Mulder han...@xs4all.nl 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

Re: A desperate lunge for on-topic-ness

2012-10-18 Thread Ben Finney
Jean-Michel Pichavant jeanmic...@sequans.com 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

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 what

  1   2   3   >