Re: Happy Christmas Pythoneers

2007-12-24 Thread Michael Bentley
On Dec 24, 2007, at 9:30 AM, [EMAIL PROTECTED] wrote: On Dec 24, 12:17�am, Paddy [EMAIL PROTECTED] wrote: After quite enjoying participating in the group in 2007, I'd like to wish you all a Merry Xmas. - Paddy. Shouldn't that be 0Xmas? msg = ['Merry', '0Xmas'] for message in msg: ...

Re: Pexpect and a Linux Terminal

2007-12-24 Thread Michael Bentley
On Dec 24, 2007, at 7:06 PM, [EMAIL PROTECTED] wrote: hello, I'm new in Python and i would like to use Pexpect to execute a root command (i want to mount via a Pyhton script a drive) so that's my script for the moment : from os import * import pexpect import os cmd1=su - cmd2=mount

Re: Deleting lines from a file

2007-12-17 Thread Michael Bentley
On Dec 17, 2007, at 5:34 AM, Horacius ReX wrote: I need to write a program which reads an external text file. Each time it reads, then it needs to delete some lines, for instance from second line to 55th line. The file is really big, so what do you think is the fastest method to delete

Re: Deleting lines from a file

2007-12-17 Thread Michael Bentley
On Dec 17, 2007, at 6:25 AM, Horacius ReX wrote: and regardless of the speed, what do you think would be the best method to do this ? The first thing I'd look into is reading the whole file into memory, making all the deletions, and finally writing it out. But you said the file is big,

Re: open(.xls file, 'w') so that hyperlinks appear

2007-10-05 Thread Michael Bentley
-- http://mail.python.org/mailman/listinfo/python-list

Re: generating range of numbers

2007-10-03 Thread Michael Bentley
On Oct 3, 2007, at 2:18 AM, vimal wrote: i am new to python. i just want to generate numbers in the form like: 1,2,4,8,16,32.to a maximum of 1024 using a range function I don't think it can be done with *only* a range function... import math [pow(2, x) for x in

Re: List of objects X Database

2007-10-03 Thread Michael Bentley
On Oct 3, 2007, at 1:01 PM, MindMaster32 wrote: I am writing a script that has to read data from an ASCII file of about 50 Mb and do a lot of searches and calculations with that data. That would be a classic problem solved by the use of a database (SQLite would suit just fine), but that

Re: List Question

2007-10-02 Thread Michael Bentley
On Oct 2, 2007, at 2:06 PM, brad wrote: How is this expressed in Python? If x is in y more than three times: print x y is a Python list. # Try using help -- help(list) or help(list.count) for instance... if y.count(x) 3: print x --

Re: Using ImageGrab (PIL) to capture screen of remote computer

2007-10-02 Thread Michael Bentley
On Oct 2, 2007, at 2:33 AM, jorma kala wrote: Is it possible to use ImageGrab of the Python Imaging Library to capture the screen of a remote computer? I'm running my python program on a computer that is connected directly via a ethernet crossover cable to another computer. Can I somehow

Re: notify when process finishes (on unix)

2007-09-30 Thread Michael Bentley
On Sep 30, 2007, at 7:11 AM, bahoo wrote: I'd like to write a script that sends me an email when a unix (Linux) process ends running (or CPU drops below some threshold). Could anyone point me to the relevant functions, or show me an example? man at. --

Re: Killing A Process By PID

2007-09-21 Thread Michael Bentley
On Sep 20, 2007, at 7:46 PM, Arvind Singh wrote: file('/var/lock/Application.lock', 'w').write(str(os.getpid())) Which to be honest appears to run just fine, when I look in that file it always contains the correct process ID, for instance, 3419 or something like that. I honestly doubt

Re: Wait For Application Start

2007-09-18 Thread Michael Bentley
On Sep 18, 2007, at 5:40 AM, Francesco Guerrieri wrote: On 9/18/07, Robert Rawlins - Think Blue [EMAIL PROTECTED] wrote: This seems like a very logical method, but I'm not sure how to implement it into my python code? Is there a simple way to make it wait for that file? Without the

Re: how can I find out the process ids with a process name

2007-09-03 Thread Michael Bentley
cd /proc for i in ls [0-9]*/status do echo $i `grep '^Name' $i | cut -f2` | sed 's/\/status//g' done Um... cd /proc for i in `ls [0-9]*/status` do echo $i `grep '^Name' $i | cut -f2` | sed 's/\/status//g' done --- Let the wookie win. --

Re: how can I find out the process ids with a process name

