Re: Ordered Sets

2009-03-29 Thread CTO
On Mar 28, 3:33 am, "Gabriel Genellina" wrote: > En Thu, 26 Mar 2009 12:20:17 -0300, Scott David Daniels   > escribió: > > > (2) Why, oh why, do people feel so comforted adding double_underscores > >      to data structures? Probably because other authors feel too comfortable using single unders

Re: Thoughts on language-level configuration support?

2009-03-31 Thread CTO
On the one hand, I can 110% see why you want to reduce boilerplate code and provide a discoverable, common mechanism for automating the two and three-quarters parsers that a lot of applications have to write to handle a config file, CLI, and/or registry values, but why introduce a syntax for it? A

Re: Creating huge data in very less time.

2009-03-31 Thread CTO
1) How random is random enough? Some PRNGs are very fast, and some are very random, but theres always a compromise. 2) How closely related can the files be? It would be easy to generate 1GB of pseudorandom numbers, then just append UUIDs to them 3) Unique filenames can be generated with tmpnam --

Re: Thoughts on language-level configuration support?

2009-04-01 Thread CTO
> I just mean that there should be a > clear and easy way to do it, that it should be considered a basic > service, and that if the best way to satisfy all the goals is to > integrate it directly into the language, that shouldn't be shied away > from. Honestly, the programming language and the con

Re: how to get back an object from its id() value

2009-04-08 Thread CTO
> But how do I get a usable reference from the id value? > For example, if "foo" has a method "bar()", how can I call "foo.bar()" > from "str(id(foo))" (say, 149466208). can you just use a weakref instead? It is certainly cleaner than trying to store id's, since an id is only guaranteed to be uniq

Re: how to get back an object from its id() value

