Colour sampling

2009-10-15 Thread Dylan Palmboom
Does anyone know what python libraries are available to do the following: 1. I would like to take a photograph of an object with a colour. In this case, it is a sheet of sponge. 2. Feed this image into a function in a python library and let the function automatically scan this image's pixel

() vs. [] operator

2009-10-15 Thread Ole Streicher
Hi, I am curious when one should implement a __call__() and when a __getitem__() method. For example, I want to display functions and data in the same plot. For a function, the natural interface would to be called as f(x), while the natural interface for data would be f[x]. On the other hand,

Error received from _mechanize.py

2009-10-15 Thread Raji Seetharaman
Hi all, Im learning web scraping with python from the following link http://www.packtpub.com/article/web-scraping-with-python To work with it, mechanize to be installed I installed mechanize using sudo apt-get install python-mechanize As given in the tutorial, i tried the code as below

Re: () vs. [] operator

2009-10-15 Thread Steven D'Aprano
On Thu, 15 Oct 2009 09:14:35 +0200, Ole Streicher wrote: So what is the reason that Python has separate __call__()/() and __getitem__()/[] interfaces and what is the rule to choose between them? They are separate so you can implement both, or just one, or neither, whichever makes the most

Re: () vs. [] operator

2009-10-15 Thread Xavier Ho
On Thu, Oct 15, 2009 at 5:14 PM, Ole Streicher ole-usenet-s...@gmx.netwrote: snip So what is the reason that Python has separate __call__()/() and __getitem__()/[] interfaces and what is the rule to choose between them? Hi, This is very interesting, a thought that never occured to me before.

Re: () vs. [] operator

2009-10-15 Thread Chris Rebert
On Thu, Oct 15, 2009 at 12:14 AM, Ole Streicher ole-usenet-s...@gmx.net wrote: Hi, I am curious when one should implement a __call__() and when a __getitem__() method. For example, I want to display functions and data in the same plot. For a function, the natural interface would to be

Re: the usage of 'yield' keyword

2009-10-15 Thread Tim Golden
Dave Angel wrote: def find(root): for pdf in os.walk(root, topdown=False): for file in pdf[2]: yield os.path.join(pdf[0],file) At the risk of nitpicking, I think that a modicum of tuple-unpacking would aid readability here: code for dirpath, dirnames,

Re: The rap against while True: loops

2009-10-15 Thread Tim Rowe
2009/10/11 Philip Semanchuk phi...@semanchuk.com: IMHO, break, goto, etc. have their place, but they're ripe for abuse which leads to spaghetti code. Unrestricted goto can leat to spaghetti code, but surely break can't? AFAICS, any break construct will still be H-K reducible. -- Tim Rowe --

creating a slide show in JES

2009-10-15 Thread Matthew manzo
I need to create a slideshow in JES but am not sure how to do it. Can anyone help me with this. How do i create a slideshow that has a song and then two images where one image begins then the second image slowly blends in and takes over the first image? --

Re: () vs []

2009-10-15 Thread Mick Krippendorf
mattia schrieb: Any particular difference in using for a simple collection of element () over [] or vice-versa? Just try this and you'll see: tup = (1,2,3) tup.append(4) or: tup = (1,2,3) tup[0] = 4 HTH, Mick. -- http://mail.python.org/mailman/listinfo/python-list

() vs []

2009-10-15 Thread mattia
Any particular difference in using for a simple collection of element () over [] or vice-versa? Thanks, Mattia -- http://mail.python.org/mailman/listinfo/python-list

Re: () vs []

2009-10-15 Thread Nanjundi
On Oct 14, 1:05 pm, mattia ger...@gmail.com wrote: Any particular difference in using for a simple collection of element () over [] or vice-versa? Thanks, Mattia From: http://www.faqs.org/docs/diveintopython/odbchelper_tuple.html 1 You can’t add elements to a tuple. Tuples have no

Re: the usage of 'yield' keyword

2009-10-15 Thread Paul Rudin
Peng Yu pengyu...@gmail.com writes: http://docs.python.org/reference/simple_stmts.html#grammar-token-yield_stmt The explanation of yield is not clear to me, as I don't know what a generator is. I see the following example using 'yield'. Could somebody explain how 'yield' works in this

Re: Error received from _mechanize.py

