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

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 import

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 se

Re: () vs. [] operator

2009-10-15 Thread Xavier Ho
On Thu, Oct 15, 2009 at 5:14 PM, 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? Hi, This is very interesting, a thought that never occured to me before. Usually, a function is a

Re: () vs. [] operator

2009-10-15 Thread Chris Rebert
On Thu, Oct 15, 2009 at 12:14 AM, Ole Streicher 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)",

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: for dirpath, dirnames, filenames in

Re: The rap against "while True:" loops

2009-10-15 Thread Tim Rowe
2009/10/11 Philip Semanchuk : > 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 -- http://mail.python.

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? -- h

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 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 append or extend

Re: the usage of 'yield' keyword

2009-10-15 Thread Paul Rudin
Peng Yu 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 example? Thank you! >

Re: Error received from _mechanize.py

2009-10-15 Thread Chris Rebert
On Thu, Oct 15, 2009 at 12:39 AM, Raji Seetharaman 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 install pyt

Re: () vs []

2009-10-15 Thread Xavier Ho
On Thu, Oct 15, 2009 at 3:21 AM, Nanjundi wrote: > 3 You can’t find elements in a tuple. Tuples have no index method. > I don't know what language you're using there, but my Python tuples have indexes. >>> a = (1, 2, 3) >>> a (1, 2, 3) >>> a[1] 2 -- http://mail.python.org/mailman/listinf

Re: () vs. [] operator

2009-10-15 Thread Ulrich Eckhardt
Ole Streicher wrote: > 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. Wait: The term 'function' is overloaded. In Python and programming in general, a function is a piece of code wi

Re: () vs []