2007-09-02 Thread Michael Bentley
On Sep 2, 2007, at 12:26 PM, herman wrote: I would like to find out all the process id with the process name 'emacs'. In the shell, i can do this: $ ps -ef |grep emacs root 20731 8690 0 12:37 pts/200:00:09 emacs-snapshot-gtk root 25649 25357 0 13:55 pts/900:00:05

Re: convert non-delimited to delimited

2007-08-27 Thread Michael Bentley
On Aug 27, 2007, at 10:59 AM, RyanL wrote: I'm a newbie! I have a non-delimited data file that I'd like to convert to delimited. Example... Line in non-delimited file: 01397256359210100534+42050-102800FM-15+1198KAIA Should be:

Re: Syslog

2007-08-23 Thread Michael Bentley
On Aug 20, 2007, at 4:56 PM, greg wrote: Hi All, Could anyone tell me how I could syslog to a specific log (e.g. /var/ log/daemon.log, /var/log/syslog.log...)? # something like this: import logging logging.basicConfig(level=logging.DEBUG, format='%(asctime)s

Re: simple spider in python

2007-08-23 Thread Michael Bentley
On Aug 23, 2007, at 6:33 AM, [EMAIL PROTECTED] wrote: Hi everybody, i'm new to the forum so: hello everybody (should I say world?) ^_^ I'm trying to do a simple spider in python which: 1) ask google a query 2) parse the data I'm a python newbie so *any* help would be very, very

Re: popen4 not returning output

2007-08-20 Thread Michael Bentley
On Aug 19, 2007, at 8:58 PM, [EMAIL PROTECTED] wrote: I am trying to run the following script: #!/usr/bin/python import popen2 commandToRun = scp scp_trial.py [EMAIL PROTECTED]:/targetDirectory #commandToRun = ls print commandToRun p_out, p_in = popen2.popen4 (commandToRun) theOut =

Re: Where we need to use Python ?

2007-08-20 Thread Michael Bentley
On Aug 20, 2007, at 1:02 AM, [EMAIL PROTECTED] wrote: And Is it a interpreted language or a programming language It comes in which category I very keen to know this please tell [ open on suburban kitchen, Wife and Husband arguing ] Wife: New Shimmer is a floor wax! Husband: No, new

Re: clarification

2007-08-16 Thread Michael Bentley
On Aug 16, 2007, at 2:42 AM, Beema shafreen wrote: hi every body, i have compared two files: code: fh = open('HPRD_MAIN_20.txt','r') for line in fh.readlines(): data = line.strip().split('#') fh1 = open('NOMENCLATURE_MAIN_20.txt','r') for line1 in fh1.readlines():

Re: curses library

2007-08-15 Thread Michael Bentley
On Aug 14, 2007, at 11:10 AM, Ghirai wrote: I need to write a console application. Are there any wrappers around curses/ncurses? Or any other similar libraries? It looks like Curses Tk still exists: http://www.schwartzcomputer.com/ tcl-tk/tcl-tk.html It probably requires a recompile of Tk

Re: Colored text

2007-08-13 Thread Michael Bentley
On Aug 12, 2007, at 7:05 PM, Rohan wrote: Can some one tell me how do I get colored text. Say when I want to write something in a text file , how do I get it colored. You can use ANSI escape codes -- http://en.wikipedia.org/wiki/ ANSI_escape_code: colorCodes = [ \033[0mAll attributes

Re: Binary, Hex, and Decimal string conversions

2007-08-12 Thread Michael Bentley
On Aug 12, 2007, at 6:28 PM, Dick Moores wrote: n = 12 base = 36 print to_base(n, base) == This seems to work fine for n = base, but not for n base. For example, the code shown returns c. Is my indentation wrong, or the code? It seems to me that the

Re: Launching App

2007-08-09 Thread Michael Bentley
On Aug 9, 2007, at 3:01 AM, Robert Rawlins - Think Blue wrote: I’m looking for the best method to launch my python app when my Linux system boots up. At the moment I just have an entry like this in my rc.local file: CD /myfolder/anotherfolder ./myapp.py Is this the best way to do

Re: Launching App

2007-08-09 Thread Michael Bentley
On Aug 9, 2007, at 3:01 AM, Robert Rawlins - Think Blue wrote: I’m looking for the best method to launch my python app when my Linux system boots up. At the moment I just have an entry like this in my rc.local file: CD /myfolder/anotherfolder ./myapp.py Is this the best way to do this?

Re: Stackless Integration

