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 nex

Re: generators/iterators: filtered random choice

2006-09-15 Thread Calvin Spealman
On 15 Sep 2006 19:17:25 -0700, 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) == 26):

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 lin

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

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.

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

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 diffi

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

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

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

Re: Problem with operator overloading and inheritance in Python

2006-09-18 Thread Calvin Spealman
do I 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 over

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

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

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

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 t

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

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 fil

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.

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 > > -- > http://mail.python.org/mailman/

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

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) p.

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

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 o

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

Re: deriving classes from object extensions

2006-12-07 Thread Calvin Spealman
On 7 Dec 2006 16:12:18 -0800, manstey <[EMAIL PROTECTED]> wrote: > Hi, > > I am using Python with Cache dbase, which provides pythonbind module, > and intersys.pythonbind.object types. But I can't create a class based > on this type: > > import intersys.pythonbind > class MyClass(intersys.pythonbin

Re: what is wrong with my code?

2006-12-20 Thread Calvin Spealman
It is hard to determine what is wrong with your code without you telling anyone why it is you believe something is wrong with it. Did you get an exception? Did it simply not do what it was expected to do? There seems to be some apparent indenting problems, but maybe that is just from pushing it thr

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 tal

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 me

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 aren

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 my

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

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 de

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

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 aware

Re: "once" assigment in Python

2007-09-13 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 yo

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 sh

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

Re: The curious behavior of integer objects

2007-01-15 Thread Calvin Spealman
As it turns out, this has little to do with integers and the operations you are trying to do on them. I'll explain in more detail. Integers are immutable, which you may already know. This presents a problem with subclassing them and using the usual special method __init__, because the int object h

Re: assert versus print [was Re: The curious behavior of integer objects]

2007-01-15 Thread Calvin Spealman
On 1/15/07, Steven D'Aprano <[EMAIL PROTECTED]> wrote: > On Mon, 15 Jan 2007 21:38:42 -0500, Calvin Spealman wrote: > > > On 1/15/07, Steven D'Aprano <[EMAIL PROTECTED]> wrote: > >> On Mon, 15 Jan 2007 17:50:56 -0500, Calvin Spealman wrote: > >>

Re: assert versus print [was Re: The curious behavior of integer objects]

2007-01-15 Thread Calvin Spealman
On 1/15/07, Steven D'Aprano <[EMAIL PROTECTED]> wrote: > On Mon, 15 Jan 2007 17:50:56 -0500, Calvin Spealman wrote: > > > assert foo(0x10) == 0 # Assertions are much better tests than prints :-) > > I dispute that assertion (pun intended). Hah! > Firstly, print

Re: [Python-Dev] Deletion order when leaving a scope?

2007-01-17 Thread Calvin Spealman
Absolutely an irrelevent side effect, especially when you take into consideration the 4 and counting alternative implementations of the language. None the less, I can explain why it is as it is, keeping in mind its not like that on purpose, its just how it is. Locals are optimized into an array fo

Re: Object type check

2007-02-07 Thread Calvin Spealman
The answer is to do nothing at all. Use the interfaces of the objects that you expect. Treat them like numbers if you expect them to be, or stirngs, or iterables. Call methods and access attributes you expect to be there. If the caller passes sometihng bad, and something doesn't work, they'll find

Re: Object type check

2007-02-07 Thread Calvin Spealman
On 7 Feb 2007 08:59:12 -0800, king kikapu <[EMAIL PROTECTED]> wrote: > > Dont restrict them to particular types. You would > > not restrict them to a particular class in C#. Instead, you define the > > interfaces simply by how you use the objects. > > Of cource i restrict them to particular types!

Re: Hacking in python

2007-02-10 Thread Calvin Spealman
http://en.wikipedia.org/wiki/Hacker_%28disambiguation%29 Educate yourself on what hacking actually is. We're all hackers, because it just means we get the most out of code, enjoy pushing our technology to the limit, and generally love programming. The term has been abused by the media and you don'

Re: What does "del" actually do?

2007-02-10 Thread Calvin Spealman
del simply removes the name in the current scope. if that happens to be the last non-cyclic reference to the object it was bound to, then it will remove the objec to, but thats a seperate matter. if you remove the class and there are instances out there, they can only exist if there are some other

Re: Something like the getattr() trick.

2007-02-10 Thread Calvin Spealman
This is a really common question. What you really need here is to lookup some value (one of the two classes) by a key (the names of the classes). Does that sound like something familiar? You seem to need a dictionary, where you think you want lookup some global objects by name. Alternatively, if y

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

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 do

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 hopi

Re: replacing built-in exception types

2007-12-11 Thread Calvin Spealman
y 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 Spealman wrote: >> Why would you do this? How to do it, if its even possible, is far >> less >

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,)) Not

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 __i

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

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 an

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:// ironfroggy-code.blogspot.com/2007/02/m

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

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

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

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: 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 <[EMAI

Re: [Python-Dev] To 3.0.2 or not to 3.0.2?

2009-02-16 Thread Calvin Spealman
FWIW; I think a 3.0.2 would be useful socially (even volunteer projects have marketting issues to consider). It says "we are committed to making 3.x work", while the quick jump to 3.1 with only a limited minor fix release to 3.0 says "we stumbled into this and have to just brush this under the rug.

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 12

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 self.__cl

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 cre

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 getat

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, ...) -- http://mail.python.org/mailman/listinfo/

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 h

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

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 --> 'www.exampl

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

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

Getting Python to run Python Scripts in cygwin

2008-06-19 Thread Calvin Cheng
cumbersome switching back-and-forth between command prompt and cygwin just to run python scripts. Thank you in advance, Calvin -- http://mail.python.org/mailman/listinfo/python-list

Docutils rst2html.py gives Unknown Directive type "toctree"

2008-06-19 Thread Calvin Cheng
a how I can fix this? Would be glad if someone who is familiar with docutils could point me in the right direction. Thank you, Calvin -- http://mail.python.org/mailman/listinfo/python-list

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

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

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

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

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 t

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 i

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 its

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 (

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 e

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 va

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(type, object) > , > > > how can both work? > > they can't both be the superclass

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

2008-08-12 Thread Calvin Spealman
tp://mail.python.org/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."

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

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

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 lo

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 g

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 t

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 th

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 stud

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 gl

<    1   2   3   >