Re: Three days with some of the coolest people in ruby and rails

2008-10-07 Thread Chris Rebert
Not that I particularly have anything against Ruby or Rails, but your post isn't quite germane to this mailinglist, which is about Python, not Ruby. Though they are similar languages, your post is entirely devoid of even any reference to Python and thus is not at all relevant. Cheers, Chris --

Re: Job Posting

2008-10-08 Thread Chris Rebert
On Wed, Oct 8, 2008 at 9:20 AM, Capuano, Rebecca [EMAIL PROTECTED] wrote: HI, Would you be able to post this on your site? I don't know if you post jobs. Thanks! This is a general-interest mailinglist about the Python programming language, not a way of directly contacting just the Python.org

Re: Inefficient summing

2008-10-08 Thread Chris Rebert
I personally would probably do: from collections import defaultdict label2sum = defaultdict(lambda: 0) for r in rec: for key, value in r.iteritems(): label2sum[key] += value ratio = label2sum[F1] / label2sum[F2] This iterates through each 'r' only once, and (imho) is pretty

Re: A question about funcation parameter and self defined object

2008-10-08 Thread Chris Rebert
On Wed, Oct 8, 2008 at 4:36 PM, Wei Guo [EMAIL PROTECTED] wrote: Hi, I defined a class called vec3 which contains x, y, z and in another function, I tried to call a function which takes a vec3 as a parameter, but it seems that parameter is passed as a generic object and I can not access x ,

Re: Safe eval of insecure strings containing Python data structures?

2008-10-08 Thread Chris Rebert
On Wed, Oct 8, 2008 at 5:34 PM, Warren DeLano [EMAIL PROTECTED] wrote: I would like to parse arbitrary insecure text string containing nested Python data structures in eval-compatible form: # For example, given a config.txt such as: { 'my_atom' : 1.20, 'my_dict' : { 2:50 , 'hi':'mom'},

Re: default value in __init__

2008-10-09 Thread Chris Rebert
See Pitfall #5 on http://zephyrfalcon.org/labs/python_pitfalls.html It also applies to dictionaries (and sets, any mutable object really). On Thu, Oct 9, 2008 at 1:03 AM, kenneth [EMAIL PROTECTED] wrote: Dear all, I have encountered this weird problem. I have a class definition with an

Re: default value in __init__

2008-10-09 Thread Chris Rebert
On Thu, Oct 9, 2008 at 1:39 AM, kenneth [EMAIL PROTECTED] wrote: On Oct 9, 10:14 am, Christian Heimes [EMAIL PROTECTED] wrote: kenneth wrote: the 'd' variable already contains the 'self.d' value of the first instance and not the default argument {}. Am I doing some stupid error, or this

Re: How to do regular BASH work in Python?

2008-10-09 Thread Chris Rebert
You might also be interested in the 'shutil' module: http://docs.python.org/library/shutil.html#module-shutil Cheers, Chris -- Follow the path of the Iguana... http://rebertia.com On Thu, Oct 9, 2008 at 7:13 AM, Frantisek Malina [EMAIL PROTECTED] wrote: Hey, I found it. Python rocks:

Re: Total Python Noob

2008-10-10 Thread Chris Rebert
On Thu, Oct 9, 2008 at 11:22 PM, Tom Lake [EMAIL PROTECTED] wrote: I have Python 2.6 installed on Vista Ultimate. When I try to calculate sqrt (or any transcendental functions) I get the following error sqrt(2) Traceback (most recent call last): File stdin, line 1, in module NameError:

Re: default value in __init__

2008-10-10 Thread Chris Rebert
On Fri, Oct 10, 2008 at 4:36 AM, [EMAIL PROTECTED] wrote: Bruno Desthuilliers: You mean : to people that don't bother reading the FineManual *nor* searching the newsgroup / ML archives ? Are there ways to change how Python3 manages arguments and functions, to remove this antifeature of

Re: Unicode equality from raw_input

2008-10-11 Thread Chris Rebert
In order to convert a byte sequence to Unicode, Python needs to know the encoding being used. When you don't specify a encoding, it tries ASCII, which obviously errors if your byte sequence isn't ASCII, like in your case. Figure out what encoding your terminal/system is set to, then use the

Re: Decrease code redundancy without breaking references

2008-10-11 Thread Chris Rebert
for cfg in settings_modules: cfg.TEMPLATE_DIRS = (/clients/+ cfg.SITE_FOLDER+/templates, /packages/apps/templates) cfg.MEDIA_FILES_PREFIX = 'http://'+ cfg.SITE_DOMAIN+'/media/' cfg.VIDEO_FILES_URL = 'http://'+ cfg.SITE_DOMAIN+'/video/' cfg.VIDEO_FILES_ROOT = '/clients/'+

Re: Question

