Re: Advanced concurrancy

2005-07-28 Thread Calvin Spealman
Twisted [1] includes lots of support for asyncronous concurrency, using deferreds. There is also the possiblity of PEP 342's [2] concurrency through enhanced generators, and being able to pass data to the generator every iteration. There are ways to simulate this, as well. I've written a recipe

Re: Wheel-reinvention with Python (was: Ten Essential Development Practices)

2005-07-29 Thread Calvin Spealman
The choice is GUI toolkits is largely seperate from Python. Consider that they are just bindings to libraries that are developed completely seperate of the language. GUI is should be seperate from the language, and thus not bound to same expectations and desires as elements of the language itself.

Re: Ten Essential Development Practices

2005-07-29 Thread Calvin Spealman
On 7/29/05, Dark Cowherd [EMAIL PROTECTED] wrote: I am new to Python. I tried it out and think it is fantastic. Congrats and have fun learning all there is to learn. I really loved this from import this statements: There should be one-- and preferably only one --obvious way to do it. But

Re: How can I run a program?

2005-07-30 Thread Calvin Spealman
did you try to put the filename in quotes? On 30 Jul 2005 03:33:14 -0700, Lad [EMAIL PROTECTED] wrote: Hello, I am running Python on XP and have a problem with a program if its name consists '-' for example: my-program.py When I try to run a program with such name I get the error :

Re: Advanced concurrancy

2005-08-01 Thread Calvin Spealman
On 28 Jul 2005 10:41:54 -0700, [EMAIL PROTECTED] [EMAIL PROTECTED] wrote: Asynchrony is not concurrency. If you have to turn your code inside out, (that is, if you have to write your code such that the library calls your code, rather than vice versa) it's very much *not* concurrency: it's

Re: Operator Overloading

2005-08-01 Thread Calvin Spealman
On 1 Aug 2005 05:12:47 -, Gurpreet Sachdeva [EMAIL PROTECTED] wrote: Hi, Is there any provision in python which allows me to make my own operators? My problem is that I need to combine two dictonaries with their keys and I don't want to use any of the existing operators like

Re: how to write a line in a text file

2005-08-10 Thread Calvin Spealman
On 7/31/05, James Dennett [EMAIL PROTECTED] wrote: Peter Hansen wrote: Steven D'Aprano wrote: Given that ZODB and PySQLite are simply Python extension modules, which get bundled by your builder tool and are therefore installed transparently along with your app by your installer, this

Re: Does any one recognize this binary data storage format

2005-08-10 Thread Calvin Spealman
On 8/10/05, Grant Edwards [EMAIL PROTECTED] wrote: On 2005-08-10, John Machin [EMAIL PROTECTED] wrote: Perhaps the one bit is an exponent -- some kind of floating point based format? That matches the doubling of all digits. That would just be sick. I can't imagine anybody on an 8-bit

PyUnit and multiple test scripts

2005-02-26 Thread Calvin Spealman
I'm trying to find the best way to use PyUnit and organize my test scripts. What I really want is to separate all my tests into 'test' directories within each module of my project. I want all the files there to define a 'suite' callable and to then all all those suites from all those test

Re: Scoping issue with import

2005-02-28 Thread Calvin Spealman
Each module is only 'aware' of the built-ins and the modules it itself imports. So, all you need to do is add this line to my_imported_mod: from my_main_mod import myfun This is a fully intentional feature. Modules stand on their own. James Stroud wrote: Say I have a module, we'll call it

Importing from filesystem path a 'frozen sub-module' error

2005-02-28 Thread Calvin Spealman
I've been working on a small test runner script, to accumulate my test scripts (all python files in the 'test' sub-directories of my source tree). Things were going well, but I'm still having trouble loading the modules, once I have a path to the python source file. This is the error I am getting:

Re: list of all type names

2005-03-01 Thread Calvin Spealman
Of course, remember that there are benefits to this, as well. Redefining the built-ins can be useful in some interesting cases. Klaus Neuner wrote: Hello, Python has one feature that I really hate: There are certain special names like 'file' and 'dict' with a predefined meaning. Yet, it is

Re: What do you call a class not intended to be instantiated

2008-09-21 Thread Calvin Spealman
I call it an obvious misuse and misunderstanding of why you'd use a class in the first place. Either create an instance and not make these things classmethods or just share the stuff in a module-level set of variables. But the instantiating is the best options. Your class attributes might not be

Re: cPickle asymptotic performance?