2007-08-09 Thread Michael Bentley
On Aug 9, 2007, at 4:48 AM, Jean-Paul Calderone wrote: On Thu, 09 Aug 2007 09:00:27 -, Justin T. [EMAIL PROTECTED] wrote: Hi, I've been looking at stackless python a little bit, and it's awesome. My question is, why hasn't it been integrated into the upstream python tree? Does it

Re: subprocess leaves child living

2007-06-06 Thread Michael Bentley
On Jun 6, 2007, at 7:11 AM, Thomas Dybdahl Ahle wrote: Den Tue, 05 Jun 2007 17:41:47 -0500 skrev Michael Bentley: On Jun 5, 2007, at 5:13 PM, Michael Bentley wrote: On Jun 5, 2007, at 4:17 PM, Thomas Dybdahl Ahle wrote: Den Tue, 05 Jun 2007 15:46:39 -0500 skrev Michael Bentley

Re: Beginning Python

2007-06-05 Thread Michael Bentley
On Jun 5, 2007, at 9:29 AM, abhiee wrote: Hello , I have just begun learning python...and I'm loving it...Just wanted to ask you that how much time would it take me to learn python completely and which languages should i learn alongwith python to be a good professional programmer?...Now i

Re: subprocess leaves child living

2007-06-05 Thread Michael Bentley
On Jun 5, 2007, at 3:01 PM, Rob Wolfe wrote: Thomas Dybdahl Ahle [EMAIL PROTECTED] writes: But you can't ever catch sigkill. There is no protection against sigkill. Isn't there a way to make sure the os kills the childprocess when the parrent dies? If the parent dies suddenly without

Re: subprocess leaves child living

2007-06-05 Thread Michael Bentley
On Jun 5, 2007, at 4:17 PM, Thomas Dybdahl Ahle wrote: Den Tue, 05 Jun 2007 15:46:39 -0500 skrev Michael Bentley: But actually *that* is an orphan process. When a parent process dies and the child continues to run, the child becomes an orphan and is adopted by init. Orphan processes can

Re: subprocess leaves child living

2007-06-05 Thread Michael Bentley
On Jun 5, 2007, at 5:13 PM, Michael Bentley wrote: On Jun 5, 2007, at 4:17 PM, Thomas Dybdahl Ahle wrote: Den Tue, 05 Jun 2007 15:46:39 -0500 skrev Michael Bentley: But actually *that* is an orphan process. When a parent process dies and the child continues to run, the child becomes

Re: Python Pop Quiz

2007-06-02 Thread Michael Bentley
On Jun 1, 2007, at 9:33 PM, [EMAIL PROTECTED] wrote: 1. Do you like Python? It's pretty good. 2. Do you think Python is good? It's pretty good. 3. Do you think Python is real good? It's pretty good. 4. What is your favorite version of Python? The one I have. 5. Because of Python, do

Re: unknown host

2007-06-01 Thread Michael Bentley
On Jun 1, 2007, at 8:09 AM, abcd wrote: I have a linux machine (ip = 10.10.10.8), which can ping other machines on the same subnet...such as 10.10.10.1 10.10.10.2 10.10.10.5 10.10.10.6 10.10.10.254 If I use socket.gethostbyaddr(ip) I get back results when ip is 10.10.10.1 and

Re: Good Python style?

2007-05-31 Thread Michael Bentley
On May 31, 2007, at 2:59 AM, Andreas Beyer wrote: Hi, I found the following quite cryptic code, which basically reads the first column of some_file into a set. In Python I am used to seeing much more verbose/explicit code. However, the example below _may_ actually be faster than the

Re: ImageMagick Issue

2007-05-31 Thread Michael Bentley
On May 31, 2007, at 8:08 PM, Sick Monkey wrote: I ran into another slight problem. And I attempted to fix it, but have not been able to do so yet. If a filename does not contain a space, then this method works like a charm. But if there is a space then the code throws a nasty error.

Re: ImageMagick Issue

2007-05-30 Thread Michael Bentley
On May 30, 2007, at 11:00 PM, Sick Monkey wrote: When I run the following command: [EMAIL PROTECTED] david.huggins]# identify -format %w '/someDIR/ images/david.huggins/100_0264.JPG' I get the following result 2304 However, when I try to set this value to a variable,

Re: How to get a dot's or pixel's RGB with PIL

2007-05-27 Thread Michael Bentley
On May 26, 2007, at 11:29 PM, [EMAIL PROTECTED] wrote: e.g. rtfm = (100,100) im.getpixel(rtfm) -- http://mail.python.org/mailman/listinfo/python-list

Re: Creating Graphs for the Web