2009-10-15 Thread Chris Rebert
On Thu, Oct 15, 2009 at 12:39 AM, Raji Seetharaman sraji...@gmail.com wrote: Hi all, Im learning web scraping with python from the following link http://www.packtpub.com/article/web-scraping-with-python To work with it,  mechanize to be installed I installed mechanize using sudo apt-get

Re: efficient running median

2009-10-15 Thread Raymond Hettinger
[Janto Dreijer] I found a PDF by Soumya D. Mohanty entitled Efficient Algorithm for computing a Running Median (2003) by Googling. It has code snippets at the end, but it's not going to be a simple cut-and-paste job. It will take some work figuring out the missing parts. See

Re: segmentation fault

2009-10-15 Thread ankita dutta
thanx david, yes ,i am using matplotlib for plotting graph. i am using this lines in my programme: import matplotlib.pyplot as plt now, if the problem with matplotlib ( and i will send them mail) , but can you kindly tell alternatively , how can i plot graph for my programme. ankita On Thu,

Re: segmentation fault

2009-10-15 Thread ankita dutta
hi chris, i am using matplotlib for plotting graph, as following: import matplotlib.pyplot as plt can you kindly tell me how to fix this problem(crashing) ? On Thu, Oct 15, 2009 at 3:36 PM, Chris Rebert c...@rebertia.com wrote: On Thu, Oct 15, 2009 at 2:14 AM, ankita dutta

set using alternative hash function?

2009-10-15 Thread Austin Bingham
If I understand things correctly, the set class uses hash() universally to calculate hash values for its elements. Is there a standard way to have set use a different function? Say I've got a collection of objects with names. I'd like to create a set of these objects where the hashing is done on

Re: set using alternative hash function?

2009-10-15 Thread Chris Rebert
On Thu, Oct 15, 2009 at 4:24 AM, Austin Bingham austin.bing...@gmail.com wrote: If I understand things correctly, the set class uses hash() universally to calculate hash values for its elements. Is there a standard way to have set use a different function? Say I've got a collection of objects

Re: segmentation fault

2009-10-15 Thread David Cournapeau
On Thu, Oct 15, 2009 at 7:46 PM, ankita dutta ankita.dutt...@gmail.com wrote: thanx david, yes ,i am using matplotlib for plotting graph. i am using this lines in my programme: import matplotlib.pyplot as plt now, if the problem with matplotlib ( and i will send them mail) , The problem

Re: set using alternative hash function?

2009-10-15 Thread Duncan Booth
Austin Bingham austin.bing...@gmail.com wrote: If I understand things correctly, the set class uses hash() universally to calculate hash values for its elements. Is there a standard way to have set use a different function? Say I've got a collection of objects with names. I'd like to create a

Re: set using alternative hash function?

2009-10-15 Thread Austin Bingham
That's definitely a workable solution, but it still rubs me the wrong way. The uniqueness criteria of a set seems, to me, like a property of the set, whereas the python model forces it onto each set element. Another issue I have with the HashWrapper approach is its space requirements. Logically,

Re: set using alternative hash function?

2009-10-15 Thread Austin Bingham
I guess we see things differently. I think it's quite natural to want a set of unique objects where unique is defined as an operation on some subset/conflation/etc. of the attributes of the elements. That's all that the regular set class is, except that it always uses the hash() function to

Re: set using alternative hash function?

2009-10-15 Thread Diez B. Roggisch
Austin Bingham wrote: If I understand things correctly, the set class uses hash() universally to calculate hash values for its elements. Is there a standard way to have set use a different function? Say I've got a collection of objects with names. I'd like to create a set of these objects

Re: segmentation fault

2009-10-15 Thread ankita dutta
hi, well, even i was also using matplotlib for some time, and it was working fine. but this time i use it for data which is quite large,( my input file has single column of float values , and length ( no. of rows) of this column is 10,000,000. ) may be because of size it might have crashed. any

Re: segmentation fault