2008-06-12 Thread Calvin Spealman
If you are getting to the point where your data is large enough to really care about the speed of cPickle, then maybe its time you moved past pickles for your storage format? 2.5 includes sqlite, so you could persist them in a nice, indexed table or something. Just a suggestion. On Jun

Re: namedtuple suggestions

2008-06-13 Thread Calvin Spealman
On Jun 13, 2008, at 11:17 AM, Jason R. Coombs wrote: I see a new function in (python 2.6) lib/collections called namedtuple. This is a great function. I can see many places in my code where this will be immensely useful. I have a couple of suggestions. My first suggestion is to use

Re: Iterate creating variables?

2008-06-13 Thread Calvin Spealman
On Jun 13, 2008, at 11:56 AM, [EMAIL PROTECTED] wrote: On Jun 13, 11:48 am, Diez B. Roggisch [EMAIL PROTECTED] wrote: [EMAIL PROTECTED] schrieb: On Jun 13, 11:21 am, Diez B. Roggisch [EMAIL PROTECTED] wrote: [EMAIL PROTECTED] schrieb: I have twenty-five checkboxes I need to create

Re: Hard to understand 'eval'

2008-06-15 Thread Calvin Spealman
The point here is that eval() use is general frowned upon. If you don't understand it or the alternatives, then you probably don't understand it well enough to make the call on using it or not. If you need just look up an attribute where the name of the attribute is in a variable, use

Re: Iterate creating variables?

2008-06-15 Thread Calvin Spealman
That smells bad the same was the eval() usage in the thread Hard to understand 'eval'. This is only one pythoners opinion, of course. On Jun 13, 2008, at 3:29 PM, Jason Scheirer wrote: for x in xrange(1, 26): setattr(self, 'checkbox_%i' % x, ...) --

Re: newbie: for loop within for loop question

2008-06-15 Thread Calvin Spealman
The sets module is no longer needed, as we have the built-in sets type. Its even getting a literal syntax soon. As for the original problem, I agree on the homework smell. On Jun 15, 2008, at 9:31 PM, takayuki wrote: Dennis, thanks for your reply. unfortunately i accidentally posted only

Re: PEP 372 -- Adding an ordered directory to collections

2008-06-16 Thread Calvin Spealman
This gets my +1, for what its worth. I don't really see a good reason not to include the insert() method, however. I don't see that it would complicate things much, if at all. d = odict([('a', 42), ('b', 23)]) d.insert(1, ('c', 19)) d collections.odict([('a', 42), ('c', 19), ('b', 23)])

Re: 'string'.strip(chars)-like function that removes from the middle?

2008-06-16 Thread Calvin Spealman
On Jun 16, 2008, at 12:58 PM, Ethan Furman wrote: Greetings. The strip() method of strings works from both ends towards the middle. Is there a simple, built-in way to remove several characters from a string no matter their location? (besides .replace() ;) For example: .strip --

Re: Static memory allocation in Python

2008-06-17 Thread Calvin Spealman
On Jun 17, 2008, at 2:34 PM, Eduardo Henrique Tessarioli wrote: Hi, I am running a very simple python application and I noted that the memory allocation is something like 4,5M. This is a problem in my case, because I have to run 2 thousand process at the same time. The memory I need is

Re: Looking for lots of words in lots of files

2008-06-18 Thread Calvin Spealman
Upload, wait, and google them. Seriously tho, aside from using a real indexer, I would build a set of the words I'm looking for, and then loop over each file, looping over the words and doing quick checks for containment in the set. If so, add to a dict of file names to list of words found

Charlotte Python Group

2007-07-18 Thread Calvin Spealman
I am looking to start a meetup in or near Charlotte. I already have a couple people interested, and I see some folks subscribing to new python groups on meetup. If I can find a few more people, it could be worth it. Is anyone in the area and interested in a group? Anyone who might want to do a

Re: Charlotte Python Group

2007-07-18 Thread Calvin Spealman
Holy crap, did I forget to mention the state and country? I could be a moron, at times. This would be Charlotte, North Carolina, the United States of America. On 7/18/07, Wildemar Wildenburger [EMAIL PROTECTED] wrote: Calvin Spealman wrote: I am looking to start a meetup in or near Charlotte

ANN: CharPy, Charlotte, NC Python Group

2007-07-20 Thread Calvin Spealman
I announced the idea earlier, but forgot to mention the state. I started a mailing list, and I want to find who in the area might be interested. Join if you can, even if you don't know you'll stick. We need to see what kind of interest there is in the area. If you are in the area, even if you