2008-10-13 Thread Chris Rebert
To be a bit less sarcastic than the other replies, your question is *much* *much* too vague to be answered. Unless you give us more specific information and ask a more precise question, it's impossible help you. See the link someone already replied with for some good advice on how to do that.

Re: How to set cookie in client machine

2008-10-13 Thread Chris Rebert
See the 'cookie' module: http://www.python.org/doc/2.5.2/lib/module-Cookie.html Also: A. In the future, Google is your friend! That page is the top hit for python cookie for Christ's sake; it's not hard to find. B. Please don't post your question again just because it isn't answered fast enough.

Re: IDE Question

2008-10-15 Thread Chris Rebert
You can find a list and several reviews on http://wiki.python.org/moin/IntegratedDevelopmentEnvironments I think Wing IDE (http://www.wingware.com/products) is generally thought to be the most sophisticated one; but it's neither open-source nor gratis (they do let noncommerical open-source devs

Re: PDF warning under Ubuntu and Fedora

2008-10-15 Thread Chris Rebert
CUPS is the Common Unix Printing System. See http://en.wikipedia.org/wiki/CUPS for more info. Apparently something (your script or one of the libraries it uses perhaps?) is trying to create a new printer called PDF and failing because that name is already in use, hence the warnings. Cheers, Chris

Re: PDF warning under Ubuntu and Fedora

2008-10-15 Thread Chris Rebert
On Wed, Oct 15, 2008 at 2:12 PM, Stef Mientki [EMAIL PROTECTED] wrote: Chris Rebert wrote: CUPS is the Common Unix Printing System. See http://en.wikipedia.org/wiki/CUPS for more info. Apparently something (your script or one of the libraries it uses perhaps?) is trying to create a new

Re: default value in __init__

2008-10-16 Thread Chris Rebert
On Wed, Oct 15, 2008 at 9:43 PM, Aaron Castironpi Brady [EMAIL PROTECTED] wrote: On Oct 15, 11:33 pm, Steve Holden [EMAIL PROTECTED] wrote: Aaron Castironpi Brady wrote: [about how default argument behavior should, in his opinion, be changed] Say what you like. The language is as it is by

Re: account balance checker

2008-10-16 Thread Chris Rebert
You'd probably have to use something like mechanize (http://wwwsearch.sourceforge.net/mechanize/) to fill out the forms, but if BofA's website uses Javascript at all, you're probably out of luck. Cheers, Chris -- Follow the path of the Iguana... http://rebertia.com On Wed, Oct 15, 2008 at 8:09

Re: Dictionary of Dicts question

2008-10-16 Thread Chris Rebert
On Thu, Oct 16, 2008 at 12:19 PM, John Townsend [EMAIL PROTECTED] wrote: I'm working with a Dictionary of Dicts. Something like this: myDict = { 'TestName': { 'FileName':{

Re: Unicode File Names

2008-10-16 Thread Chris Rebert
2008/10/16 Jordan [EMAIL PROTECTED]: On Oct 16, 9:20 pm, John Machin [EMAIL PROTECTED] wrote: On Oct 17, 11:43 am, Jordan [EMAIL PROTECTED] wrote: I've got a bunch of files with Japanese characters in their names and os.listdir() replaces those characters with ?'s. I'm trying to open the

Re: properties access by name

2008-10-17 Thread Chris Rebert
Since rwproperty appears to use descriptors just like regular property(), you'd do it the same way as for any normal attribute, namely: #for reading print foo.y #is the same as print getattr(foo, y) #for writing foo.x = 1 #is the same as setattr(foo, x, 1) Cheers, Chris -- Follow the path of

Re: Normalizing arguments

2008-10-17 Thread Chris Rebert
On Fri, Oct 17, 2008 at 8:37 AM, Dan Ellis [EMAIL PROTECTED] wrote: Given some function, f(a, b, c=3), what would be the best way to go about writing a function, g(f, *args, **kwargs), that would return a normalized tuple of arguments that f would receive when calling f(*args, **kwargs)? By

Re: Script can't find input file despite being in the same directory

2008-10-17 Thread Chris Rebert
On Fri, Oct 17, 2008 at 10:07 AM, Robocop [EMAIL PROTECTED] wrote: I have a simple little script that reads in postscript code, appends it, then writes it to a new postscript file. Everything worked fine a month ago, but after rearranging my directory tree a bit my script fails to find the

Re: Log Exception with Backtrace

2008-10-17 Thread Chris Rebert
On Fri, Oct 17, 2008 at 9:40 AM, Heston James - Cold Beans [EMAIL PROTECTED] wrote: Afternoon Guys, I'm currently logging exceptions within my applications like so: try: #do something except Exception, error: # Log the exception. self.logger.error(Exception Occurred: (%s)

Re: algorizm to merge nodes