2007-05-23 Thread Michael Bentley
On May 23, 2007, at 4:17 PM, erikcw wrote: I'm working on a django powered website, and need to dynamically generate some graphs (bar, pie, and line) from users' data stored in MySQL. Can anyone recommend a good library I can use for this? Matplotlib! --

Re: Restart Linux System

2007-05-22 Thread Michael Bentley
On May 22, 2007, at 11:15 AM, Michael L Torrie wrote: I’m looking to restart a Linux system from my python application. What’s the best way to achieve this, is there something in the OS module? Probably not. You need to just spawn the reboot command, or run init 6. This requires root,

Re: Unable to strip \n characters

2007-05-20 Thread Michael Bentley
On May 20, 2007, at 5:50 AM, aiwarrior wrote: files = f.readlines() for upload in files: upload.strip(\n) final_args = ./rsapiresume.pl %s prem user password % (upload) print upload #os.system( final_args ) for upload in f: final_args = ./rsapiresume.pl %s

Re: Unable to strip \n characters

2007-05-20 Thread Michael Bentley
On May 20, 2007, at 7:41 AM, Michael Bentley wrote: (upload.strip()) Oops: (upload.strip(),) or upload.strip() -- http://mail.python.org/mailman/listinfo/python-list

Re: App Leaving 'sh defunct' Everywhere

2007-05-18 Thread Michael Bentley
On May 18, 2007, at 3:49 AM, Robert Rawlins - Think Blue wrote: I’ve got an application that seems to leave ‘sh defunct’ in my os processes list. I’m running it on Debian, albeit a stripped down embedded version. I’m not sure what the cause of this is, My application starts several

Re: Python compared to other language

2007-05-18 Thread Michael Bentley
On May 18, 2007, at 2:04 PM, scott wrote: I have been looking at the various programming languages available. I have programed in Basic since I was a teenager and I also have a basic understanding of C, but I want something better. Can anybody tell me the benefits and

Re: Code Explanation

2007-05-17 Thread Michael Bentley
On May 17, 2007, at 4:12 AM, Robert Rawlins - Think Blue wrote: I’m currently working on a non-python project, and I’m trying to overcome a task of parsing a text file into a database and/or xml file. I’ve managed to find a parser example written in python, and I’m hoping to deconstruct

Re: FreeType

2007-05-17 Thread Michael Bentley
On May 17, 2007, at 12:29 PM, Glich wrote: Hi, where can I download freetype (= 2.1.7)? I need it to use matplotlib. I have search a lot but still can not find it. Thanks! Type 'freetype' in the google search form, and click the I'm Feeling Lucky button. If that doesn't work for some

Re: FreeType