Re: Advice on sending images to clients over network

2007-07-22 Thread Calvin Spealman
On 7/22/07, Paul McNett [EMAIL PROTECTED] wrote: Paul Rubin wrote: Frank Millman [EMAIL PROTECTED] writes: Any suggestions will be much appreciated. Why on earth don't you write the whole thing as a web app instead of a special protocol? Then just use normal html tags to put images

Re: Where is the collections module?

2007-07-22 Thread Calvin Spealman
Look in Modules/_collectionsmodule.c Pretty much any built-in module will be named thusly. On 7/22/07, Gordon Airporte [EMAIL PROTECTED] wrote: I was going to try tweaking defaultdict, but I can't for the life of me find where the collections module or its structures are defined. Python 2.5.

Coroutine API

2007-08-03 Thread Calvin Spealman
I was talking to some other people, who all were working on different schedulers and such for coroutines. We decided to work out a common API to give coroutines, and common rules to passing data between them, etc. I am wondering now if there is already work on this, or some schedulers I'm not

Re: Is Python really a scripting language?

2007-12-11 Thread Calvin Spealman
The term scripting language is a pretty misunderstood one these days. I hold the opinion that what it is supposed to mean can, today, apply to any language. C, even, is a scripting language. All any of our software today is doing is calling out to some other component and simply acting as

Re:

2007-12-11 Thread Calvin Spealman
My first reaction is that if you have this and dont know how to get the list from it then maybe you are not as sure as you could be that you want to have such a string in the first place. Why do you have this list in a string? On Dec 11, 2007, at 5:14 PM, katie smith wrote: How on earth

Re: replacing built-in exception types

2007-12-11 Thread Calvin Spealman
Why would you do this? How to do it, if its even possible, is far less important than if you should even attempt it in the first place. On Dec 11, 2007, at 3:51 PM, Nishkar Grover wrote: I'm trying to replace a built-in exception type and here's a simplified example of what I was hoping

Re: replacing built-in exception types

2007-12-11 Thread Calvin Spealman
construct the hierarchy of subclasses, so for example, my subclass of OSError is a subclass of the built-in OSError and a subclass of my subclass of EnvironmentError. The only thing left to do is find a way to replace the built-in exception types with my custom ones. - Nishkar Calvin

Re: psycopg

2007-12-12 Thread Calvin Spealman
Don't do that, for a number of reasons. String concatenation is really never a good idea and formatting your own query strings is exactly what leads to things like sql injection. Let the db library handle it for you: cur.execute('insert into seq(id,sequence) values(3, %s)', (content,))

Re: __init__ method for containers

2007-12-12 Thread Calvin Spealman
I agree that the behavior should be more consistant, but you also should not be calling __init__ more than once on any given instance and that in and of itself should probably constitute undefined behavior. On Dec 12, 2007, at 3:22 PM, Neil Cerutti wrote: List and deque disagree on what

Re: Stringified list back to list of ints

2007-12-12 Thread Calvin Spealman
I still hold my vote that if you need to reverse the stringification of a list, you shouldn't have stringified the list and lost hold of the original list in the first place. That is the solution above all others. On Dec 12, 2007, at 10:26 AM, Paul McGuire wrote: On Dec 12, 7:25 am, Lee

Re: problem pickling a function