2008-10-17 Thread Chris Rebert
(Disclaimer: completely untested) from collections import defaultdict merged = defaultdict(list) for key, val in your_list_of_pairs: merged[key].append(val) result = [[key]+vals for key, vals in merged.items()] Cheers, Chris -- Follow the path of the Iguana... http://rebertia.com On Fri,

Re: better scheduler with correct sleep times

2008-10-18 Thread Chris Rebert
On Sat, Oct 18, 2008 at 5:09 AM, qvx [EMAIL PROTECTED] wrote: I need a scheduler which can delay execution of a function for certain period of time. My attempt was something like this: [code snipped] But then I came up with the following case: 1. I call delay with delay_sec = 10 2. The

Re: default value in __init__

2008-10-19 Thread Chris Rebert
On Sun, Oct 19, 2008 at 12:56 AM, Paul McGuire [EMAIL PROTECTED] wrote: On Oct 14, 1:36 pm, David C. Ullrich [EMAIL PROTECTED] wrote: Well... How to say.. Is there any chance these people will read anything *at all* ? No. That's exactly the point! Basic Python is so transparent that you

Re: what's the python for this C statement?

2008-10-20 Thread Chris Rebert
On Mon, Oct 20, 2008 at 2:56 AM, Michele [EMAIL PROTECTED] wrote: Hi there, I'm relative new to Python and I discovered that there's one single way to cycle over an integer variable with for: for i in range(0,10,1) Actually, you want: for i in range(10): Since starting at 0 and using a step

Re: quick newbie syntax question

2008-10-20 Thread Chris Rebert
On Mon, Oct 20, 2008 at 12:08 PM, Robocop [EMAIL PROTECTED] wrote: Is it possible to do something like this syntactically: year = '2008' month = '09' limit = '31' for i in range(1,limit): This previous line will fail. range() takes numbers, not strings. Change 'limit' to an int. temp =

Re: hiding modules in __init__.py

2008-10-20 Thread Chris Rebert
On Sat, Oct 18, 2008 at 12:03 PM, Brendan Miller [EMAIL PROTECTED] wrote: How would I implement something equivalent to java's package private in python? Say if I have package/__init__.py package/utility_module.py and utility_module.py is an implementation detail subject to change. Is

Re: How to execute a makefile from LINUX system.

2008-10-21 Thread Chris Rebert
On Mon, Oct 20, 2008 at 10:32 PM, gaurav kashyap [EMAIL PROTECTED] wrote: Hi all, I am using Link-41b parser in my program. The windows version of it has an .exe file that can be executed using os.system command On Linux version,I have a makefile. so my question is: How to run the makefile

Re: I want to release the GIL

2008-10-21 Thread Chris Rebert
On Mon, Oct 20, 2008 at 10:12 PM, Piotr Sobolewski [EMAIL PROTECTED] wrote: Hello, I have such program: import time import thread def f(): global lock while True: lock.acquire() print thread.get_ident() time.sleep(1) lock.release()

Re: importing a class thru a variable?

2008-10-21 Thread Chris Rebert
On Tue, Oct 21, 2008 at 4:07 PM, john [EMAIL PROTECTED] wrote: Hi, This is probably a question of questionable sanity, due to the fact I don't think I can explain this well. I'd like to have a script set up such that it imports a class that is named in the command line arguments as the first

Re: Function to Add List Elements?

2008-10-22 Thread Chris Rebert
On Wed, Oct 22, 2008 at 12:59 PM, Henry Chang [EMAIL PROTECTED] wrote: This seems like a simple problem, but I can't find a simple solution. Suppose I have two lists of integers. List A = [A1, A2, A3] List B = [B1, B2, B3] I just simply want a new list, such as: List C = [C1, C2, C3]

Re: Python Script Bug

2008-10-23 Thread Chris Rebert
On Thu, Oct 23, 2008 at 11:54 AM, [EMAIL PROTECTED] [EMAIL PROTECTED] wrote: Hello everyone, I would like to know what isn't good in my script. #!/usr/bin/python # -*- coding: iso-8859-15 -*- from time import strftime import datetime t = input(datetime.date) input() does not do what you

Re: why would 'import win32com' fail?

2008-10-23 Thread Chris Rebert
On Thu, Oct 23, 2008 at 12:21 PM, bill [EMAIL PROTECTED] wrote: All, I am trying to access Excel from Python. Many of the examples started with: import win32com blah, blah I try that from my Python shell and it fails. What am I missing here? It's not a standard

Re: Will Python 3 be stackless?

2008-10-23 Thread Chris Rebert
On Thu, Oct 23, 2008 at 1:14 PM, Phillip B Oldham [EMAIL PROTECTED] wrote: Will Python 3 be stackless? Or, rather, will it have any features similar to stackless' microthreads and channels? -- http://mail.python.org/mailman/listinfo/python-list No, it will definitely not. But it does have

Re: How to examine the inheritance of a class?