2007-05-17 Thread Michael Bentley
On May 17, 2007, at 2:47 PM, Glich wrote: I've been there. All the code is in C/C++, don't I need it in python? I will explore the software. I dismissed this because there was no python. I am knew to all of this. Thanks for your reply. The c stuff (freetype) is what you need (it gets

Re: How to convert a number to binary?

2007-05-17 Thread Michael Bentley
On May 17, 2007, at 6:33 PM, Lyosha wrote: Converting binary to base 10 is easy: int('', 2) 255 Converting base 10 number to hex or octal is easy: oct(100) '0144' hex(100) '0x64' Is there an *easy* way to convert a number to binary? def to_base(number, base):

Re: How to convert a number to binary?

2007-05-17 Thread Michael Bentley
On May 17, 2007, at 6:45 PM, Lyosha wrote: On May 17, 4:40 pm, Michael Bentley [EMAIL PROTECTED] wrote: On May 17, 2007, at 6:33 PM, Lyosha wrote: Converting binary to base 10 is easy: int('', 2) 255 Converting base 10 number to hex or octal is easy: oct(100) '0144' hex(100

Re: Trying to choose between python and java

2007-05-16 Thread Michael Bentley
On May 15, 2007, at 8:21 PM, Anthony Irwin wrote: I saw on the python site a slide from 1999 that said that python was slower then java but faster to develop with is python still slower then java? I guess that all depends on the application. Whenever I have a choice between using

Re: url question - extracting (2 types of) domains

2007-05-16 Thread Michael Bentley
On May 15, 2007, at 9:04 PM, lazy wrote: Hi, Im trying to extract the domain name from an url. lets say I call it full_domain and significant_domain(which is the homepage domain) Eg: url=http://en.wikipedia.org/wiki/IPod , full_domain=en.wikipedia.org ,significant_domain=wikipedia.org

Re: removing common elemets in a list

2007-05-16 Thread Michael Bentley
On May 16, 2007, at 10:36 AM, John Zenger wrote: On May 16, 2:17 am, [EMAIL PROTECTED] wrote: Hi, Suppose i have a list v which collects some numbers,how do i remove the common elements from it ,without using the set() opeartor.

Re: Removing part of string

2007-05-14 Thread Michael Bentley
On May 14, 2007, at 12:56 AM, [EMAIL PROTECTED] wrote: Hi, I am parsing an xml file ,and one part of structure looks something like this: - COMPARAM id=_338 DDORef=_18 Semantics=timing PhysicalLink=Infotainment_Control_Bus_CAN

Re: Asyncore Help?

2007-05-14 Thread Michael Bentley
On May 14, 2007, at 4:30 AM, Nick Craig-Wood wrote: The learning curve of twisted is rather brutal :-) -- http://mail.python.org/mailman/listinfo/python-list

Re: How to do basic CRUD apps with Python

2007-05-13 Thread Michael Bentley
On May 13, 2007, at 6:20 PM, walterbyrd wrote: With PHP, libraries, apps, etc. to do basic CRUD are everywhere. Ajax and non-Ajax solutions abound. With Python, finding such library, or apps. seems to be much more difficult to find. I thought django might be a good way, but I can not seem

Re: 4 byte integer

2007-05-11 Thread Michael Bentley
On May 11, 2007, at 4:25 AM, Paul D Ainsworth wrote: Greetings everyone. I'm a relative newcomer to python and I have a technical problem. I want to split a 32 bit / 4 byte unsigned integer into 4 separate byte variables according to the following logic: - bit numbers 0..7 byte 1

Re: searching algorithm

2007-05-11 Thread Michael Bentley
On May 10, 2007, at 12:26 PM, Gigs_ wrote: Hi all! I have text file (english-croatian dictionary) with words in it in alphabetical order. This file contains 17 words in this format: english word: croatian word I want to make instant search for my gui Instant search, i mean that

Re: searching algorithm

2007-05-11 Thread Michael Bentley
Call me dense, but how does one do this in Python - which doesn't have pointers? Dictionaries with dictionaries within dictionaries... (with each letter as the key and the its children as values) is going to be extremely space inefficient, right? Isn't *everything* in python essentially a

Re: searching algorithm

2007-05-11 Thread Michael Bentley
On May 11, 2007, at 3:50 AM, Michael Bentley wrote: Here's an idea: use a rats' nest of dictionaries and do all the lookup work up front when you build the rats' nest. Maybe something like this: ... Oops! This is better :-) #! /usr/bin/env python import pprint dictionary = absinth:pelin

Re: sqlite for mac?

2007-05-01 Thread Michael Bentley
On May 1, 2007, at 12:39 PM, kirkjobsluder wrote: On May 1, 1:12 pm, 7stud [EMAIL PROTECTED] wrote: I'm using python 2.4.4 because the download said there were more mac modules available for 2.4.4. than 2.5, and I can't seem to locate a place to download sqlite for mac. I it comes on OS X

Re: I wish that [].append(x) returned [x]

2007-05-01 Thread Michael Bentley
On May 1, 2007, at 3:45 PM, Tobiah wrote: I wanted to do: query = query text % tuple() but the append() method returns none, so I did this: fields = rec[1:-1] fields.append(extra) query = query text % tuple(fields) As you learned. .append() adds to an existing

Re: How can I get the ascii code of a charter in python?

2007-05-01 Thread Michael Bentley
On May 1, 2007, at 4:06 PM, [EMAIL PROTECTED] wrote: Hi, a python newbe needs some help, I read the python doc at http://docs.python.org/lib/module-curses.ascii.html I tried Import curses.asciicurses.ascii Print ascii('a') I get an error saying module curses.ascii8 does not exsist.

Re: os.path.join

2007-05-01 Thread Michael Bentley
On May 1, 2007, at 8:36 PM, Elliot Peele wrote: Why does os.path.join('/foo', '/bar') return '/bar' rather than '/foo/bar'? That just seems rather counter intuitive. It's the leading slash in '/bar'. os.path.join('/foo', 'bar') returns '/foo/bar'. --

Re: editing scripts on a mac

2007-04-27 Thread Michael Bentley
On Apr 27, 2007, at 11:08 AM, Steve Holden wrote: I am teaching someone Python by email, and part of our conversation recently ran as follows: him How do I save a script and run it? me Do you have a text editor? If so, edit the script in that, then save it me in your home directory

Re: Re-ocurring Events

2007-04-26 Thread Michael Bentley
On Apr 26, 2007, at 4:26 AM, Robert Rawlins - Think Blue wrote: A bit more of a complex one this time, and I thought I’d get your opinions on the best way to achieve this. Basically I’m looking for a way to describe a re-occurring event, like a calendar event or appointment I guess. I’m

Re: trinary operator - if then else

2007-04-25 Thread Michael Bentley
On Apr 25, 2007, at 1:58 AM, Alchemist wrote: What is Python's version for the trinary if..then..else operator? I want a one-liner such as a?b:c for the if..then..else control structure if a then b else c Does Python 2.4 support it? Not precisely, but you can *usually* get away

Re: Tutorial creates confusion about slices

2007-04-24 Thread Michael Bentley
On Apr 24, 2007, at 1:39 AM, Antoon Pardon wrote: On 2007-04-23, Michael Bentley [EMAIL PROTECTED] wrote: On Apr 23, 2007, at 7:38 AM, Antoon Pardon wrote: The following is part of the explanation on slices in the tutorial: The best way to remember how slices work is to think

Re: Tutorial creates confusion about slices

2007-04-24 Thread Michael Bentley
On Apr 24, 2007, at 4:47 AM, Antoon Pardon wrote: On 2007-04-24, Michael Bentley [EMAIL PROTECTED] wrote: On Apr 24, 2007, at 1:39 AM, Antoon Pardon wrote: I suspect that if you give this explanation to someone and explain that there is also a step parameter, chances are he will answer

Re: Tutorial creates confusion about slices

2007-04-24 Thread Michael Bentley
On Apr 24, 2007, at 6:35 AM, Antoon Pardon wrote: On 2007-04-24, Michael Bentley [EMAIL PROTECTED] wrote: On Apr 24, 2007, at 4:47 AM, Antoon Pardon wrote: On 2007-04-24, Michael Bentley [EMAIL PROTECTED] wrote: On Apr 24, 2007, at 1:39 AM, Antoon Pardon wrote: I suspect that if you

Re: Python Screen Scraper

2007-04-24 Thread Michael Bentley
On Apr 24, 2007, at 11:50 AM, James Stroud wrote: Hello, Does anyone know of an example, however modest, of a screenscraper authored in python? I am using Firefox. Basically, I am answering problems via my browser and being scored for each problem. I have a tendency to go past my peak for

Re: If Dict Contains a particular key

2007-04-24 Thread Michael Bentley
On Apr 24, 2007, at 12:28 PM, Robert Rawlins - Think Blue wrote: Hello Guys, I’m Looking to build a quick if/else statement that checks a dictionary for a key like follows. If myDict contains ThisKey: Do this... Else Do that... Thats the best way

Re: Blank rows resulting from simple csv script

2007-04-24 Thread Michael Bentley
On Apr 24, 2007, at 3:35 PM, Drew wrote: Hi all - I've written a simple script to read a .csv file and then write out rows to a new file only if the value in the 4th column is a 0. Here's the code: import csv reader = csv.reader(open('table_export.csv','rb')) writer =

Re: recursion depth problem

2007-04-23 Thread Michael Bentley
On Apr 23, 2007, at 1:57 AM, proctor wrote: On Apr 22, 5:51 pm, Michael Bentley [EMAIL PROTECTED] wrote: Oops! Note to self: *ALWAYS* try code before posting to a public forum :-( def binary(val, width): print '%10s = the sum of' % val for i in [2 ** x for x in range

Re: Do other Python GUI toolkits require this?

2007-04-23 Thread Michael Bentley
OK. In order to kill the-thread-that-would-not-die(tm), I think I know what I must do. I'll print a correction: On Apr 19, 2007, at 2:22 AM, Michael Bentley wrote: ... I switched to PyObjC. The learning curve is rather steep IMO, but worth it. One thing I think I should mention though

Re: Tutorial creates confusion about slices

2007-04-23 Thread Michael Bentley
On Apr 23, 2007, at 7:38 AM, Antoon Pardon wrote: The following is part of the explanation on slices in the tutorial: The best way to remember how slices work is to think of the indices as pointing between characters, with the left edge of the first character numbered 0. Then the right

Re: recursion depth problem

2007-04-22 Thread Michael Bentley
On Apr 22, 2007, at 1:49 PM, proctor wrote: i have a small function which mimics binary counting. it runs fine as long as the input is not too long, but if i give it input longer than 8 characters it gives RuntimeError: maximum recursion depth exceeded in cmp i'm not too sure what i am

Re: recursion depth problem

2007-04-22 Thread Michael Bentley
On Apr 22, 2007, at 4:08 PM, proctor wrote: On Apr 22, 2:55 pm, [EMAIL PROTECTED] wrote: On Apr 22, 11:49 am, proctor [EMAIL PROTECTED] wrote: hello, i have a small function which mimics binary counting. it runs fine as long as the input is not too long, but if i give it input

Re: recursion depth problem

2007-04-22 Thread Michael Bentley
On Apr 22, 2007, at 5:47 PM, proctor wrote: On Apr 22, 4:37 pm, Michael Bentley [EMAIL PROTECTED] wrote: On Apr 22, 2007, at 4:08 PM, proctor wrote: On Apr 22, 2:55 pm, [EMAIL PROTECTED] wrote: On Apr 22, 11:49 am, proctor [EMAIL PROTECTED] wrote: hello, i have a small function which

Re: recursion depth problem

2007-04-22 Thread Michael Bentley
Oops! Note to self: *ALWAYS* try code before posting to a public forum :-( def binary(val, width): print '%10s = the sum of' % val for i in [2 ** x for x in range(width - 1, -1, -1)]: a = val / i print ' ' * 13 + '%s * (2 ** %s)' % (a, width)

Re: Styled Output

2007-04-21 Thread Michael Bentley
On Apr 21, 2007, at 3:21 AM, Robert Rawlins - Think Blue wrote: Chaps, Hope you’re all having a good weekend, I’m sure it’ll only be the more ‘hard core’ of you reading this, anyone with any sanity would be out in the sunshine right now. I’m running a program of mine from Linux

Re: Do other Python GUI toolkits require this?

2007-04-19 Thread Michael Bentley
On Apr 18, 2007, at 5:11 PM, Kevin Walzer wrote: James Stroud wrote: This appears more or less unique to Objective C. It looks that with PyObjC, you have to interact with the Objective C runtime to manage memory. This is not required, thankfully, with any other GUI tookits I've seen. I

Re: Do other Python GUI toolkits require this?

2007-04-19 Thread Michael Bentley
On Apr 19, 2007, at 4:11 AM, Antoon Pardon wrote: On 2007-04-19, Michael Bentley [EMAIL PROTECTED] wrote: On Apr 18, 2007, at 5:11 PM, Kevin Walzer wrote: James Stroud wrote: This appears more or less unique to Objective C. It looks that with PyObjC, you have to interact

Re: Do other Python GUI toolkits require this?

2007-04-19 Thread Michael Bentley
*plonk* -- http://mail.python.org/mailman/listinfo/python-list

Re: Strange terminal behavior after quitting Tkinter application

2007-04-18 Thread Michael Bentley
On Apr 18, 2007, at 2:33 AM, Chris wrote: I'm puzzled by some strange behavior when my Python/Tkinter application quits (on linux): the terminal from which I started Python is messed up. If start up python, then import the code below, then start the program with Application(), then click

Re: Help on Shelve....

2007-04-18 Thread Michael Bentley
On Apr 18, 2007, at 8:19 AM, Clement wrote: On Apr 17, 5:52 pm, Michael Bentley [EMAIL PROTECTED] wrote: On Apr 17, 2007, at 6:52 AM, Clement wrote: Can i useShelvefor storing large amount of data around 6GB.. Is it stable...? if any problems come, can i retrive the document.. Do you know

Re: Help on Shelve....

2007-04-17 Thread Michael Bentley
On Apr 17, 2007, at 6:52 AM, Clement wrote: Can i use Shelve for storing large amount of data around 6GB.. Is it stable...? if any problems come, can i retrive the document.. Do you know for sure your filesystem handles files that big? -- http://mail.python.org/mailman/listinfo/python-list

Re: How to generate a continuous string

2007-04-16 Thread Michael Bentley
On Apr 16, 2007, at 5:03 AM, 人言落日是天涯,望极天涯不 见家 wrote: How to generate a continuous string, like this aaa the number of characters is dynamic. Is there a module or function implement this string ? such as: duplicate_string(char, num) It's even easier than that -- just

Re: OverflowError: mktime argument out of range ???

2007-04-15 Thread Michael Bentley
On Apr 15, 2007, at 5:41 AM, Jorgen Bodde wrote: This is what I try: time.mktime((1928, 12,28, 0, 0, 0, 0, 0, 0)) Traceback (most recent call last): File interactive input, line 1, in module OverflowError: mktime argument out of range Probably depends on your system. It doesn't break

Re: how to strip the domain name in python?

2007-04-15 Thread Michael Bentley
On Apr 15, 2007, at 4:24 PM, [EMAIL PROTECTED] wrote: On Apr 15, 11:57 am, Marc 'BlackJack' Rintsch [EMAIL PROTECTED] wrote: In [EMAIL PROTECTED], Marko.Cain.23 wrote: On Apr 14, 10:36 am, [EMAIL PROTECTED] wrote: On Apr 14, 12:02 am, Michael Bentley [EMAIL PROTECTED] wrote: On Apr

Re: how to check the 'content/type' using urlopen

2007-04-15 Thread Michael Bentley
On Apr 15, 2007, at 6:25 PM, John wrote: i have the following code to open a URL address, but can you please tell me how can I check the content type of the url response? Thank you. try: req = Request(url, txdata, txheaders) handle = urlopen(req) except IOError,

Re: how to strip the domain name in python?

2007-04-15 Thread Michael Bentley
On Apr 15, 2007, at 7:57 PM, Michael Bentley wrote: if net_location[0].lower() == 'www': net_location = net_location[1:] It is not guaranteed that the host name will be 'www' though, is it? If you *really* want to strip the host portion of a domain name, I suppose you could

Re: Append data to a list within a dict

2007-04-14 Thread Michael Bentley
On Apr 14, 2007, at 12:51 AM, Paul Rubin wrote: Is this a class exercise? Hint: 1) figure out how to access the list of the 'two' key 2) append 'twofour' to it. damn. -- http://mail.python.org/mailman/listinfo/python-list

Re: Double backslash in filepaths ?

2007-04-14 Thread Michael Bentley
On Apr 14, 2007, at 4:26 AM, Stef Mientki wrote: It looks like sometimes a single backslash is replaced by a double backslash, but sometimes it's not ??? See the error message below, the first backslash is somewhere (not explicitly in my code) replaced, but the second is not ??? Is it

Re: reading from sys.stdin

2007-04-13 Thread Michael Bentley
On Apr 13, 2007, at 4:47 AM, 7stud wrote: On Apr 13, 3:36 am, 7stud [EMAIL PROTECTED] wrote: It is if the file is smaller than the buffer size. How is that relevant? If I put 100 lines of text in a file with each line having 50 characters, and I run this code: import sys lst = []

Re: Arrays, Got Me Confused

2007-04-13 Thread Michael Bentley
On Apr 13, 2007, at 7:04 AM, Robert Rawlins - Think Blue wrote: #!/usr/bin/python # Filename: Firewall.py class Firewall: def __init__(self): Self.FireArray = array(c) p = Firewall() print p Throws: Traceback (most recent call last): File

Re: Problem with algorithm

2007-04-13 Thread Michael Bentley
On Apr 13, 2007, at 9:19 AM, Paul McGuire wrote: If you just expand the length to five million* or so, one of those strings will contain all the works of Shakespeare. Not likely, even with a tiny sampling of the works of Shakespeare: # :-) import string import random def main(bardText,

Re: Python editor/IDE on Linux?

2007-04-13 Thread Michael Bentley
Everybody uses vim. Except for real programmers... Who instead use emacs ;-) -- http://mail.python.org/mailman/listinfo/python-list

Re: how to strip the domain name in python?

2007-04-13 Thread Michael Bentley
On Apr 13, 2007, at 11:49 PM, [EMAIL PROTECTED] wrote: Hi, I have a list of url names like this, and I am trying to strip out the domain name using the following code: http://www.cnn.com www.yahoo.com http://www.ebay.co.uk pattern = re.compile(http:(.*)\.(.*), re.S) match =

Re: Append data to a list within a dict

2007-04-13 Thread Michael Bentley
On Apr 14, 2007, at 12:39 AM, Tina I wrote: Say I have the following dictionary: ListDict = { 'one' : ['oneone' , 'onetwo' , 'onethree'], 'two' : ['twoone' , 'twotwo', 'twothree'], 'three' : ['threeone' , 'threetwo', threethree']} Now I want to append 'twofour' to the list of the 'two'

Re: reading from sys.stdin

2007-04-12 Thread Michael Bentley
On Apr 12, 2007, at 3:20 AM, 7stud wrote: I can't break out of the for loop in this example: -- import sys lst = [] for line in sys.stdin: lst.append(line) break print lst --- But, I can break out of the for loop when I do this: - import sys lst =

Re: VB6 To Python

2007-04-12 Thread Michael Bentley
On Apr 12, 2007, at 1:11 PM, Sampson, David wrote: Any experience or insight would be great. It has been my experience that when migrating to a dissimilar system, avoiding the rewrite is a mistake. And futile. hth, Michael -- http://mail.python.org/mailman/listinfo/python-list

  1   2   >