2007-12-12 Thread Calvin Spealman
On Dec 12, 2007, at 11:01 AM, Emin.shopper Martinian.shopper wrote: Dear Experts, I love the pickle module, but I occasionally have problems pickling a function. For example, if I create an instance g of class f and assign g.x to a function, then I cannot pickle g (example code

Re: __init__ method for containers

2007-12-12 Thread Calvin Spealman
On Dec 12, 2007, at 4:05 PM, Neil Cerutti wrote: On 2007-12-12, Calvin Spealman [EMAIL PROTECTED] wrote: I agree that the behavior should be more consistant, but you also should not be calling __init__ more than once on any given instance and that in and of itself should probably

Re: Newbie NameError problem

2007-12-12 Thread Calvin Spealman
On Dec 12, 2007, at 11:26 AM, [EMAIL PROTECTED] wrote: I don't understand what I don't understand in the following: You also don't understand how to ask for help properly. Your example is too large, for one. You want a minimal working example (http://

Re: classmethod inheritance

2007-12-12 Thread Calvin Spealman
If you need multiple factories you can do so but to do what you're asking requires both a factory and an instance method initializer, just like __new__ is a class method and __init__ is an instance method. One creates and one initializes what is already created. On Dec 12, 2007, at 12:49

Re: Monitoring the output of an external program

2007-12-13 Thread Calvin Spealman
I always recommend the subprocess module for any needs like this. Read up on it and it should provide everything you need. On Dec 13, 2007, at 2:41 AM, Caleb Marcus wrote: I'm writing something that has to invoke an external program, and every time the external program prints something,

Re: what the heck does this mean?

2007-12-13 Thread Calvin Spealman
On Dec 12, 2007, at 10:57 PM, katie smith wrote: Traceback (most recent call last): File C:\Python25\empire\Empire Strategy.pyw, line 322 Maty = Searched(number) Look, you're calling Searched right here with Searched(number) TypeError: 'list' object is not callable ... Maty

Re: parallel processing in standard library

2007-12-28 Thread Calvin Spealman
I think we are a ways off from the point where any of the solutions are well used, matured, and trusted to promote as a Python standard module. I'd love to see it happen, but even worse than it never happening is it happening too soon. On Dec 27, 2007 8:52 AM, Emin.shopper Martinian.shopper

Re: storing references instead of copies in a dictionary

2008-07-17 Thread Calvin Spealman
On Thu, Jul 17, 2008 at 7:45 AM, mk [EMAIL PROTECTED] wrote: Hello everyone, I'm storing functions in a dictionary (this is basically for cooking up my own fancy schmancy callback scheme, mainly for learning purpose): def f2(arg): ... return f2 + arg ... def f1(arg): ... return

Re: Instance

2008-07-17 Thread Calvin Spealman
On Thu, Jul 17, 2008 at 2:56 AM, karthikbalaguru [EMAIL PROTECTED] wrote: Hi, I am new to python. I am trying to use the python files given to me for bringing up a setup. I get the following error while trying to use a python file - AttributeError : Classroom instance has no attribute

Re: Getting a unknown word out of a list with no spaces

2008-07-17 Thread Calvin Spealman
BeautifulSoup. You need a good html parsing, not some one-shot code to handle one tiny unflexable pattern. On Thu, Jul 17, 2008 at 3:07 AM, Alexnb [EMAIL PROTECTED] wrote: Hello Lets say I have a string: --a href=/browse/brick--brick--/a-- The -- needs to be replaced with or where

Re: __new__

2008-08-03 Thread Calvin Spealman
its a good point you make. if its not _technically_ immutable, why use __new__ when __init__ would work just as fine? well, if it should be treated as immutable, then we should do what we can to follow that, even in internal code that knows otherwise. Besides, maybe down the road, protections will

Re: A bug in difflib module? (find_longest_match)

2008-08-04 Thread Calvin Spealman
This came up again and I was taking a look at it. There seems to still be no resolution. I have a patch that can add a kwarg to skip this behavior if you know you need otherwise. Right now its a simple boolean flag, but is this enough? Are there any use cases anyone has to define how this case is

Re: Wouldn't it be nice if this worked?

2008-08-10 Thread Calvin Spealman
dont quote me but i do think this check is being removed. On Sun, Aug 10, 2008 at 3:42 PM, Patrick Mullen [EMAIL PROTECTED] wrote: How about: class A: def add(self,x,y): return x+y class B(A): pass print B().add(1, 2) This also works: class A: def add(self, x, y):

Re: updating dictionaries from/to dictionaries

2008-08-11 Thread Calvin Spealman
for k in foo: foo[k] += bar.get(k, 0) On Mon, Aug 11, 2008 at 3:27 AM, Brandon [EMAIL PROTECTED] wrote: Hi all, I am not altogether experienced in Python, but I haven't been able to find a good example of the syntax that I'm looking for in any tutorial that I've seen. Hope somebody can

Re: How to execute commands in internal zones of solaris using python running from the global zone ?

2008-08-11 Thread Calvin Spealman
You might try subprocess, first of all. Use it to launch zlogin and then treat it like a shell and write 'zonename\n' to its stdin, to simulate running it as a user. This is a good bet, but I don't have either available to try it. The subprocess documentation covers invoking a process and writing

Re: How to iterate a sequence, with skipping the first item?

2008-08-12 Thread Calvin Spealman
i = iter(container.iterChildren()) i.next() for x in i: ... On Tue, Aug 12, 2008 at 2:51 AM, ray [EMAIL PROTECTED] wrote: A container object provides a method that returns an iterator object. I need to iterate the sequence with that iterator, but need to skip the first item. I can only

Re: Why nested scope rules do not apply to inner Class?

2008-08-12 Thread Calvin Spealman
The simple answer is Dont nest classes. It is not supported. What you are seeing is really an artifact of how classes are built. Basically, everything inside the class body has to exist before it can run, so the inner classes code objects are actually created first. However, the class object

Re: Thesaurus / ontology / taxonomy Python library

2008-08-12 Thread Calvin Spealman
Sounds like you might want to read up on RDF On Tue, Aug 12, 2008 at 10:41 AM, Benjamin Michiels [EMAIL PROTECTED] wrote: Hi, I am curently looking for a library allowing the creation and management of a thesaurus. Our requirements are the following: - creation of our own thesaurus (that

Re: python interpreter

2008-08-12 Thread Calvin Spealman
The best answer is: Don't do that! That isn't how you test things. Write test scripts, probably using the unittest framework. You'll save yourself time and trouble having easily reproducible tests. Many people suggested reload(), but you should know it is dangerous. It can have results you don't

Re: Why nested scope rules do not apply to inner Class?

2008-08-12 Thread Calvin Spealman
Please re-evaluate your need for nesting classes in the first place. On Tue, Aug 12, 2008 at 1:06 PM, Cousson, Benoit [EMAIL PROTECTED] wrote: This is a language limitation. This is because nested scope is implemented for python function only since 2.3 allow late binding of free variables.

Re: super, object and type?

2008-08-12 Thread Calvin Spealman
object and type both are instances of type. Yes, type is an instance of itself. type inherits object. On Tue, Aug 12, 2008 at 1:14 PM, ssecorp [EMAIL PROTECTED] wrote: super(object, type) super: class 'object', type object super(type, object) super: class 'type', type object how can both

Re: Why nested scope rules do not apply to inner Class?

2008-08-12 Thread Calvin Spealman
/pipermail/python-dev/2002-November/029872.html On Tue, Aug 12, 2008 at 4:40 PM, Maric Michaud [EMAIL PROTECTED] wrote: Le Tuesday 12 August 2008 15:51:30 Calvin Spealman, vous avez écrit : The simple answer is Dont nest classes. It is not supported. I can't agree with this, there are many common

Re: You advice please

2008-08-13 Thread Calvin Spealman
Ruby (on Rails) people love to talk about Ruby (on Rails). Python people are too busy getting things done to talk as loudly. On Wed, Aug 13, 2008 at 11:04 AM, D'Arcy J.M. Cain [EMAIL PROTECTED] wrote: On Wed, 13 Aug 2008 13:47:58 +0200 Álvaro G. Vicario [EMAIL PROTECTED] wrote: But I've never

Re: Why nested scope rules do not apply to inner Class?

2008-08-13 Thread Calvin Spealman
On Wed, Aug 13, 2008 at 11:32 AM, Cousson, Benoit [EMAIL PROTECTED] wrote: Defining it as a nested class saves you one line of code, but IMHO makes the result just a bit more cluttered, while reducing the elegance of reusing the metaclass. The whole point of nested class is to avoid polluting

Re: You advice please

2008-08-13 Thread Calvin Spealman
God forbid I try to make a joke. On Wed, Aug 13, 2008 at 11:20 AM, Nigel Rantor [EMAIL PROTECTED] wrote: Calvin Spealman wrote: Ruby (on Rails) people love to talk about Ruby (on Rails). Python people are too busy getting things done to talk as loudly. Have you read this list? I would

Re: Why nested scope rules do not apply to inner Class?

2008-08-13 Thread Calvin Spealman
On Wed, Aug 13, 2008 at 7:41 PM, Maric Michaud [EMAIL PROTECTED] wrote: I was not aware of any nested classes are unsupported before and didn't consider nested classes as bad practice till now, even with the pickle limitation (not every class are intended to be pickled), more you didn't give

Re: Why nested scope rules do not apply to inner Class?

2008-08-13 Thread Calvin Spealman
On Wed, Aug 13, 2008 at 10:49 PM, Carl Banks [EMAIL PROTECTED] wrote: There is no point of nested classes because nested classes _are not_ supported by python. They are simply an artifact of not actively denying the syntax non-globally. I would fully support a change to the language to

Re: precedence of [] vs .

2008-08-14 Thread Calvin Spealman
On Thu, Aug 14, 2008 at 6:46 PM, Michael Tobis [EMAIL PROTECTED] wrote: I wrote some code to test the precedence of getitem vs getattr; it shows that getitem binds tighter. I have been handed some code that relies on the observed behavior. However, the Nutshell precedence list claims the

Re: Dynamically defined functions via exec in imported module

2008-08-15 Thread Calvin Spealman
On Fri, Aug 15, 2008 at 10:48 PM, Nadeem [EMAIL PROTECTED] wrote: I understand the 99% rule... the example I gave was to simplify the issue. The full thing I'm working on is a library for an introductory CS class I'm teaching. I'm trying, essentially, to build a library of macros for students

Can't Find Headers on OSX

2007-11-30 Thread Calvin Spealman
I'm still on 10.4 and I'm trying to build pyOpenSSL, but I'm failing with Python.h trying to include and failing to find any of the shared libraries. I can't figure this one out because i just don't compile anything non trivial often. ironfroggy:~/Desktop/pyOpenSSL-0.6 ironfroggy$ python setup.py

Unittest Automation

2007-05-07 Thread Calvin Spealman
I'm trying to find a better way, a shell one-liner, that I can use to recurse through my project, find all my test_ modules, aggregate the TestCase classes into a suite, and run all my tests. Basically, what py.test does out of the box. Why am I having such trouble doing it? -- Read my blog! I

kwarg references

2007-04-24 Thread Calvin Spealman
In the internal API when a C function is called and passed a kwarg dictionary, is there any case where anything else has a reference to it? I checked with the following code and it looks like even if you explicitly pass a dictionary with **kwargs, it still copies the dictionary anyway. -- Read

Charlotte Python Group

2007-04-25 Thread Calvin Spealman
Attending my first meetup tomorrow for the Agile Charlotte group from meetup.com. My old area, surrounded by cows and corn, had no chance of getting any meetups, so I'm excited to be back at the city and able to partake in some community. If anyone by chance is attending, or near enough to make

Re: once assigment in Python

2007-09-14 Thread Calvin Spealman
This is one of the things that I often see people trying to do in Python, where the best solution is simply to understand how Python works and craft the code to work with the language. The problem, in my view, is not that you don't have a good way to do this once assignment operation, but that you

Re: Needless copying in iterations?

2007-09-15 Thread Calvin Spealman
This is a case where its up to the type involved. For example, xrange() slices the way you want but range() does not. Maybe a type would return for slices a proxy object that got the value by index or maybe it knows that it makes more sense to give you a copy because changes during the iteration

Re: Importing Module To Use Variables In A Second Module

2007-09-28 Thread Calvin Spealman
Most problems like this are caused by trying to access the attributes of the module before that module is fully executed, and thus before they are defined. For example, if you have A.py: import B data = TEST And B.py: import A print A.data Now, if you run A,py, it will import B before

setuptools on mac

2007-10-06 Thread Calvin Spealman
I am trying to install the newest setuptools on my macbook. 2.3 was installed by default, and 2.4 is installed and is my default version now. However, when I try to import setuptools, which is required to _install_ setuptools, I get this error: macbkpro1:~/Desktop/setuptools-0.6c7 ironfroggy$

Extra Unittest Information

2006-09-13 Thread Calvin Spealman
This is something I have been wanting to find for a while, but i haven't figured out. I really would love to know if there is some way I can report extra information while running unittests, and have that information appear along with the tracebacks, so its near the relevent test's results. --

Re: Check if variable is an instance of a File object

2006-09-15 Thread Calvin Spealman
On 15 Sep 2006 00:18:14 -0700, [EMAIL PROTECTED] [EMAIL PROTECTED] wrote: Hi everyone, Maybe these questions will sound strange to you, but I sometime have a hard time switching from Java to Python ;-) Let's say I have a function like this : def show_lines(file): for next_line in

Re: generators/iterators: filtered random choice

2006-09-15 Thread Calvin Spealman
On 15 Sep 2006 19:17:25 -0700, gry@ll.mit.edu gry@ll.mit.edu wrote: I want a function (or callable something) that returns a random word meeting a criterion. I can do it like: def random_richer_word(word): '''find a word having a superset of the letters of word''' if len(set(word)

Re: Hardlinks on NTFS

2006-09-17 Thread Calvin Spealman
On 9/17/06, Wildemar Wildenburger [EMAIL PROTECTED] wrote: Hi :) I'm thinking of letting my program create hardlinks (or symlinks). I know python allows doing this for ext, reiser and the like, but apparently not for ntfs systems. Is there any package out there that lets me create links in a

Re: CONSTRUCT - Adding Functionality to the Overall System

2006-09-17 Thread Calvin Spealman
On 17 Sep 2006 09:22:16 -0700, Ilias Lazaridis [EMAIL PROTECTED] wrote: I understand that I can use __metaclass__ to create a class which modifies the behaviour of another class. How can I add this metaclass to *all* classes in the system? (In ruby I would alter the Class class) This is a

Re: Pythondocs.info : collaborative Python documentation project

2006-09-17 Thread Calvin Spealman
On 9/17/06, A.M. Kuchling [EMAIL PROTECTED] wrote: On Sun, 17 Sep 2006 18:10:51 +0200, Daniel Nogradi [EMAIL PROTECTED] wrote: start a new one. What would be very useful though is more visible links on the python.org site to the activestate repository where appropriate. I'm not

Re: Problem with operator overloading and inheritance in Python

2006-09-17 Thread Calvin Spealman
On 9/17/06, Edward A. Waugh [EMAIL PROTECTED] wrote: Consider the following code: import sys class FirstClass: def __init__(self, value): self.data = value def __add__(self, value): return FirstClass(self.data + value) def display(self): print

Re: modules in diff. file

2006-09-18 Thread Calvin Spealman
On 18 Sep 2006 00:19:20 -0700, JyotiC [EMAIL PROTECTED] wrote: hi, i have a prog. and i want diving the code in different files. there will be one mail file which will call modules or variables(global) from differnet files how can i do this. code is very big and i it's getting difficult to

Re: Cross-process dictionary/hashtable

2006-09-18 Thread Calvin Spealman
On 18 Sep 2006 12:44:32 -0700, Sandra-24 [EMAIL PROTECTED] wrote: A dictionary that can be shared across processes without being marshaled? Is there such a thing already for python? If not is there one for C maybe? I was just thinking how useful such a thing could be. It's a great way to

Re: why a main() function?

2006-09-18 Thread Calvin Spealman
On 18 Sep 2006 12:40:00 -0700, [EMAIL PROTECTED] [EMAIL PROTECTED] wrote: I think I read a suggestion somewhere to wrap the code where a Python script starts in a main() function, so one has def main(): print hi main() instead of print hi What are the advantages of doing this? It

Re: [ANN] Code Golf Challenge : 1,000 Digits Of Pi

2006-09-18 Thread Calvin Spealman
On 9/18/06, Carl Drinkwater [EMAIL PROTECTED] wrote: Hi all, Code Golf's 12th challenge has just been added to the site. It asks you to calculate the first 1,000 digits of Pi - Something I'm sure most of you have thought about, but never done. You can see the challenge at :

Re: Problem with operator overloading and inheritance in Python

2006-09-18 Thread Calvin Spealman
define new-style classes? - Edward Original Message Follows From: Calvin Spealman [EMAIL PROTECTED] Reply-To: [EMAIL PROTECTED] To: Edward Waugh [EMAIL PROTECTED] Subject: Re: Problem with operator overloading and inheritance in Python Date: Mon, 18 Sep 2006 17:06:53 -0400 On 9/18

Re: Read a group of files as a list

2006-09-18 Thread Calvin Spealman
On 18 Sep 2006 17:09:22 -0700, citlaly [EMAIL PROTECTED] wrote: Hi!! I'm a beginner in python and I'm trying to use the files from a folder as a list. What I want to do is read each one as a list, but just the name of the file, the data inside doesn't matter. How can I do it? I was trying

Re: Code Golf Challenge : 1,000 Digits Of Pi

2006-09-18 Thread Calvin Spealman
On 18 Sep 2006 16:33:20 -0700, George Sakkis [EMAIL PROTECTED] wrote: Calvin Spealman wrote: Just once, I would like to see a programming contest that was judged on the quality of your code, not the number of bytes you managed to incomprehensively hack it down to. Unfortunately, quality

Re: CONSTRUCT - Adding Functionality to the Overall System

2006-09-18 Thread Calvin Spealman
On 18 Sep 2006 20:23:03 -0700, Ilias Lazaridis [EMAIL PROTECTED] wrote: Steve Holden wrote: Ilias Lazaridis wrote: ... http://www-128.ibm.com/developerworks/linux/library/l-pymeta.html I am not so much interested in old-style, as is start production with python 2.4 (possibly even

Re: Python Threading

2006-09-21 Thread Calvin Spealman
On 20 Sep 2006 00:27:07 -0700, daniel [EMAIL PROTECTED] wrote: Hello, Can anyone explain the main points in working with threads in Python. Why use threading and not Thread.I have read an article that i have to subclass the Thread class and override some function. I repeat this all the time,

Re: Need help with syntax on inheritance.

2006-10-04 Thread Calvin Spealman
On 3 Oct 2006 19:09:53 -0700, SpreadTooThin [EMAIL PROTECTED] wrote: If you are deriving a new class from another class, that you must (I assume) know the initializer of the other class. So in myClass import array class myClass(arrary.array): def __init__(self, now here I need to put

Re: Initialization of variables using no-arg constructor

2006-10-09 Thread Calvin Spealman
On 10/9/06, Edward Waugh [EMAIL PROTECTED] wrote: Consider the following (working) Python code: import sys def sum(list): # total = 0 does not work for non-numeric types total = list[0].__class__() for v in list: total += v return total l = [1, 2, 3] print

Re: screen output problem

2006-11-25 Thread Calvin Spealman
On 25 Nov 2006 15:27:26 -0800, Ritesh Raj Sarraf [EMAIL PROTECTED] wrote: Hi, I have, for very long, been trying to find a consistent solution (which could work across major python platforms - Linux, Windows, Mac OS X) for the following problem. I have a function which downloads files from

Re: [help] Is it true to call obj.__str__() while executing print obj?

2006-11-29 Thread Calvin Spealman
On 11/29/06, Tommy Zong [EMAIL PROTECTED] wrote: Hi, I am learning metaclass by reading Metaclass programming in Python, Part 2. I have a question as following and had tried to search from internet and also have read the article Unifying types and classes in Python 2.2 but failed to

Re: How to detect what type a variable is?

2006-11-29 Thread Calvin Spealman
On 29 Nov 2006 07:36:26 -0800, Leandro Ardissone [EMAIL PROTECTED] wrote: Hi, I want to know what type is a variable. For example, I get the contents of an xml but some content is a list or a string, and I need to know what type it is. Thanks --

Image SIG ML Moderator does not respond

2006-05-07 Thread Calvin Spealman
I have tried repeatedly to make a post to the Image SIG ML, and get nothing but automated responses that I must wait for word from the moderator to approve my posting on the list. I have gotten no reply, positive or not, in over a month. I am assuming the Image SIG moderator is currently MIA. What

Re: Async callback in python

2006-12-04 Thread Calvin Spealman
On 4 Dec 2006 20:18:22 -0800, Linan [EMAIL PROTECTED] wrote: Hi, In javascript, code could be written like this: ... var _p=XMLHttpRequest(); _p.open('GET',url,true); _p.send(null); _p.onreadystateChange=function(){ if(_p.readyState==4)

Subprocess with a Python Session?

2006-12-05 Thread Calvin Spealman
No matter what I do I cant get the following code to do what I expect. I hadn't used subprocess t o read and write to pipes of a still-running app, and I just can't seem to get it right. What gives? import subprocess p = subprocess.Popen(python, stdout=subprocess.PIPE, stdin=subprocess.PIPE)

Re: Subprocess with a Python Session?

2006-12-05 Thread Calvin Spealman
On 12/5/06, Fredrik Lundh [EMAIL PROTECTED] wrote: Calvin Spealman wrote: No matter what I do I cant get the following code to do what I expect. I hadn't used subprocess t o read and write to pipes of a still-running app, and I just can't seem to get it right. What gives? import

Re: how to get all the variables of a string formating?

2006-12-06 Thread Calvin Spealman
On 6 Dec 2006 09:41:36 -0800, GHUM [EMAIL PROTECTED] wrote: imagine: template= Hello %(name)s, how are you %(action)s we can use it to do things like: print template % dict (name=Guido, action=indenting) Is there an easy (i.e.: no regex) way to do get the names of all parameters?

Re: how to get all the variables of a string formating?

2006-12-06 Thread Calvin Spealman
On 6 Dec 2006 18:33:26 GMT, Duncan Booth [EMAIL PROTECTED] wrote: Calvin Spealman [EMAIL PROTECTED] wrote: I am not aware of anything in the stdlib to do this easily, but its pretty easy to get them. See this example: class format_collector(object): def __init__(self

  1   2   3   >