2008-10-23 Thread Chris Rebert
On Thu, Oct 23, 2008 at 6:36 PM, John Ladasky [EMAIL PROTECTED] wrote: Hello again! Suppose that I have several subclasses which inherit from a base class, thus: class Foo(object): class Spam1(Foo): class Spam2(Foo): class Spam3(Foo): etc. The list of subclasses is not fully

Re: Global dictionary or class variables

2008-10-24 Thread Chris Rebert
On Fri, Oct 24, 2008 at 1:44 PM, Mr. SpOOn [EMAIL PROTECTED] wrote: Hi, in an application I have to use some variables with fixed valuse. For example, I'm working with musical notes, so I have a global dictionary like this: natural_notes = {'C': 0, 'D': 2, 'E': 4 } This actually works

Re: Database specialized in storing directed graphs?

2008-10-28 Thread Chris Rebert
On Mon, Oct 27, 2008 at 5:32 PM, Carl Banks [EMAIL PROTECTED] wrote: I was wondering if anyone had any advice on this. This is not to study graph theory; I'm using the graph to represent a problem domain. The graphs could be arbitrarily large, and could easily have millions of nodes, and

Re: Contracts for Python

2008-10-28 Thread Chris Rebert
On Tue, Oct 28, 2008 at 10:47 AM, Paulo J. Matos [EMAIL PROTECTED] wrote: Hi all, I am wondering if there is any work on contracts for Python. I could only find PEP316, however, I am wondering if there is any official support for it already (tools I mean), and if it is or if it will be

Re: Return lines in file that match string

2008-10-28 Thread Chris Rebert
On Tue, Oct 28, 2008 at 11:37 AM, Travis Kirstine [EMAIL PROTECTED] wrote: I am new to python and could use some help with a fairly easy task. I would like to return all lines in a file that have the string 'coordinates' to a list. from __future__ import with_statement with

Re: Default Argument Question

2008-10-29 Thread Chris Rebert
On Wed, Oct 29, 2008 at 9:14 AM, Paulo J. Matos [EMAIL PROTECTED] wrote: Hi all, Going through the tutorial brought up a question. Consider the functions: def f(a, L=[]): L.append(a) return L print f(3) print f(9) print f(7) def f1(i = 0): i = i + 1 print i f1() f1()

Re: split() and string.whitespace

2008-10-31 Thread Chris Rebert
On Fri, Oct 31, 2008 at 11:53 AM, Chaim Krause [EMAIL PROTECTED] wrote: I am unable to figure out why the first two statements work as I expect them to and the next two do not. Namely, the first two spit the sentence into its component words, while the latter two return the whole sentence

Re: Efficient way to remove objects from a list

2008-11-03 Thread Chris Rebert
On Mon, Nov 3, 2008 at 1:40 AM, 一首诗 [EMAIL PROTECTED] wrote: Hi all, Today I wrote some code like this: Build a new list as you go, then overwrite the old list with it. unfinished = [] for m in self.messages: if not m.finished: unfinished.append(m)

Re: wrapping a method function call?

2008-11-03 Thread Chris Rebert
On Mon, Nov 3, 2008 at 1:57 AM, [EMAIL PROTECTED] wrote: Steven D'Aprano [EMAIL PROTECTED] wrote: Now you can monkey patch class A if you want. It's probably not a great idea to do this in production code, as it will effect class A everywhere. This is perfect for me. The code in question

Re: Is there a better/simpler way to filter blank lines?

2008-11-04 Thread Chris Rebert
On Tue, Nov 4, 2008 at 2:30 PM, tmallen [EMAIL PROTECTED] wrote: On Nov 4, 4:30 pm, [EMAIL PROTECTED] wrote: tmallen: I'm parsing some text files, and I want to strip blank lines in the process. Is there a simpler way to do this than what I have here? lines = filter(lambda line:

Re: find an object ancestor

2008-11-05 Thread Chris Rebert
On Sun, Nov 2, 2008 at 1:16 PM, Michel Perez [EMAIL PROTECTED] wrote: HI all: imagine something like this: class father: pass class son( father ): pass I need to know the son ancestor class how can i know this. Help on built-in function issubclass in module __builtin__:

Re: List to Text back to List

2008-11-06 Thread Chris Rebert
On Thu, Nov 6, 2008 at 12:04 PM, SimonPalmer [EMAIL PROTECTED] wrote: Hi, I am looking for a way to convert a List of floating point numbers to and from text. I am embedding it in an XML document and am looking for a neat way to serialise and de-serialise a list from a text node. I can easily

Re: List to Text back to List

2008-11-06 Thread Chris Rebert
On Thu, Nov 6, 2008 at 12:18 PM, SimonPalmer [EMAIL PROTECTED] wrote: On Nov 6, 8:11 pm, Chris Rebert [EMAIL PROTECTED] wrote: On Thu, Nov 6, 2008 at 12:04 PM, SimonPalmer [EMAIL PROTECTED] wrote: Hi, I am looking for a way to convert a List of floating point numbers to and from text. I am