2009-10-15 Thread David Cournapeau
On Thu, Oct 15, 2009 at 9:08 PM, ankita dutta ankita.dutt...@gmail.com wrote: hi, well, even i was also using matplotlib for some time, and it was working fine. but this time i use it for data which is quite large,( my input file has single column of float values , and length ( no. of rows)

Re: set using alternative hash function?

2009-10-15 Thread Diez B. Roggisch
Chris Rebert wrote: On Thu, Oct 15, 2009 at 4:24 AM, Austin Bingham austin.bing...@gmail.com wrote: If I understand things correctly, the set class uses hash() universally to calculate hash values for its elements. Is there a standard way to have set use a different function? Say I've got a

Re: set using alternative hash function?

2009-10-15 Thread Diez B. Roggisch
Austin Bingham wrote: That's definitely a workable solution, but it still rubs me the wrong way. The uniqueness criteria of a set seems, to me, like a property of the set, whereas the python model forces it onto each set element. This is a POV, but to to me, the set just deals with a very

Python 2.6.3 and finding init.tcl

2009-10-15 Thread Shawn Wheatley
I'm trying to troubleshoot a bug in VirtualEnv, but in order to do so I need to better understand how Python initializes Tkinter. Setup: Python 2.6.3 on Windows 7 Windows XP SP3 Problem: There is a file called init.tcl that gets loaded when first executing a Tkinter statement. The file is held

Re: id( ) function question

2009-10-15 Thread Mel
Erik Max Francis wrote: Tim Chase wrote: In general, if you're using is (and not comparing with None) or id(), you're doing it wrong unless you already know the peculiarities of Python's identity implementations. Right. Another way to do look at it is that if you're curious about what the

reading joystick data

2009-10-15 Thread Ronn Ross
Hello, I'm using PyUSB 0.4.2 to interact with a Microsoft Sindwinder joystick. I'm using python 2.6 on windows XP. With the code snippet below I'm able to find usb device currently plugged into my computer. Now I would like to actually tap into the data that to joystick is providing to the

set using alternative hash function?

2009-10-15 Thread Austin Bingham
On Thu, Oct 15, 2009 at 2:23 PM, Diez B. Roggisch de...@nospam.web.de wrote: Austin Bingham wrote: This is a POV, but to to me, the set just deals with a very minimal protocol - hash-value equality. Whatever you feed it, it has to cope with that. It strikes *me* as odd to ask for something

Re: set using alternative hash function?

2009-10-15 Thread Diez B. Roggisch
Austin Bingham wrote: On Thu, Oct 15, 2009 at 2:23 PM, Diez B. Roggisch de...@nospam.web.de wrote: Austin Bingham wrote: This is a POV, but to to me, the set just deals with a very minimal protocol - hash-value equality. Whatever you feed it, it has to cope with that. It strikes *me* as

Re: set using alternative hash function?

2009-10-15 Thread Austin Bingham
On Thu, Oct 15, 2009 at 3:02 PM, Diez B. Roggisch de...@nospam.web.de wrote: Austin Bingham wrote: You do. Hashes can collide, and then you need equality. Sets are *based* on equality actually, the hash is just one optimization. ... Right, thanks for clearing that up. Not reading closely

Re: Clear interface for mail class

2009-10-15 Thread Benedict Verheyen
Francesco Bochicchio wrote: snip I would add a server class, maybe subclassing something in standard library, and add to it the 'send' method, so that sending a mail would be something like: myserver = MyMailServer(mysmtpserver, localhost, ) # this only needs to be done once, not for

Re: set using alternative hash function?

2009-10-15 Thread Diez B. Roggisch
And if there were something that would decide on context which of several implementations to use, you'd have less to worry. As things are, there isn't such thing (I don't even have the slightest idea what could work), you are as well off with defining two functions. But this context decider

Re: set using alternative hash function?

2009-10-15 Thread Mick Krippendorf
Austin Bingham schrieb: I guess we see things differently. I think it's quite natural to want a set of unique objects where unique is defined as an operation on some subset/conflation/etc. of the attributes of the elements. What you seem to imply is that the hash function imposes some kind of

Re: set using alternative hash function?

2009-10-15 Thread Austin Bingham
On Thu, Oct 15, 2009 at 3:43 PM, Diez B. Roggisch de...@nospam.web.de wrote: The context-decider isn't the same thing because it isn't designed yet :) And most probably won't ever be. It's just the abstract idea that hashing/equality change for one object depending on the circumstances they

Re: set using alternative hash function?

2009-10-15 Thread Anthony Tolle
On Oct 15, 7:24 am, Austin Bingham austin.bing...@gmail.com wrote: [snip] I'd like to create a set of these objects where the hashing is done on these names. [snip] Why not use a dict? The key would be the object name. Pretty much the same behavior as a set (via the key), and you can still

Re: set using alternative hash function?

2009-10-15 Thread Austin Bingham
On Thu, Oct 15, 2009 at 3:50 PM, Mick Krippendorf mad.m...@gmx.de wrote: Austin Bingham schrieb: What you seem to imply is that the hash function imposes some kind of uniqueness constraint on the set which uses it. That's just not the case, the uniqueness constraint is always the (in-)equality

Re: set using alternative hash function?

2009-10-15 Thread Austin Bingham
On Thu, Oct 15, 2009 at 4:06 PM, Anthony Tolle anthony.to...@gmail.com wrote: Why not use a dict?  The key would be the object name.  Pretty much the same behavior as a set (via the key), and you can still easily iterate over the objects. To reiterate, dict only gets me part of what I want.

Re: HTMLgen???

2009-10-15 Thread Gabriel Genellina
En Thu, 15 Oct 2009 05:58:02 -0300, an...@vandervlies.xs4all.nl escribió: Does HTMLgen (Robin Friedrich's) still exsist?? And, if so, where can it be found? Would you consider using HyperText? It's inspired on HTMLGen but I like its design much more (that said, currently I prefer to use a

Re: set using alternative hash function?

2009-10-15 Thread Anthony Tolle
On Oct 15, 10:42 am, Austin Bingham austin.bing...@gmail.com wrote: On Thu, Oct 15, 2009 at 4:06 PM, Anthony Tolle To reiterate, dict only gets me part of what I want. Whereas a set with uniqueness defined over 'obj.name' would guarantee no name collisions, dict only sorta helps me keep

Raw_input with readline in a daemon thread makes terminal text disappear

2009-10-15 Thread John O'Hagan
I'm getting input for a program while it's running by using raw_input in a loop in separate thread. This works except for the inconvenience of not having a command history or the use of backspace etc. That can be solved by loading the readline module; however, it results in a loss of visible

Re: set using alternative hash function?

2009-10-15 Thread Chris Rebert
On Thu, Oct 15, 2009 at 5:22 AM, Diez B. Roggisch de...@nospam.web.de wrote: Chris Rebert wrote: On Thu, Oct 15, 2009 at 4:24 AM, Austin Bingham austin.bing...@gmail.com wrote: If I understand things correctly, the set class uses hash() universally to calculate hash values for its elements.

How to organize code for conversion between different classes? (avoiding cyclic dependencies)

2009-10-15 Thread Peng Yu
Suppose I have classes 'A', 'B', 'C', 'D'. The definition of these classes are long enough so that I have to put each class in a separate module 'mA', 'mB', 'mC', 'mD', which are in packages 'pA', 'pB', 'pC', 'pD', respectively. And there were no need to have conversion functions between these

Re: HTMLgen???

2009-10-15 Thread tinnews
Gabriel Genellina gagsl-...@yahoo.com.ar wrote: En Thu, 15 Oct 2009 05:58:02 -0300, an...@vandervlies.xs4all.nl escribió: Does HTMLgen (Robin Friedrich's) still exsist?? And, if so, where can it be found? Would you consider using HyperText? It's inspired on HTMLGen but I like its

Re: set using alternative hash function?

2009-10-15 Thread Gabriel Genellina
En Thu, 15 Oct 2009 11:42:20 -0300, Austin Bingham austin.bing...@gmail.com escribió: On Thu, Oct 15, 2009 at 4:06 PM, Anthony Tolle anthony.to...@gmail.com wrote: Why not use a dict?  The key would be the object name.  Pretty much the same behavior as a set (via the key), and you can still

Yet Another Pic Problem

2009-10-15 Thread Victor Subervi
Hi; My code was working fine then I must have inadvertently screwed something up. The result is a mysql insert/update statement that looks something like the following: update productsX set Name=%s, Title=%s, Description=%s, Price=%s, Bedrooms=%s, Bathrooms=%s, Conditions=%s, Acreage=%s,

Re: id( ) function question

2009-10-15 Thread Christian Heimes
Mel wrote: As Python has evolved the semantics have got richer, and the implementation has got trickier with proxy objects and wrapped functions and more. Whatever use there was for `is` in ordinary code is vanishing. 'is' has important use cases but it's not trivial to use if you leave the

Re: id( ) function question

2009-10-15 Thread Laszlo Nagy
The built-ins aren't mutable, and the singletons are each immutable and/or unique; so in no case do objects that are both different and mutable have the same ID. I know. :-) Although I have no idea how it is that `id({}) == id({})` as a prior posted showed; FWIW, I can't manage to

Re: id( ) function question

2009-10-15 Thread Laszlo Nagy
Christian Heimes írta: Chris Rebert wrote: The built-ins aren't mutable, and the singletons are each immutable and/or unique; so in no case do objects that are both different and mutable have the same ID. Correct, the fact allows you to write code like type(egg) is str to check if an

Re: Load a list subset with pickle?

2009-10-15 Thread Peng Yu
On Tue, Oct 13, 2009 at 1:23 PM, Robert Kern robert.k...@gmail.com wrote: On 2009-10-13 13:00 PM, Peng Yu wrote: I use pickle to dump a long list. But when I load it, I only want to load the first a few elements in the list. I am wondering if there is a easy way to do so? Thank you! Not by

Re: set using alternative hash function?

2009-10-15 Thread Austin Bingham
On Thu, Oct 15, 2009 at 5:15 PM, Gabriel Genellina gagsl-...@yahoo.com.ar wrote: En Thu, 15 Oct 2009 11:42:20 -0300, Austin Bingham austin.bing...@gmail.com escribió: I think you didn't understand correctly Anthony Tolle's suggestion: py class Foo: ...   def __init__(self, name): self.name =

Re: id( ) function question

2009-10-15 Thread Laszlo Nagy
None, True, False, integers and strings are not mutable. The only time the id is the same between two objects is if they are the identical two objects. I'm aware of that. ;-) CPython just (as a performance optimization) re-uses the same objects sometimes even if people think they're

Re: set using alternative hash function?

2009-10-15 Thread Rami Chowdhury
On Thu, 15 Oct 2009 09:11:00 -0700, Austin Bingham austin.bing...@gmail.com wrote: On Thu, Oct 15, 2009 at 5:15 PM, Gabriel Genellina gagsl-...@yahoo.com.ar wrote: En Thu, 15 Oct 2009 11:42:20 -0300, Austin Bingham austin.bing...@gmail.com escribió: I think you didn't understand correctly

Re: python performance on Solaris

2009-10-15 Thread Antoine Pitrou
Le Wed, 14 Oct 2009 22:39:14 -0700, John Nagle a écrit : Note that multithreaded compute-bound Python programs really suck on multiprocessors. Adding a second CPU makes the program go slower, due to a lame mechanism for resolving conflicts over the global interpreter lock. I'm not sure

Module naming convention about StringIO

2009-10-15 Thread Peng Yu
It says on http://www.python.org/dev/peps/pep-0008/ Package and Module Names Modules should have short, all-lowercase names. Underscores can be used in the module name if it improves readability. Python packages should also have short, all-lowercase names, although the

Re: Python XMLRPC question

2009-10-15 Thread prasanna
Thanks a bunch. Qill give it a shot. --p On Oct 14, 8:18 pm, Gabriel Genellina gagsl-...@yahoo.com.ar wrote: En Wed, 14 Oct 2009 22:08:09 -0300,prasannaprasa...@ix.netcom.com   escribió: Out of curiosity--one more thing I haven't yet figured out, is there a xmlrpc command I can send that

Re: Module naming convention about StringIO

2009-10-15 Thread Tim Golden
Peng Yu wrote: It says on http://www.python.org/dev/peps/pep-0008/ ... don't get too hung up on things like this. Just use the modules. But StringIO does not following this convention. Although on the same page, it also mentions the following. However, since StringIO is in the library, shall

Problem with character encoding in commandline

2009-10-15 Thread gialloporpora
Dear all, I have a strange problem that I am not able to solve myself. I have written a little Python script to download image from last.fm, now, if I call it from the python environment it works, if I call it from Windows console it doesn't works If I open the prompt and run python I call

Re: Load a list subset with pickle?

2009-10-15 Thread Robert Kern
On 2009-10-15 11:05 AM, Peng Yu wrote: On Tue, Oct 13, 2009 at 1:23 PM, Robert Kernrobert.k...@gmail.com wrote: On 2009-10-13 13:00 PM, Peng Yu wrote: I use pickle to dump a long list. But when I load it, I only want to load the first a few elements in the list. I am wondering if there is a

Re: How to organize code for conversion between different classes? (avoiding cyclic dependencies)

2009-10-15 Thread Stephen Hansen
On Thu, Oct 15, 2009 at 8:02 AM, Peng Yu pengyu...@gmail.com wrote: Suppose I have classes 'A', 'B', 'C', 'D'. The definition of these classes are long enough so that I have to put each class in a separate module 'mA', 'mB', 'mC', 'mD', which are in packages 'pA', 'pB', 'pC', 'pD',

Re: Load a list subset with pickle?

2009-10-15 Thread Gabriel Genellina
En Thu, 15 Oct 2009 13:05:18 -0300, Peng Yu pengyu...@gmail.com escribió: How do I determine if I have loaded all the elements? I use the following code. I'm wondering if there is any better solution than this. ### import pickle alist = [1, 2.0, 3, 4+6j]

Re: Load a list subset with pickle?

2009-10-15 Thread Gabriel Genellina
En Thu, 15 Oct 2009 13:05:18 -0300, Peng Yu pengyu...@gmail.com escribió: How do I determine if I have loaded all the elements? I use the following code. I'm wondering if there is any better solution than this. ### import pickle alist = [1, 2.0, 3, 4+6j]

Re: set using alternative hash function?

2009-10-15 Thread Anthony Tolle
On Oct 15, 12:11 pm, Austin Bingham austin.bing...@gmail.com wrote: To put it in code, I want this:   s = set(hash_func = lambda obj: hash(obj.name), eq_func = ...)   ...   x.name = 'foo'   y.name = 'foo'   s.add(x)   s.add(y) # no-op because of uniqueness criteria   assert len(s) == 1 I

Re: where's self.assertMatch (for Django)?

2009-10-15 Thread Phlip
When I google (including codesearch) for assertMatch, I get a mishmash of opinions. Am I missing the One True assertMatch(), or isn't there one and I gotta write it? or copy and use one of the pretenders? Ookay, try this: def assertMatch(self, pattern, slug): r =

Problem

2009-10-15 Thread Ander
I can't send emails out. Can u fix this problem please? The message could not be sent. The authentication setting might not be correct for your outgoing e-mail [SMTP] server. For help solving this problem, go to Help, search for Troubleshoot Windows Mail, and read the I'm having problems sending

Re: Problem

2009-10-15 Thread Xavier Ho
On Fri, Oct 16, 2009 at 3:28 AM, Ander and...@hot.ee wrote: I can't send emails out. Can u fix this problem please? I don't know what I'm missing here, but you evidently sent out an email to the Python mailing list... Cheers, Xav -- http://mail.python.org/mailman/listinfo/python-list

Re: set using alternative hash function?

2009-10-15 Thread Gabriel Genellina
En Thu, 15 Oct 2009 13:24:18 -0300, Rami Chowdhury rami.chowdh...@gmail.com escribió: On Thu, 15 Oct 2009 09:11:00 -0700, Austin Bingham austin.bing...@gmail.com wrote: On Thu, Oct 15, 2009 at 5:15 PM, Gabriel Genellina gagsl-...@yahoo.com.ar wrote: En Thu, 15 Oct 2009 11:42:20 -0300,

Re: set using alternative hash function?

2009-10-15 Thread Ethan Furman
Austin Bingham wrote: Yes, I can construct a dict as you specify, where all of the keys map to values with name attributes equal to the key. My point is that dict doesn't really help me enforce that beyond simply letting me set it up; it doesn't care about the values at all, just the keys. All

Re: Problem

2009-10-15 Thread Tim Chase
I can't send emails out. Can u fix this problem please? The problem is on line 72. Oh wait...you didn't include any code or the traceback. Yeah, that's gonna make it a little difficult to diagnose. But I'm gonna guess that The authentication setting might not be correct for your outgoing

struct curiosity

2009-10-15 Thread pjcoup
Hello, I was fooling around with python's struct lib, looking on how we'd unpack some data. I was a little confused by its behavior: Python 2.5.2 (r252:60911, Jul 22 2009, 15:33:10) [GCC 4.2.4 (Ubuntu 4.2.4-1ubuntu3)] on linux2 Type help, copyright, credits or license for more information.

Python-URL! - weekly Python news and links (Oct 15)

2009-10-15 Thread Gabriel Genellina
QOTW: It is however, much like the framework in question, best kept private and not made public. - Ed Singleton, on a perfectly healthful and acceptable practice ... left unnamed here http://groups.google.com/group/comp.lang.python/msg/987b1a7a4b9 01f3f Looking for a sane way of

Re: set using alternative hash function?

2009-10-15 Thread Anthony Tolle
On Oct 15, 1:49 pm, Ethan Furman et...@stoneleaf.us wrote: I'm still not sure I understand your concern about the values in a set, though.  Sets keep the first object of a given key, dicts keep the last object of a given key; in both cases, all other objects with the same key are lost. So is

Re: Object Relational Mappers are evil (a meditation)

2009-10-15 Thread Mick Krippendorf
Steve Holden wrote: Many such designs make mistakes like using multiple columns (or, even worse, comma-separated values) instead of many-to-many relationships. BTW, the comma-separted-values-in-a-field is officially called the First Anormal Form. There *has to be* some value to it since I've

Moving subwindows in curses does not seem to work

2009-10-15 Thread Mitko Haralanov
Hi all, I am attempting to learn curses programming and in the process have created a small curses ui program. I am currently working on the code which is handling resizing the terminal window. As part of the resizing of the terminal window, I have to resize and move some of the subwindows in my

Re: Module naming convention about StringIO

2009-10-15 Thread Terry Reedy
Peng Yu wrote: It says on http://www.python.org/dev/peps/pep-0008/ Package and Module Names Modules should have short, all-lowercase names. Underscores can be used in the module name if it improves readability. Python packages should also have short, all-lowercase

Re: Object Relational Mappers are evil (a meditation)

2009-10-15 Thread Ethan Furman
Mick Krippendorf wrote: Steve Holden wrote: Many such designs make mistakes like using multiple columns (or, even worse, comma-separated values) instead of many-to-many relationships. BTW, the comma-separted-values-in-a-field is officially called the First Anormal Form. There *has to be*

Re: ?????? () vs []

2009-10-15 Thread Terry Reedy
SmokingDog wrote: Interesting interpretation.. but I just gave it a try. a = (1,2,3,4) a (1, 2, 3, 4) a.index(3) 2 a.index(5) Traceback (most recent call last): File stdin, line 1, in module ValueError: tuple.index(x): x not in tuple So my Python is saying that tuples

Pack optimization

2009-10-15 Thread BDL
I have a large amount of binary data that needs to be pushed across the network. It appears from profiling that the dominant time is being taken up by packing the data. (50%) Here is a CME that shows the problem. from numpy import random from struct import pack import time lenstim = 10084200

Re: Load a list subset with pickle?

2009-10-15 Thread Peng Yu
On Thu, Oct 15, 2009 at 12:01 PM, Gabriel Genellina gagsl-...@yahoo.com.ar wrote: En Thu, 15 Oct 2009 13:05:18 -0300, Peng Yu pengyu...@gmail.com escribió: How do I determine if I have loaded all the elements? I use the following code. I'm wondering if there is any better solution than this.

Re: Object Relational Mappers are evil (a meditation)

2009-10-15 Thread Mick Krippendorf
Ethan Furman schrieb: Mick Krippendorf wrote: BTW, the comma-separted-values-in-a-field is officially called the First Anormal Form. There *has to be* some value to it since I've seen it used quite a few times... Just because you've seen something, doesn't mean it has value; [...] The

Re: Problem with character encoding in commandline

2009-10-15 Thread gialloporpora
Risposta al messaggio di gialloporpora : Dear all, I have a strange problem that I am not able to solve myself. Ok, I have solved my problem, sorry for the post. First I had no view this function: sys.getfilesystemencoding() that return the console encoding, sorry. Sandro

Re: Object Relational Mappers are evil (a meditation)

2009-10-15 Thread Paul Rubin
Ethan Furman et...@stoneleaf.us writes: BTW, the comma-separted-values-in-a-field is officially called the First Anormal Form. There *has to be* some value to it since I've seen it used quite a few times... Mick. Just because you've seen something, doesn't mean it has value; just

Re: Pack optimization

2009-10-15 Thread Paul Rubin
BDL bdlab...@gmail.com writes: Is there a faster method to do this? Is it possible to use array? array.tostring is the first thing I'd think of. -- http://mail.python.org/mailman/listinfo/python-list

Re: efficient running median

2009-10-15 Thread Janto Dreijer
On Oct 15, 12:41 pm, Raymond Hettinger pyt...@rcn.com wrote: [Janto Dreijer] I found a PDF by Soumya D. Mohanty entitled Efficient Algorithm for computing a Running Median (2003) by Googling. It has code snippets at the end, but it's not going to be a simple cut-and-paste job. It will

Re: for loop: range() result has too many items

2009-10-15 Thread David C . Ullrich
On Wed, 14 Oct 2009 01:54:44 -0700 (PDT), Mark Dickinson dicki...@gmail.com wrote: On Oct 13, 10:39 pm, Steven D'Aprano ste...@remove.this.cybersource.com.au wrote: On Tue, 13 Oct 2009 16:17:58 -0500, Peng Yu wrote: Hi, The following code does not run because range() does not accept a big

How to schedule system calls with Python

2009-10-15 Thread Jeremy
I need to write a Python script that will call some command line programs (using os.system). I will have many such calls, but I want to control when the calls are made. I won't know in advance how long each program will run and I don't want to have 10 programs running when I only have one or two

Re: Pack optimization

2009-10-15 Thread Robert Kern
On 2009-10-15 13:57 PM, BDL wrote: I have a large amount of binary data that needs to be pushed across the network. It appears from profiling that the dominant time is being taken up by packing the data. (50%) Here is a CME that shows the problem. from numpy import random from struct import

Re: How to schedule system calls with Python

2009-10-15 Thread TerryP
On Oct 15, 7:42 pm, Jeremy jlcon...@gmail.com wrote: I need to write a Python script that will call some command line programs (using os.system).  I will have many such calls, but I want to control when the calls are made.  I won't know in advance how long each program will run and I don't

Re: id( ) function question

2009-10-15 Thread Erik Max Francis
Mel wrote: My poster-child use of `is` is a MUDD game where `reference1_to_player is reference2_to_player` , if True, means that both refer to the same in-game player. Even that might not last. Well, that usage is fine; I can't see any circumstances under which it might change. `is`

Re: () vs. [] operator

2009-10-15 Thread Carl Banks
On Oct 15, 12:14 am, Ole Streicher ole-usenet-s...@gmx.net wrote: Hi, I am curious when one should implement a __call__() and when a __getitem__() method. For example, I want to display functions and data in the same plot. For a function, the natural interface would to be called as f(x),

Tracking down DLL load errors in Windows ?

2009-10-15 Thread Fred P
Hi, a bit of platform-specific advice sought here... I'm trying to diagnose one of those mysteries Windows is so fond of... Say that I have code that imports some binary Python module from site- packages (in this case, libpyexiv2.pyd through pyexiv2.py, could be anythng else). On three Windows

Re: Tracking down DLL load errors in Windows ?

2009-10-15 Thread Christian Heimes
Fred P wrote: Is there any tool and/or methodology I could use to at least pinpoint the exact DLL that libpyexiv2 is failing to load, and ideally also the reason why ?... The depencency walker http://www.dependencywalker.com/ works fine for me. Christian --

Re: How to schedule system calls with Python

2009-10-15 Thread Jeremy
On Oct 15, 2:15 pm, TerryP bigboss1...@gmail.com wrote: On Oct 15, 7:42 pm, Jeremy jlcon...@gmail.com wrote: I need to write a Python script that will call some command line programs (using os.system).  I will have many such calls, but I want to control when the calls are made.  I won't

Re: Are there any modules for IRC, that work with Python 3.1?

2009-10-15 Thread Chris Jones
On Sat, Oct 10, 2009 at 01:39:48AM EDT, TerryP wrote: [..] Having recently been put into search for a new IRC client, and everything I've thrown in the cauldron having become a disappointment... OT as always, but I'm surprised you found weechat-curses disappointing. CJ --

Re: Object Relational Mappers are evil (a meditation)

2009-10-15 Thread Ethan Furman
Mick Krippendorf wrote: Ethan Furman schrieb: Mick Krippendorf wrote: BTW, the comma-separted-values-in-a-field is officially called the First Anormal Form. There *has to be* some value to it since I've seen it used quite a few times... Just because you've seen something, doesn't mean it

Re: Object Relational Mappers are evil (a meditation)

2009-10-15 Thread Paul Rubin
Ethan Furman et...@stoneleaf.us writes: If I knew what First Anormal Form was I (hope!) It appears to be a made-up term. -- http://mail.python.org/mailman/listinfo/python-list

Re: Object Relational Mappers are evil (a meditation)

2009-10-15 Thread Mick Krippendorf
Ethan Furman schrieb: If I knew what First Anormal Form was [...] This refers to the Normal Forms one goes through when normalizing relational databases. (http://en.wikipedia.org/wiki/Database_normalization#Normal_forms) The First Anormal Form (FAN) means just lumpin' data together in a comma

  1   2   3   >