2009-10-15 Thread Chris Rebert
On Thu, Oct 15, 2009 at 1:27 AM, Xavier Ho wrote: > On Thu, Oct 15, 2009 at 3:21 AM, Nanjundi wrote: >> 3       You can’t find elements in a tuple. Tuples have no index method. > > I don't know what language you're using there, but my Python tuples have > indexes. > a = (1, 2, 3) a > (1

Re: () vs []

2009-10-15 Thread Xavier Ho
On Thu, Oct 15, 2009 at 6:39 PM, Chris Rebert wrote: > Nanjundi meant "index method" as in "a method .index()" (i.e. a method > named "index") which searches through the container for the given item > and returns the index of the first instance of said item, like > list.index() does. > > Interest

Re: Colour sampling

2009-10-15 Thread Anthra Norell
Dylan Palmboom wrote: 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 sca

Re: () vs []

2009-10-15 Thread Chris Rebert
On Thu, Oct 15, 2009 at 1:46 AM, Xavier Ho wrote: > > On Thu, Oct 15, 2009 at 6:39 PM, Chris Rebert wrote: >> >> Nanjundi meant "index method" as in "a method .index()" (i.e. a method >> named "index") which searches through the container for the given item >> and returns the index of the first i

HTMLgen???

2009-10-15 Thread andre
Hi, Does HTMLgen (Robin Friedrich's) still exsist?? And, if so, where can it be found? -- Andre van der Vlies Certifiable Linux/UNIX engineer (CLUE) Homepage: http://vandervlies.xs4all.nl/~andre Books: http://www.lulu.com/andre14 Key fi

Re: () vs []

2009-10-15 Thread Tim Golden
Xavier Ho wrote: On Thu, Oct 15, 2009 at 6:39 PM, Chris Rebert wrote: Nanjundi meant "index method" as in "a method .index()" (i.e. a method named "index") which searches through the container for the given item and returns the index of the first instance of said item, like list.index() does.

回复: () vs []

2009-10-15 Thread SmokingDog
the value 5 not in tuple reference help list.index(x) Return the index in the list of the first item whose value is x. It is an error if there is no such item. -- Eric Lee -- 原始邮件 -- 发件人: "Chris Rebert"; 发送时间: 2009年10月15日(星期四) 下午4:48 收

segmentation fault

2009-10-15 Thread ankita dutta
hi, i am relatively new to python programming, i am facing the following problem: i am tring to simply obtain data from a file ( "B.txt" , data in this file are in single column and floats) and plot a graph between those values and thier index. ( for example if in file , if at 2nd position valu

Re: () vs []

2009-10-15 Thread Xavier Ho
On Thu, Oct 15, 2009 at 6:55 PM, Tim Golden wrote: > It was added relatively recently, around Python 2.6 I think, > at least partly as an oh-ok-then reaction to everyone asking: > "how come lists have .index and .count and tuples don't?" > and neverending "tuples-are-immutable-lists-no-they-aren'

Re: HTMLgen???

2009-10-15 Thread eric_dex...@msn.com
On Oct 15, 2:58 am, an...@vandervlies.xs4all.nl wrote: > Hi, > Does HTMLgen (Robin Friedrich's) still exsist?? And, if so, where can it > be found? > > -- >                Andre van der Vlies >                Certifiable Linux/UNIX engineer (CLUE) >                Homepage:http://vandervlies.xs4al

Re: segmentation fault

2009-10-15 Thread David Cournapeau
On Thu, Oct 15, 2009 at 6:14 PM, ankita dutta wrote: >   is dumped > segmentation fault > > It looks like you are using matplotlib, and matplotlib is the one likely to segfault. You could check that it is indeed the case by just commenting the part which does the plot - but I would be very surpr

Re: segmentation fault

2009-10-15 Thread Chris Rebert
On Thu, Oct 15, 2009 at 2:14 AM, ankita dutta wrote: > hi, > i am relatively new to python programming, > i am facing the following problem: > > i am tring to simply  obtain data from a file ( "B.txt" ,  data in this file > are in single column and floats) > and plot a graph between those values a

Re: What command should be use when the testing of arguments is failed?

2009-10-15 Thread Jean-Michel Pichavant
Peng Yu wrote: I have the following python code snippet. I'm wondering what command I should use to terminate the program if the arguments are not right. #!/usr/bin/env python import sys import os if len(sys.argv) <= 1: print "usage:", os.path.basename(sys.argv[0]), '' return ## what comma

Re: segmentation fault

2009-10-15 Thread Krishnakant
On Thu, 2009-10-15 at 14:44 +0530, ankita dutta wrote: > hi, > i am relatively new to python programming, > i am facing the following problem: > > i am tring to simply obtain data from a file ( "B.txt" , data in > this file are in single column and floats) > and plot a graph between those value

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 http://code.

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 wrote: > On Thu, Oct 15, 2009 at 2:14 AM, ankita dutta > wrote: > > hi, > > i am relat

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 th

Re: set using alternative hash function?

2009-10-15 Thread Chris Rebert
On Thu, Oct 15, 2009 at 4:24 AM, 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

Re: segmentation fault

2009-10-15 Thread David Cournapeau
On Thu, Oct 15, 2009 at 7:46 PM, ankita dutta 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 is how matplotli

Re: set using alternative hash function?

2009-10-15 Thread Duncan Booth
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 > objec

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

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 calcu

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

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 wa

Re: segmentation fault

2009-10-15 Thread David Cournapeau
On Thu, Oct 15, 2009 at 9:08 PM, ankita dutta 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) of this column is 1

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

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 m

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 >

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

set using alternative hash function?

2009-10-15 Thread Austin Bingham
On Thu, Oct 15, 2009 at 2:23 PM, Diez B. Roggisch 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 else. But I'm no

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

Re: set using alternative hash function?

2009-10-15 Thread Austin Bingham
On Thu, Oct 15, 2009 at 3:02 PM, Diez B. Roggisch 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 enough == public shami

Re: Clear interface for mail class

2009-10-15 Thread Benedict Verheyen
Francesco Bochicchio wrote: > > 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

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 "conte

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 kin

Re: set using alternative hash function?

2009-10-15 Thread Austin Bingham
On Thu, Oct 15, 2009 at 3:43 PM, Diez B. Roggisch 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 > are used in, and t

Re: set using alternative hash function?

2009-10-15 Thread Anthony Tolle
On Oct 15, 7:24 am, Austin Bingham 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 easily iterate over the o

Re: set using alternative hash function?

2009-10-15 Thread Austin Bingham
On Thu, Oct 15, 2009 at 3:50 PM, Mick Krippendorf 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 of objects,

Re: set using alternative hash function?

2009-10-15 Thread Austin Bingham
On Thu, Oct 15, 2009 at 4:06 PM, Anthony Tolle 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. Whereas a set with uniq

Re: HTMLgen???

2009-10-15 Thread Gabriel Genellina
En Thu, 15 Oct 2009 05:58:02 -0300, 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 templating engine instead o

Re: set using alternative hash function?

2009-10-15 Thread Anthony Tolle
On Oct 15, 10:42 am, Austin Bingham 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 things straight; it does

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 a

Re: set using alternative hash function?

2009-10-15 Thread Chris Rebert
On Thu, Oct 15, 2009 at 5:22 AM, Diez B. Roggisch wrote: > Chris Rebert wrote: > >> On Thu, Oct 15, 2009 at 4:24 AM, 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 h

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 c

Re: HTMLgen???

2009-10-15 Thread tinnews
Gabriel Genellina wrote: > En Thu, 15 Oct 2009 05:58:02 -0300, 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 pref

Re: set using alternative hash function?

2009-10-15 Thread Gabriel Genellina
En Thu, 15 Oct 2009 11:42:20 -0300, Austin Bingham escribió: On Thu, Oct 15, 2009 at 4:06 PM, Anthony Tolle 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

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

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 t

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 reproduce

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 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 pickling th

Re: set using alternative hash function?

2009-10-15 Thread Austin Bingham
On Thu, Oct 15, 2009 at 5:15 PM, Gabriel Genellina wrote: > En Thu, 15 Oct 2009 11:42:20 -0300, Austin Bingham > escribió: > I think you didn't understand correctly Anthony Tolle's suggestion: > > py> class Foo: > ...   def __init__(self, name): self.name = name > ... > py> objs = [Foo('Joe'), Fo

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 usi

Re: set using alternative hash function?

2009-10-15 Thread Rami Chowdhury
On Thu, 15 Oct 2009 09:11:00 -0700, Austin Bingham wrote: On Thu, Oct 15, 2009 at 5:15 PM, Gabriel Genellina wrote: En Thu, 15 Oct 2009 11:42:20 -0300, Austin Bingham escribió: I think you didn't understand correctly Anthony Tolle's suggestion: py> class Foo: ...   def __init__(self, name

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

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 use

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" wrote: > En Wed, 14 Oct 2009 22:08:09 -0300,prasanna   > escribió: > > > Out of curiosity--one more thing I haven't yet figured out, is there a > > xmlrpc command I can send that stops or restarts the server? > > If

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 Kern 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? Tha

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 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', respectively. And there

Re: Load a list subset with pickle?

2009-10-15 Thread Gabriel Genellina
En Thu, 15 Oct 2009 13:05:18 -0300, Peng Yu 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] output=open('serialize_list.output/serialize

Re: Load a list subset with pickle?

2009-10-15 Thread Gabriel Genellina
En Thu, 15 Oct 2009 13:05:18 -0300, Peng Yu 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] output=open('serialize_list.output/serialize

Re: set using alternative hash function?

2009-10-15 Thread Anthony Tolle
On Oct 15, 12:11 pm, Austin Bingham 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 wrote a quick s

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 = re.compile(patt

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 sendi

Re: Problem

2009-10-15 Thread Xavier Ho
On Fri, Oct 16, 2009 at 3:28 AM, Ander 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 escribió: On Thu, 15 Oct 2009 09:11:00 -0700, Austin Bingham wrote: On Thu, Oct 15, 2009 at 5:15 PM, Gabriel Genellina wrote: En Thu, 15 Oct 2009 11:42:20 -0300, Austin Bingham escribió: I think you didn't understand correctly Anthony

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 th

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 e-m

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 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 that the beh

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'v

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 u

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

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* som

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 "", line 1, in > ValueError: tuple.index(x): x not in tuple > > So my Python is say

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 s

Re: Load a list subset with pickle?

2009-10-15 Thread Peng Yu
On Thu, Oct 15, 2009 at 12:01 PM, Gabriel Genellina wrote: > En Thu, 15 Oct 2009 13:05:18 -0300, Peng Yu 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

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; [...]

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

  1   2   >