Re: etymology of list comprehension?

2008-11-06 Thread Chris Rebert
On Thu, Nov 6, 2008 at 1:19 PM, [EMAIL PROTECTED] wrote: I googled and wiki'ed, but couldn't find a concise clear answer as to how python list comprehensions got their name. Who picked the name? What was the direct inspiration, another language? What language was the first to have such a

Re: problem with regex, how to conclude more than one character

2008-11-06 Thread Chris Rebert
On Thu, Nov 6, 2008 at 11:06 PM, [EMAIL PROTECTED] wrote: I always have no idea about how to express conclude the entire word with regexp, while using python, I encountered this problem again... for example, if I want to match the string in test a string, re.findall(r[^a]* (\w+),test a

Re: is it a bug in Module copy or i am wrong??

2008-11-07 Thread Chris Rebert
On Thu, Nov 6, 2008 at 11:59 PM, yoma [EMAIL PROTECTED] wrote: python version 2.5 in module copy we all know that copy have two method: copy() and deepcopy(). and the explain is - A shallow copy constructs a new compound object and then (to the extent possible) inserts *the same objects*

Re: [urllib2 + Tor] How to handle 404?

2008-11-07 Thread Chris Rebert
On Fri, Nov 7, 2008 at 12:05 AM, Gilles Ganault [EMAIL PROTECTED] wrote: Hello I'm using the urllib2 module and Tor as a proxy to download data from the web. Occasionnally, urlllib2 returns 404, probably because of some issue with the Tor network. This code doesn't solve the issue,

Re: List of modules available for import inside Python?

2008-08-27 Thread Chris Rebert
On Wed, Aug 27, 2008 at 9:21 PM, ssecorp [EMAIL PROTECTED] wrote: Is there a way to view all the modules I have available for import from within Python? Like writing in the interpreter: import.modules Also, is there anything like Cpan for Python? The closest thing would be PyPI (the Python

Re: epoch seconds from a datetime

2008-08-28 Thread Chris Rebert
On Thu, Aug 28, 2008 at 10:18 AM, Richard Rossel [EMAIL PROTECTED] wrote: Hi friends, I need a little help here, I 'm stuck with epoch calculation issue. I have this datetime: date_new = datetime(*time.strptime('20080101T00','%Y%m%dT%H%M%S') [0:6]) This date_new is in UTC Now I need to

Re: Multiple values for one key

2008-08-28 Thread Chris Rebert
On Thu, Aug 28, 2008 at 10:02 AM, Ron Brennan [EMAIL PROTECTED] wrote: I have another question. How would like to be able to add the contents on the values for one key. key['20001']:[978, 345] I'm assuming that by this you meant: assert the_dict['20001'] == [978, 345] How can I do this?

Re: re.compile versus r''

2008-08-28 Thread Chris Rebert
On Thu, Aug 28, 2008 at 12:23 PM, Terrence Brannon [EMAIL PROTECTED] wrote: Hello, I'm using a tool (PLY) which apparently expects the tokens to be created using r'' But because one token is a rather complex regular expression, I want to create the regular expression programmatically. How

Re: When to use try and except?

2008-08-29 Thread Chris Rebert
On Fri, Aug 29, 2008 at 10:56 AM, cnb [EMAIL PROTECTED] wrote: On Aug 29, 7:40 pm, Daniel [EMAIL PROTECTED] wrote: On Aug 29, 11:23 am, cnb [EMAIL PROTECTED] wrote: If I get zero division error it is obv a poor solution to do try and except since it can be solved with an if-clause.

Re: How to delete a ast character from a string?

2008-08-29 Thread Chris Rebert
On Fri, Aug 29, 2008 at 11:25 AM, [EMAIL PROTECTED] wrote: Hi, I've a list some of whose elements with character \. I want to delete this last character from the elements that have this character set at their end, I have written a small program, unfortunately this does not work:

Re: Using class-attribute as key to sort?

2008-08-29 Thread Chris Rebert
Just use the key argument to list.sort; e.g. class Foo(object): def __init__(self, x): self.x = x def __repr__(self): return Foo:+str(self.x) foos = [Foo(75), Foo(10), Foo(-1)] foos.sort(key = lambda foo: foo.x) print foos #= [Foo:-1, Foo:10, Foo:75] - Chris

Re: Is this a closure?

2008-08-31 Thread Chris Rebert
Yes, printReviews() is a closure. In particular, it's closing over the variable self, which it's getting lexically from printSelf(). - Chris On Sun, Aug 31, 2008 at 4:53 PM, ssecorp [EMAIL PROTECTED] wrote: A method on a class: def printSelf(self): def printReviews(): for

Re: Some problems with classes

2008-08-31 Thread Chris Rebert
On Sun, Aug 31, 2008 at 6:39 PM, ssecorp [EMAIL PROTECTED] wrote: Why/how is it possible to add variables like this? I don't understand this mechanism: http://docs.python.org/tut/node11.html#SECTION001133 Under the covers, Python objects are implemented using dictionaries, so

Re: How Compute # of Days between Two Dates?

2008-08-31 Thread Chris Rebert
Have you tried using subtraction on datetime.date objects (http://docs.python.org/lib/datetime-date.html)? It produces a timedelta which should be very close to what you want. - Chris On Sun, Aug 31, 2008 at 7:38 PM, W. eWatson [EMAIL PROTECTED] wrote: That's the question in Subject. For

Re: How do I adjust the font size on IDLE when running on Mac OS 10.5.4? TIA.

2008-09-02 Thread Chris Rebert
Same as on all the other platforms. 1. Open IDLE 2. Go Options - Configure IDLE... 3. Choose the Fonts/Tabs section 4. Use the Size pulldown box - Chris On Tue, Sep 2, 2008 at 6:26 AM, Malcolm Lewis [EMAIL PROTECTED] wrote: -- http://mail.python.org/mailman/listinfo/python-list --

Re: Py 2.6 changes

2008-09-02 Thread Chris Rebert
On Mon, Sep 1, 2008 at 6:02 PM, Mensanator [EMAIL PROTECTED] wrote: On Sep 1, 6:55�pm, [EMAIL PROTECTED] wrote: Steven D'Aprano: productory() -- I don't know that function, and googling mostly comes up with retail product searches. Do you mean product(), Darn my English, you are right,

Re: Pass same parameter in Recursive function

2008-09-02 Thread Chris Rebert
Assuming the function is tail-recursive or the unchanging arguments are immutable, just use a closure: def func(self, x, y, A, B, C): def _func(x,y): return _func(g(A,B,C,x), h(A,B,C,y)) #recurse return _func(x, y) I'm unsure as to the performance impact of this though. - Chris

Re: use str as variable name

2008-09-04 Thread Chris Rebert
On Thu, Sep 4, 2008 at 12:25 AM, Mathieu Prevot [EMAIL PROTECTED] wrote: Hi, I have a program that take a word as argument, and I would like to link this word to a class variable. eg. class foo(): You should subclass 'object', so that should be: class Foo(object): width = 10

Re: Converting .doc to .txt in Linux

2008-09-04 Thread Chris Rebert
I'd recommend using one of the Word-txt converters for Linux and just running it in a shell script: * http://wvware.sourceforge.net/ * http://www.winfield.demon.nl/ No compelling reason to use Python in this instance. Right tool for the right job and all that. - Chris On Thu, Sep 4, 2008 at

Re: Case-insensitive string compare?

2008-09-04 Thread Chris Rebert
On Thu, Sep 4, 2008 at 3:37 PM, Robert Dailey [EMAIL PROTECTED] wrote: On Thu, Sep 4, 2008 at 5:21 PM, Fredrik Lundh [EMAIL PROTECTED] wrote: Robert Dailey wrote: I currently have a dictionary object that I'm doing the following with: if lib not in stage_map: # ... do stuff ...

Re: Very simple - please help

2008-11-07 Thread Chris Rebert
On Fri, Nov 7, 2008 at 8:52 PM, pineapple [EMAIL PROTECTED] wrote: I am not a python programmer, but am being forced to port one of my (smalltalk) applications to python for pragmatic reasons (python is embedded with a graphics package I am switching over to, so to use the graphics package I

Re: replacing characters within a string

2008-11-08 Thread Chris Rebert
On Sat, Nov 8, 2008 at 9:16 PM, John Smith [EMAIL PROTECTED] wrote: Hi, I coded a python script that lets me parse a csv file into html code with a certain format, but I would like to replace every and character that appears within each column entry of the csv file (they are parsed as

Re: break up a value in a list to a list of individual items

2008-11-09 Thread Chris Rebert
On Sun, Nov 9, 2008 at 2:38 AM, r3bol [EMAIL PROTECTED] wrote: Hi, sorry to post this, but I've had a really hard time finding how to do it. Q. How can I break up a value in a list to a list of individual items (preferably without importing any modules)? Like... ['12345'] (string) to [1,

Re: [Newbie] Strange output from list

2008-11-11 Thread Chris Rebert
On Tue, Nov 11, 2008 at 12:56 AM, Gilles Ganault [EMAIL PROTECTED] wrote: On Mon, 10 Nov 2008 20:02:39 -0600, Andrew [EMAIL PROTECTED] wrote: sql = 'SELECT id FROM master' rows=list(cursor.execute(sql)) for id in rows: sql = 'SELECT COUNT(code) FROM companies WHERE code=%s' % id[0]

Re: Printing a status line from a python script

2008-11-11 Thread Chris Rebert
On Tue, Nov 11, 2008 at 11:02 AM, Chris Seymour [EMAIL PROTECTED] wrote: Hi All, I am working on a python script for my colleague that will walk a directory and search in the different files for a specific string. These pieces I am able to do. What my colleague wants is that when she runs

Re: Close access to the base class public methods

2008-11-11 Thread Chris Rebert
On Tue, Nov 11, 2008 at 11:16 AM, RinKaMeAri [EMAIL PROTECTED] wrote: On Nov 11, 9:12 pm, Steve Holden [EMAIL PROTECTED] wrote: RinKaMeAri wrote: Hi! Could you imagine any way to block access to the base class public methods? Here is an example: class B: def public_method():

Re: multiple breaks

2008-11-13 Thread Chris Rebert
On Thu, Nov 13, 2008 at 2:07 AM, TP [EMAIL PROTECTED] wrote: Hi everybody, Several means to escape a nested loop are given here: http://stackoverflow.com/questions/189645/how-to-break-out-of-multiple-loops-in-python According to this page, the best way is to modify the loop by affecting the

Re: unittest exits

2008-11-13 Thread Chris Rebert
On Thu, Nov 13, 2008 at 11:01 AM, Alan Baljeu [EMAIL PROTECTED] wrote: When I call unittest.main(), it invokes sys.exit(). I would like to run tests without exiting. How can I? There's probably a better way that stops it from trying to exit in the first place, but here's a quick kludge:

Re: To throw or to throw not?

2008-11-13 Thread Chris Rebert
On Thu, Nov 13, 2008 at 5:11 PM, Emanuele D'Arrigo [EMAIL PROTECTED] wrote: I'm pondering on what is a bit of a philosophical dilemma. When should I throw an exception and when should I not? Suppose I have myFunc1() calling myFunc2() which in turn calls myFunc3 (). Suppose myFunc3() has

Re: email notifier question ??

2008-11-13 Thread Chris Rebert
2008/11/13 yoma [EMAIL PROTECTED]: hi guys! I want to use python send an email to acceptor. And i hope to receive the message that the acceptor has read my email. So how to realize that get the message? To send an email using Python, you'll need to use the `smtplib` module:

Re: Sort dictionary by value when value is a list

2008-11-14 Thread Chris Rebert
On Fri, Nov 14, 2008 at 10:26 AM, major-john [EMAIL PROTECTED] wrote: I'm having trouble sorting a dictionary based on values when the values are all lists, and i want to sort the list by key with the largest value lists in decreasing size. Currently, I have the following: from operator

Re: Unsubscriptable object when using Exec

2008-11-14 Thread Chris Rebert
On Fri, Nov 14, 2008 at 10:40 AM, Indian [EMAIL PROTECTED] wrote: Hi Friends I'm getting the TypeError Unsubscriptable object when using Exec in a class Here's the example class Fake(object): def __init__(self, reg): self._reg = reg def OpenKey(self, rootkey, path):

Re: Need help in understanding a python code

2008-11-15 Thread Chris Rebert
On Sat, Nov 15, 2008 at 8:41 PM, [EMAIL PROTECTED] [EMAIL PROTECTED] wrote: Hi, I am trying to understand the following line: # a is an integer array max([(sum(a[j:i]), (j,i)) This code isn't valid. You have a [ with no closing ]. Cheers, Chris -- Follow the path of the Iguana...

Re: Customizing sequence types

2008-11-16 Thread Chris Rebert
On Sun, Nov 16, 2008 at 8:16 AM, Mr. SpOOn [EMAIL PROTECTED] wrote: Hi, I'm trying to create a class which inherit a list to change some behavior. This list should contain other instance objects and has to manage these instances in a particular way. 1) I need to sort this elements in this

Re: Optional parameter object re-used when instantiating multiple objects

2008-11-16 Thread Chris Rebert
On Sun, Nov 16, 2008 at 11:02 AM, George Sakkis [EMAIL PROTECTED] wrote: On Nov 16, 8:28 am, Steve Holden [EMAIL PROTECTED] wrote: +1. Understanding and accepting the current behavior (mainly because of the extra performance penalty of evaluating the default expressions on every call would

Re: Optional parameter object re-used when instantiating multiple objects

2008-11-16 Thread Chris Rebert
For the Nth time this year that this has come up, I'll point out yet again that this issue has already been discussed to death before: [Python-ideas] proto-PEP: Fixing Non-constant Default Arguments http://mail.python.org/pipermail/python-ideas/2007-January/000121.html [Python-3000] pre-PEP:

Re: Python and Its Libraries--Who's on First?

2008-11-17 Thread Chris Rebert
On Sun, Nov 16, 2008 at 9:25 PM, W. eWatson [EMAIL PROTECTED] wrote: Is there some repository that says something like for Python 2.5 it works with: Win OSes: W2K, XP, Vista For the supported OSes, check the links for the versions on http://python.org/download/ and see whether downloads are

Re: Sorting lists

2008-11-17 Thread Chris Rebert
On Mon, Nov 17, 2008 at 1:56 AM, asc [EMAIL PROTECTED] wrote: Hi all, I have a problem and I'm not sure whether sort() can help me. I understand that if I have a list; say L = ['b', 'c', 'a'] I can use L.sort() and I will then have; L = ['a', 'b', 'c'] But my problem is this. I have a list,

Re: Best practise hierarchy for user-defined exceptions

2008-11-17 Thread Chris Rebert
On Mon, Nov 17, 2008 at 3:47 AM, Slaunger [EMAIL PROTECTED] wrote: Hi there, I am a newcomer to Pyhton coming from Java working on a relatively large Pyhton project with several packages and modules. To improve exception handling I would like to introduce some user-defined exceptions to

Re: Customizing sequence types

2008-11-17 Thread Chris Rebert
On Mon, Nov 17, 2008 at 10:05 AM, Mr. SpOOn [EMAIL PROTECTED] wrote: It seems that I solved my main problem, but I still have some doubt. I'll make an example: class foo: ...def __init__(self, a): ...self.a = a ... f = foo(1) f2 = foo(2) f3 = foo(3) f1 = foo(1) s = set()

Re: Socket Programming and Data transer 'advice'

2008-11-17 Thread Chris Rebert
On Mon, Nov 17, 2008 at 10:42 AM, Abah Joseph [EMAIL PROTECTED] wrote: I am planning to develop School Database Management System that will run on Windows, Linux and Mac. The application will be Server/Client and GUI based. Have you considered basing this off existing software for schools, like

Re: How to deal with globals during refactoring classes into separate files.

2008-11-18 Thread Chris Rebert
On Tue, Nov 18, 2008 at 4:14 PM, r0g [EMAIL PROTECTED] wrote: Hi There, I'm refactoring some old code that uses global variables and was originally written in one big flat file with a view to nicening it up and then extending it. The problem I have though is when I move the various classes

Re: Exception difference 2.4 == 2.5

2008-11-18 Thread Chris Rebert
On Tue, Nov 18, 2008 at 8:56 PM, D'Arcy J.M. Cain [EMAIL PROTECTED] wrote: I am having a strange problem and I can't seem to zero in on it. I am also having trouble reducing it to a small enough snippet that I can post here. I think that I am doing what the more complex script does but none

Re: Non blocking socket server and storage engine

2008-11-19 Thread Chris Rebert
On Wed, Nov 19, 2008 at 2:36 AM, kdeveloper [EMAIL PROTECTED] wrote: Hello Pythonists, I am building a non blocking socket server for incomming UDP packets. The server needs to run at least three threads: 1. getting data and pushing to some storage (at the moment I use queue), 2.

Re: Exception difference 2.4 == 2.5

2008-11-19 Thread Chris Rebert
On Wed, Nov 19, 2008 at 8:24 AM, D'Arcy J.M. Cain [EMAIL PROTECTED] wrote: On Tue, 18 Nov 2008 22:33:35 -0800 Chris Rebert [EMAIL PROTECTED] wrote: What happens under Python 2.6? Interesting. I installed 2.6 and tried it. My unit test still failed but for a different reason that I

Re: Getting fractional part from a float without using string operations

2008-11-19 Thread Chris Rebert
On Wed, Nov 19, 2008 at 10:01 PM, srinivasan srinivas [EMAIL PROTECTED] wrote: Yes it works for most of the cases. But it doesn't for the following case: str(abs(int(1234567.89)-1234567.89)) '0.88999898' Since you really care about significant figures here, have you considered using

Re: Two functionaly identical functions - different results ??!

2008-11-19 Thread Chris Rebert
On Wed, Nov 19, 2008 at 11:24 PM, Barak, Ron [EMAIL PROTECTED] wrote: Hi Guys, I cannot see any difference between read1() and read2() below, and yet, one is okay, the other give an exception. In the first run, read2() is executed, and as expected, the text file is printed $ cat

Re: Using eval, or something like it...

2008-11-20 Thread Chris Rebert
On Thu, Nov 20, 2008 at 3:54 PM, r0g [EMAIL PROTECTED] wrote: Scott David Daniels wrote: r0g wrote: John Machin wrote: You mention variables of a class but you then proceed to poke at an instance of the class Check out setattr (and getattr) in the docs. The former i.e. the

Re: Sending username password to a webpage

2008-11-20 Thread Chris Rebert
On Thu, Nov 20, 2008 at 7:52 PM, KDawg44 [EMAIL PROTECTED] wrote: Hi, Is there a way to essentially simulate populating a text box and calling a submit button on a webpage? I want to write an app that gets a users information from a website and then uses that to get information from another

<    1   2   3   4   5   6   7   8   9   10   >