2009-04-08 Thread CTO
> You could create a dict with the string as the key and the object as the > value. This will create a strong reference to the object, which is (I'm assuming) undesired behavior. -- http://mail.python.org/mailman/listinfo/python-list

Re: how to get back an object from its id() value

2009-04-08 Thread CTO
> I don't know what is the best: > * using an additional dict and maintaining it It works, but as you say, is somewhat inelegant. > * or using the "di" module proposed by CTO Let me be clear: I am not proposing that you use it. It *does* do what you ask- but what y

Re: how to get back an object from its id() value

2009-04-08 Thread CTO
Correction: the UserString will be dead on the final line. When I typed it in I had a strong reference still hanging around. -- http://mail.python.org/mailman/listinfo/python-list

Re: safe eval of moderately simple math expressions

2009-04-09 Thread CTO
how about sympy? http://code.google.com/p/sympy/ -- http://mail.python.org/mailman/listinfo/python-list

Re: Recommendations on Pythonic tree data structure design techniques

2009-04-09 Thread CTO
I'm writing a Python graph library (called Graphine) that's pretty easy to use and does what you want. It is pre-alpha right now, but if you're interested please let me know- I'm very interested in hearing outside opinions. -- http://mail.python.org/mailman/listinfo/python-list

Re: ctypes

2009-04-30 Thread CTO
At the risk of self-promotion, you may want to try this recipe . Then just do the following: >>> @C_function("/home/luca/Desktop/luca/progetti_eric/Pico/libusbtc08-1.7.2/src/.libs/libusbtc08.so") ... def usb_tc08_get_single(handle: "c_short", temp: "*c_float", overflow_flags: "*c_short", units: "

Re: where to start with

2009-05-01 Thread CTO
I'd add http://diveintopython.org/ to that list as you gain more experience with Python, or if you already know at least one language. -- http://mail.python.org/mailman/listinfo/python-list

Re: Passing a function as an argument from within the same class?

2009-05-01 Thread CTO
Make doNothing a classmethod. class SomeClass: @classmethod def doNothing(cls): pass def function1(self): print "Running function 1" def function2(self, passedFunction=SomeClass.doNothing): print "Running passed function" passedFunction() someObj

Re: How to measure the memory cost in Python?

2009-05-01 Thread CTO
Not OP, but I'd actually like to know if there's an answer to this one that doesn't involve platform-specific tools. -- http://mail.python.org/mailman/listinfo/python-list

Re: Passing a function as an argument from within the same class?

2009-05-01 Thread CTO
> Careful, bearophiles' answer remains the best one. > > The only reason your example worked is that you had already had > SomeClass defined (probably from a previous experiment). Scott is correct, and if bearophile and I ever give you conflicting advice, take bearophile's. A (corrected) bit of c

Re: How to measure the memory cost in Python?

2009-05-01 Thread CTO
> sys.getsizeof() [a suggested solution] isn't platform-specific. So, to answer the OP's question, you'd just do something like def get_totalsize(obj): total_size = sys.getsizeof(obj) for value in vars(obj).values(): try: total_size += get_total_size(value)

Re: ctypes: reference of a struct member?

2009-05-01 Thread CTO
ctypes.byref() -- http://mail.python.org/mailman/listinfo/python-list

Re: How to measure the memory cost in Python?

2009-05-02 Thread CTO
> > PS) The asizeof(obj) function from this recipe > code.activestate.com/recipes/546530> does size the object plus its > > references, recursively. > > Correction, the last sentence should be: The asizeof(obj) ... plus its > referents, recursively. I will admit, I have *no idea* what that code i

Re: yet another list comprehension question

2009-05-02 Thread CTO
On May 2, 10:13 pm, Ross wrote: > I'm trying to set up a simple filter using a list comprehension. If I > have a list of tuples, a = [(1,2), (3,4), (5,None), (6,7), (8, None)] > and I wanted to filter out all tuples containing None, I would like to > get the new list b = [(1,2), (3,4),(6,7)]. try

Re: Can someone please explain to me this code?

2009-05-02 Thread CTO
On Sat, May 2, 2009 at 9:41 PM, Soumen banerjee wrote: Hello, I was trying to find a method to make global hotkeys with python in linux. I found this one which uses a library called python-xlib. The point is that since i dont have much experience with this, i cant understand s

Re: eric not working on ubuntu 9.04

2009-05-03 Thread CTO
>   File "/usr/lib/python2.6/email/message.py", line 790, in Message >     from email.Iterators import walk Well, the module is called email.iterators (rather than email.Iterators), for starters. It looks like __all__ exports both names (which seems a little dodgy to me, but hey, y'all are the exp

Re: How to measure the memory cost in Python?

2009-05-03 Thread CTO
Alright, it's pretty obvious that I have a lot to learn before I'll be able to intelligently address this problem, but if somebody could point me at something that would help me figure out the terminology at least I'd really appreciate it. From what you're saying, it sounds like a combination of th

Re: Is it better to use threads or fork in the following case

2009-05-03 Thread CTO
Probably better just to check HEAD and see if its updated within the time you're looking at before any unpack. Even on a 56k that's going to be pretty fast, and you don't risk unpacking an old file while a new version is on the way. If you still want to be able to unpack the old file if there's an

Re: Is it better to use threads or fork in the following case

2009-05-03 Thread CTO
> In addition, the zip file format stores the directory at the end of the   > file. So you can't process it until it's completely downloaded.   > Concurrency doesn't help here. Don't think that's relevant, if I'm understanding the OP correctly. Lets say you've downloaded the file once and you're d

Re: Is it better to use threads or fork in the following case

2009-05-04 Thread CTO
> Which brings us backs to the "20 questions"-part of my earlier post. It > could be, but it could also be that processing takes seconds. Or it takes > so long that even concurrency won't help. Who knows? Probably the OP ;) Geremy Condra -- http://mail.python.org/mailman/listinfo/python-list

Re: Database help needed

2009-05-04 Thread CTO
On May 4, 7:51 pm, Emile van Sebille wrote: > On 5/4/2009 4:30 PM Amber said... > > > > > > > My PHB is insane. > > > Today he drops 50,000 databases in MS Access format on my desk, and > > tells me that by Friday I need to: > > * Remove all of the "junk content" in the record fields; > > * Remove

Re: local module-docs server on Linux?

2009-05-04 Thread CTO
On May 4, 10:30 pm, Soumen banerjee wrote: > Hello, > I had used python on windows and one of the features i liked best was > that you could start a module-docs server and then use firefox to > access it. pydoc -p -- http://mail.python.org/mailman/listinfo/python-list

Re: Any idea to emulate tail -f

2009-05-04 Thread CTO
On May 5, 2:00 am, Joel Juvenal Rivera Rivera wrote: > I want to make something very similar to  the command tail -f (follow a > file), i have been trying  with some while True and some microsleeps > (about .1 s); did someone has already done something like this? > > And about the file is the apac

Re: Self function

2009-05-05 Thread CTO
On May 5, 2:08 am, Steven D'Aprano wrote: > On Mon, 04 May 2009 17:54:50 -0400, Terry Reedy wrote: > > bearophileh...@lycos.com wrote: > > >> Another possible syntax: > > >> def fact(n): > >>     return 1 if n <= 1 else n * return(n - 1) > > >> But I guess most people don't see this problem as imp

Re: Can someone please explain to me this code?

2009-05-05 Thread CTO
> root.change_attributes(event_mask = X.KeyPressMask) This asks X to send this application keypress events > root.grab_key(keycode, X.AnyModifier, 1,X.GrabModeAsync, X.GrabModeAsync) This tells X to grab the keyboard if the given keycode is generated and any modifier is pressed, not to stop proc

Re: help for documentation and license

2009-05-05 Thread CTO
On May 5, 2:30 pm, Gökhan SEVER wrote: > Hi, > > Even though I don't know what your project does, you will need to use > "Sphinx" to create semi-automatic documentation out of your project. > > I would recommend you to take a look a quality "free" Python module: > Matplotlib (http://matplotlib.sou

Re: [RELEASED] Python 3.1 beta 1

2009-05-07 Thread CTO
On May 7, 9:12 am, Scott David Daniels wrote: > Daniel Fetchinson wrote: > >> Other features include an ordered dictionary implementation > > > Are there plans for backporting this to python 2.x just as > > multiprocessing has been? > > Why not grab the 3.1 code and do it yourself for your 2.X's?

Re: ECG segmentation

2009-05-08 Thread CTO
On May 8, 2:04 pm, Filip Gruszczyński wrote: > Hi! > > I need to create a script, that performs ECG segmentation, but I can > hardly find any useful materials on the web. Did anyone try to do this > and could point me to some good materials/snippets about this? > > -- > Filip Gruszczyński How are

Re: Representing a Tree in Python

2009-05-12 Thread CTO
On May 13, 12:10 am, godshorse wrote: > Hello, > > I want to find out the shortest path tree from a root to several nodes > in a graph data structure. I found a Dijkstra code from internet that > finds shortest path between only two nodes. How can i extend it to a > tree?. And what is the best way

Re: Representing a Tree in Python

2009-05-13 Thread CTO
> But let me clear the my problem again. I have a graph. and I want to > find 'shortest path tree' from a root node to several nodes. as a > example if we have a graph of 5 nodes from 1 to 5, I need to build the > shortest path tree from node 1 to nodes 2,3,5. So my question is > instead of keeping

Re: Representing a Tree in Python

2009-05-13 Thread CTO
On May 13, 8:19 am, bearophileh...@lycos.com wrote: > godshorse, you may use the "shortestPaths" method of this graph class > of mine:http://sourceforge.net/projects/pynetwork/ > > (It uses the same Dijkstra code by Eppstein). > (Once you have all distances from a node to the other ones, it's not >

Re: How to see the code definiton in the shell ?

2009-05-13 Thread CTO
On May 13, 1:26 pm, "J. Cliff Dyer" wrote: > On Wed, 2009-05-13 at 09:40 -0700, Mohan Parthasarathy wrote: > > Hi, > > > I am new to Python. I tried searching this but could not find an > > answer. In the interactive shell, I write a new function and I want to > > be able to see all the code that

Re: Python system with exemplary organization/coding style

2009-05-14 Thread CTO
On May 14, 7:01 pm, TomF wrote: > I'm looking for a medium-sized Python system with very good coding > style and good code organization, so I can learn from it.  I'm reading > various books on Python with advice on such things but I'd prefer to > see a real system. > > By medium-sized I mean 5-20

Re: Performance java vs. python

2009-05-19 Thread CTO
> Ah! I should have been careful before asking such "general" question about > performance. I agree with you. But mine was more academic. I should not given > a specific example. > > AFAIK, for java on the client side, JVM performance is one of the critical > things which has been tuned to death

Re: any lib to extract pages form pdf and then merge?

2009-05-25 Thread CTO
On May 26, 12:47 am, oyster wrote: > I want to extract some pages from vary pdf files, then write them > with/witout rotation into one new pdf file. something likes this > [py] > import gfx > doc = gfx.open("pdf", r"Theory.pdf") > pdf = gfx.PDF() > for pagenr in [1,5,7]: >     page = doc.getPage(p

Re: What text editor is everyone using for Python

2009-05-26 Thread CTO
On May 26, 3:23 am, Lawrence D'Oliveiro wrote: > In message , Steven > > D'Aprano wrote: > > On Tue, 26 May 2009 18:31:56 +1200, Lawrence D'Oliveiro wrote: > > >> In message >> b201-4b2445732...@v35g2000pro.googlegroups.com>, LittleGrasshopper > >> wrote: > > >>> ... I am looking for suitable syn

Re: Network programming ?

2009-05-26 Thread CTO
On May 25, 11:05 pm, thushiantha...@gmail.com wrote: > Hi everyone, > > I am planning to develop a chatting software in Python, for my college > project. I am using Windows Vista. Is it possible to do sockets > programming in Python ? Any books or websites ?  Also, i want to > develop a gui for tha

Re: Passing string from python programs to external programs

2009-05-26 Thread CTO
On May 26, 2:12 pm, lone_eagle wrote: > Hi all, > > On Linux, I do something like this > > $ program_to_execute < input_file > ... get some output ... > > I have the content of the input_file as a string inside a python > program and would like to pass this string to the external program > from in

Re: Adding a Par construct to Python?

2009-05-28 Thread CTO
On May 28, 1:53 pm, Aaron Brady wrote: > On May 27, 11:07 pm, Steven D'Aprano > cybersource.com.au> wrote: > > On Wed, 27 May 2009 12:58:02 +, Albert van der Horst wrote: > > > >>And how is reduce() supposed to know whether or not some arbitrary > > >>function is commutative? > > > > Why woul

Re: Browser based Canvas UI?

2009-05-30 Thread CTO
On May 30, 4:12 am, Ken Seehart wrote: > A couple years ago I stumbled upon an interesting technology but I can't > seem to find it, and I can remember what it is called.  Unfortunately > this makes it difficult to search for.  I am am aware of several partial > matches (items that meet a subset o

Re: Q: finding distance between 2 time's

2009-05-31 Thread CTO
On May 30, 8:49 pm, John Machin wrote: >   > import time >   You are in a maze of twisty little functions, all alike. Quote of the week. Perhaps the year. I hope you don't mind me using it in the future. Geremy Condra -- http://mail.python.org/mailman/listinfo/python-list

Re: Detecting changes to a dict

2009-09-27 Thread CTO
On Sep 27, 5:36 am, Steven D'Aprano wrote: > I'm pretty sure the answer to this is No, but I thought I'd ask just in > case... > > Is there a fast way to see that a dict has been modified? I don't care > what the modifications are, I just want to know if it has been changed, > where "changed" mean

Re: Detecting changes to a dict

2009-09-27 Thread CTO
On Sep 28, 1:11 am, Steven D'Aprano wrote: > On Sun, 27 Sep 2009 21:42:10 -0700, CTO wrote: > >> Is there a fast way to see that a dict has been modified? > > ... > > > d = {"a": "b", "c": "d"} > > d2 = d.copy() &g

Re: graph edge generators

2009-06-09 Thread CTO
On Jun 9, 11:58 pm, William Clifford wrote: > I've become interested in basic graphs and networks and I'm wondering > about what algorithms are there for generating basic regular graphs > like the simplex graph or dodecahedron graph, etc (I'm sure there are > many). I'm particularly keen on unders

Re: No trees in the stdlib?

2009-06-26 Thread CTO
On Jun 26, 1:29 am, Tom Reed wrote: > Whynotrees in the standard library, if not as a built in? I searched > the archive but couldn't find a relevant discussion. Seems like a > glaring omission considering the batteries included philosophy, > particularly balanced binary search trees.Nointerest,no

Re: Finite state machine in python

2009-09-12 Thread CTO
On Sep 12, 4:39 pm, Peng Yu wrote: > Hi, > > I have see some discussion on the implementation of finite state > machine in python. Can somebody point to me the best way in implenting > an FSM in python? > > http://code.activestate.com/recipes/146262/ > > Regards, > Peng I wrote an example of how