Converstion

2006-04-27 Thread Chris
In a program I'm writing I have a problem where a bit of text sent over a network arrives at my server. If the person who sent the text made a mistake typing the word and pressed backspace the backspace code is included in the word for example hello is hel\x08lo. The \x08 is the backspace key. How

Re: Problem reading csv files

2008-01-03 Thread Chris
On Jan 4, 6:24 am, Ramashish Baranwal <[EMAIL PROTECTED]> wrote: > Hi, > > I am trying to read a csv file using csv.reader. The file is created > using Open Office and saved in Excel format. > > import csv > > reader = csv.reader(open('test.xls')) > for row in reader: > print row > > It however

Re: Cursors in a Loop

2008-01-04 Thread Chris
On Jan 4, 5:11 am, Carsten Haese <[EMAIL PROTECTED]> wrote: > On Thu, 2008-01-03 at 17:25 -0800, t_rectenwald wrote: > > On Jan 3, 7:47 pm, t_rectenwald <[EMAIL PROTECTED]> wrote: > > > I have a python script that uses the cx_Oracle module. I have a list > > > of values that I iterate through via

Re: Strange varargs issue

2008-01-04 Thread Chris
On Jan 4, 3:45 pm, Mike <[EMAIL PROTECTED]> wrote: > I'm not sure if this is a bug or if I'm just not understanding > something correctly. I'm running the following (broken.py) on > ActivePython 2.5.1.1, based on Python 2.5.1 (r251:54863 5/1/2007) as > "python broken.py foo" (on Windows, of course

Re: how to build a dict including a large number of data

2008-01-04 Thread Chris
On Jan 4, 3:57 pm, wanzathe <[EMAIL PROTECTED]> wrote: > hi everyone > i'm a newbie to python :) > i have a binary file named test.dat including 960 records. > the record format is int a + int b + int c + int d > i want to build a dict like this: key=int a,int b values=int c,int d > i choose u

Re: Cursors in a Loop

2008-01-05 Thread Chris
On Jan 4, 4:32 pm, Carsten Haese <[EMAIL PROTECTED]> wrote: > On Fri, 2008-01-04 at 00:03 -0800, Chris wrote: > > You should bind all variables to save the pool. > > > cursor = connection.cursor() > > cursor.executemany("""insert into as_siebel_hosts_

Re: Open a List of Files

2008-01-08 Thread Chris
On Jan 8, 1:03 pm, Fredrik Lundh <[EMAIL PROTECTED]> wrote: > BJ Swope wrote: > > given a list such as > > > ['messages', 'recipients', 'viruses'] > > > how would I iterate over the list and use the values as variables and > > open the variable names a files? > > > I tried > > > for outfile in ['me

Re: python recursive function

2008-01-11 Thread Chris
On Jan 11, 10:30 am, Tom_chicollegeboy <[EMAIL PROTECTED]> wrote: > here is what I have to do: > > This question involves a game with teddy bears. The game starts when I > give you some bears. You then start giving me back some bears, but you > must follow these rules (where n is the number of bear

Re: alternating string replace

2008-01-11 Thread Chris
On Jan 9, 12:34 pm, cesco <[EMAIL PROTECTED]> wrote: > Hi, > > say I have a string like the following: > s1 = 'hi_cat_bye_dog' > and I want to replace the even '_' with ':' and the odd '_' with ',' > so that I get a new string like the following: > s2 = 'hi:cat,bye:dog' > Is there a common recipe t

Re: reading a specific column from file

2008-01-11 Thread Chris
On Jan 11, 2:15 pm, cesco <[EMAIL PROTECTED]> wrote: > Hi, > > I have a file containing four columns of data separated by tabs (\t) > and I'd like to read a specific column from it (say the third). Is > there any simple way to do this in Python? > > I've found quite interesting the linecache module

Re: Exceptions - How do you make it work like built-in exceptions?

2008-01-13 Thread Chris
On Jan 13, 4:14 pm, Lie <[EMAIL PROTECTED]> wrote: > A built-in exceptions, when raised, would print traceback that points > out the offending code, like this: > > Traceback (most recent call last): > File "F:\dir\code.py", line 43, in > a = 1/0 <<<--- > ZeroDivisionError: integer division o

Re: no pass-values calling?

2008-01-15 Thread Chris
On Jan 16, 7:59 am, "J. Peng" <[EMAIL PROTECTED]> wrote: > On Jan 16, 2008 1:45 PM, Dennis Lee Bieber <[EMAIL PROTECTED]> wrote: > > > On Wed, 16 Jan 2008 11:09:09 +0800, "J. Peng" <[EMAIL PROTECTED]> > > > alist = [] > > anint = 2 > > astr = "Touch me" > > > dummy(alist, anint, astr) > > >

Re: Loop in a loop?

2008-01-17 Thread Chris
On Jan 17, 2:35 pm, [EMAIL PROTECTED] wrote: > On Jan 17, 1:21 pm, Sacred Heart <[EMAIL PROTECTED]> wrote: > > > > > Hi, > > I'm new to Python and have come across a problem I don't know how to > > solve, enter com.lang.python :) > > > I'm writing some small apps to learn the language, and I like i

Re: too long float

2008-01-17 Thread Chris
On Jan 18, 7:55 am, "J. Peng" <[EMAIL PROTECTED]> wrote: > hello, > > why this happened on my python? > > >>> a=3.9 > >>> a > > 3.8999 > > I wanted 3.9 but got 3.89 > How to avoid it? thanks. > > this is my python version: > > >>> sys.version > > '2.3.4 (#1, Feb 6 2006,

Re: Filtering two files with uncommon column

2008-01-18 Thread Chris
cept IndexError: print 'Not enough delimiters in line.' try: f2_col2 = file2_line.split(' ')[2] except IndexError: print 'Not enough delimiters in line.' if f1_col2 != f2_col2: outfile_data_to_relevant_files() file1_line = file1.next() file2_line = file2.next() HTH Chris -- http://mail.python.org/mailman/listinfo/python-list

Re: Filtering two files with uncommon column

2008-01-18 Thread Chris
On Jan 18, 12:08 pm, Madhur <[EMAIL PROTECTED]> wrote: > On Jan 18, 2:37 pm, Chris <[EMAIL PROTECTED]> wrote: > > > > > On Jan 18, 11:23 am, Madhur <[EMAIL PROTECTED]> wrote: > > > > I would like to know the best way of generating filter of tw

Re: Broke my IDLE!

2008-02-05 Thread Chris
On Feb 5, 7:05 pm, "Adam W." <[EMAIL PROTECTED]> wrote: > Tried running IDEL from the command prompt to get this: > > Traceback (most recent call last): > File "c:\Python25\Lib\idlelib\idle.pyw", line 21, in > idlelib.PyShell.main() > File "c:\Python25\lib\idlelib\PyShell.py", line 1404, i

Re: Chinese character error

2008-02-08 Thread Chris
On Feb 8, 11:29 am, John Deas <[EMAIL PROTECTED]> wrote: > Hi, > > I made a small script to recursively copy files from a directory tree > to an exportDir only if they have an mp3 extension : > > a=os.walk(os.getcwd()) > for root, dirs, files in a: > for currFile in files: >

Re: Python Beginner needs help with for loop

2008-02-10 Thread Chris
On Feb 10, 8:06 am, "[EMAIL PROTECTED]" <[EMAIL PROTECTED]> wrote: > Hi, I'm trying to write a for loop in place of the string > method .replace() to replace a character within a string if it's > found. > > So far, I've got > > s = raw_input("please enter a string: ") > c = raw_input("please enter

Re: How to access object attributes given a string

2008-02-12 Thread Chris
On Feb 12, 10:25 pm, Santiago Romero <[EMAIL PROTECTED]> wrote: > Hi... > > I'm trying to guess how to access attributes of an existing object > given the attribute name in a string. I mean: > > class Object: > self.x = 12 > self.y = 20 > self.name = "blah" > > def ChangeAttribute( o

Re: Dynamic method parameter access?

2008-02-12 Thread Chris
On Feb 12, 9:38 pm, Dennis Kempin <[EMAIL PROTECTED]> wrote: > Hello, > > I have a set of some objects. With these objects I want to call a Python > method. But the writer of the method shall have the option to select > from these objects as method parameter. > > At the moment i use the following w

Re: CSV Reader

2008-02-12 Thread Chris
On Feb 12, 12:21 pm, Mike P <[EMAIL PROTECTED]> wrote: > I did just try to post, but it doesn't look like it has appeared? > > I've used your advice Andrew and tried to use the CSV module, but now > it doesn't seem to pick up the startswith command? > Is this because of the way the CSV module is re

Re: ways to declare empty set variable

2008-02-12 Thread Chris
On Feb 12, 3:45 pm, "Sun" <[EMAIL PROTECTED]> wrote: > Maybe this is a very primative question, but I just get a bit confused about > 'set' and 'Set' module in python. > > I understand 'set' is a build in type in python after 2.4(or 2.3) and Set a > seperate module, anyhow, I gonna use build in 'se

Re: No Module Named pstats

2008-02-13 Thread Chris
On Feb 13, 11:20 am, "Juha S." <[EMAIL PROTECTED]> wrote: > Hi, > > I'm trying to use the Python profilers to test my code, but I get the > following output for cProfile.run() at the interpreter: > > Traceback (most recent call last): > File "", line 1, in > File "/usr/lib/python2.5/cProfile.p

Re: Basic question

2008-02-13 Thread Chris
On Feb 13, 2:22 pm, "WILLIAM SCHMIDT" <[EMAIL PROTECTED]> wrote: > In several places in the Python documentation I have run across an extra "r" > that I can not explain: > > * > In sys.path after the open bracket: >sys.path = [r'd:\temp'] > > In the on line help

Re: fromfunc functions

2008-02-13 Thread Chris
On Feb 13, 5:51 pm, azrael <[EMAIL PROTECTED]> wrote: > I came across the fromfunc() function in numpy where you pass as an > argument the name of a function as a string and also the atributes for > the desired function. > > I find this extremly usefull and sexy. Can someone point me how write > a

Re: fromfunc functions

2008-02-13 Thread Chris
On Feb 13, 5:51 pm, azrael <[EMAIL PROTECTED]> wrote: > I came across the fromfunc() function in numpy where you pass as an > argument the name of a function as a string and also the atributes for > the desired function. > > I find this extremly usefull and sexy. Can someone point me how write > a

Re: Cannot understand error message

2008-02-13 Thread Chris
It doesn't like all that text in the previous one... Just before s = '' you have 4 double quotes to close to doc-string instead of 3. -- http://mail.python.org/mailman/listinfo/python-list

Re: Cannot understand error message

2008-02-13 Thread Chris
On Feb 13, 7:29 pm, "Bill Davy" <[EMAIL PROTECTED]> wrote: > The following code produces an error message (using Idle with Py 2.4 and > 2.5). "There's an error in your program: EOL while scanning single-quoted > string". It comes just after "s = ''" (put there to try and isolate the > broken stri

Re: Cannot understand error message

2008-02-13 Thread Chris
what would also be good? If you didn't expect people to read > over 500 lines of code to find YOUR problem, because you can't be > bothered to isolate the error. > > When you have a problem, send the SMALLEST piece of code the exhibits the > problem, not the entire app

Re: Looking for a Python Program/Tool That Will Add Line Numbers to a txt File

2008-02-13 Thread Chris
On Feb 14, 8:54 am, "W. Watson" <[EMAIL PROTECTED]> wrote: > See Subject. It's a simple txt file, each line is a Python stmt, but I need > up to four digits added to each line with a space between the number field > and the text. Perhaps someone has already done this or there's a source on > the we

Re: Looking for a Python Program/Tool That Will Add Line Numbers to a txt File

2008-02-14 Thread Chris
On Feb 14, 1:29 pm, John Machin <[EMAIL PROTECTED]> wrote: > On Feb 14, 6:13 pm, Chris <[EMAIL PROTECTED]> wrote: > > > > > On Feb 14, 8:54 am, "W. Watson" <[EMAIL PROTECTED]> wrote: > > > > See Subject. It's a simple txt file, each l

Re: How to tell if I'm being run from a shell or a module

2008-02-14 Thread Chris
On Feb 14, 7:21 pm, [EMAIL PROTECTED] wrote: > Hi all, > > Is there any standard way to tell if the user is running from a module > or from an interactive shell like IDLE or IPython? The best I've come > up with so far is for a function to look at > getouterframes(currentframe())[1][1] (the filenam

Re: newbie question: converting csv to another dialect

2008-02-15 Thread Chris
On Feb 15, 1:11 pm, Albert-jan Roskam <[EMAIL PROTECTED]> wrote: > Hi all, > > I have a csv file with tab as a delimiter. I want to > convert it into one that is comma delimited. I changed > the regional settings on my computer to US. > > At first I thought I could use the CSV module for > this, by

Re: linux disc space

2008-02-15 Thread Chris
hose values as a variable. > I also looked at os.statvfs(), but that output doesn't seem to make > any sense at all to me, knowing the size of the disc. > Thanks for your help! > R.D. import os, statvfs s = os.statvfs(".") freebytes = s[statvfs.F_BSIZE] * s[statvfs.F_BAVAIL] HTH, Chris -- http://mail.python.org/mailman/listinfo/python-list

Re: psycopg2: connect copy_from and copy_to

2008-02-19 Thread Chris
On Feb 19, 6:23 pm, Thomas Guettler <[EMAIL PROTECTED]> wrote: > > Doesn't PostGres come with Export/Import apps ? That would be easiest > > (and faster). > > Yes, you can use "pg_dump production ... | psql testdb", but > this can lead to dead locks, if you call this during > a python script which

Re: psycopg2: connect copy_from and copy_to

2008-02-19 Thread Chris
On Feb 19, 5:06 pm, Thomas Guettler <[EMAIL PROTECTED]> wrote: > Hi, > > I want to copy data from a production database to > a testing database. Up to now I used psycopg2 and > copy_from and copy_to with two cursors and a temporary file. > > This works, but it would be better, if the data > gets pi

Re: how to finish a while loop...

2008-02-20 Thread Chris
On Feb 20, 3:42 am, richie <[EMAIL PROTECTED]> wrote: > On Feb 20, 9:35 am, icarus <[EMAIL PROTECTED]> wrote: > > > > > > To the original poster what environment are you running this in? > > > Linux. Xubuntu if that matters. > > > > When I put your program in notepad and run it fro

Re: print help content in a Command Prompt

2008-02-25 Thread Chris
On Feb 25, 11:15 am, [EMAIL PROTECTED] wrote: > Hi, > This is a basic problem, but I want to print help content in a Command > Prompt in WinXP and scrolling back to see the first lines. If I start > a command prompt and run python, and then for example, > > >>> help(list) > > it starts showing the

Re: Large file support >2/4GB ?

2008-02-25 Thread Chris
On Feb 25, 12:35 pm, robert <[EMAIL PROTECTED]> wrote: > Somebody who uses my app gets a error : > > os.stat('/path/filename') > > OSError: [Errno 75] Value too large for defined data type: > '/path/filename' > > on a big file >4GB > > ( Python 2.4.4 / Linux ) > > How about that? Does Python not su

anydbm safe for simultaneous writes?

2008-02-27 Thread chris
probably be fine, but I have no idea if they are "write safe" (I have no experience with the underlying unix stuff). Any tips appreciated. Thanks, Chris -- http://mail.python.org/mailman/listinfo/python-list

Re: anydbm safe for simultaneous writes?

2008-02-28 Thread chris
On Feb 28, 7:47 am, "Brian Smith" <[EMAIL PROTECTED]> wrote: > Chris wrote: > > I need simple data persistence for a cgi application that > > will be used potentially by multiple clients simultaneously. > > So I need something that can handle locking among

Re: Command line arguments in Windows

2008-03-03 Thread Chris
On Mar 4, 7:12 am, "Mike Walker" <[EMAIL PROTECTED]> wrote: > I am having some problems with command line arguments in Windows. The same > code under Linux works fine. > > In Windows I only get one argument no matter how many arguments are passed > on the command line. I think there is some problem

Re: Command line arguments in Windows

2008-03-04 Thread Chris
On Mar 4, 8:38 am, "Mike Walker" <[EMAIL PROTECTED]> wrote: > > If you run a python file, ie. just double clicking it the only > > argument you will have will be the filename of the script. If you > > create a shortcut to the script and in the target box add your > > arguments (if you have quotati

sqlite3 permission issue

2008-03-04 Thread chris
sume). I chmodded the db file to 666, but it did not help. Any ideas? Thanks, Chris -- http://mail.python.org/mailman/listinfo/python-list

Re: sqlite3 permission issue

2008-03-04 Thread chris
On Mar 4, 3:10 pm, chris <[EMAIL PROTECTED]> wrote: > I am trying to execute an update to a sqlite3 db via a python cgi > script. I can execute a select via a cgi script, but when I attempt > an update, I get an "unable to open database file" error. But the > error c

Re: What c.l.py's opinions about Soft Exception?

2008-03-10 Thread Chris
If all you wanted was some grouping of exceptions why not something like... soft_exception_list = [IndexError, TypeError] hard_exception_list = [ZeroDivision] try: do_something() except Exception, e: if e.__class__ in soft_exception_list: handle_soft_exception() elif e.__class

Re: Why does my compiler say invalid syntax then highlight...?

2008-03-11 Thread Chris
On Mar 11, 5:44 am, Nathan Pinno <[EMAIL PROTECTED]> wrote: > Why does my compiler say invalid syntax and then highlight the > quotation marks in the following code: > > # This program is to find primes. > primes = [] > import math > import gmpy > while 1: >     run = int(raw_input("Do you want to

Re: Creating a file with $SIZE

2008-03-12 Thread Chris
On Mar 12, 12:32 pm, "k.i.n.g." <[EMAIL PROTECTED]> wrote: > Hi All, > > I would like create files of different size, taking size as user > input. I need to check the data transfer rates from one network to > another . In order to do this I will have to create files of diff size > and work out. I a

Re: Creating a file with $SIZE

2008-03-12 Thread Chris
On Mar 12, 12:52 pm, Chris <[EMAIL PROTECTED]> wrote: > On Mar 12, 12:32 pm, "k.i.n.g." <[EMAIL PROTECTED]> wrote: > > > Hi All, > > > I would like create files of different size, taking size as user > > input. I need to check the data transfer ra

Re: Different results when running script from IDLE versus Command Line

2008-03-12 Thread Chris
On Mar 12, 8:10 pm, Casey T <[EMAIL PROTECTED]> wrote: > Hi, > > I'm new to Python and I'm having some problems with getting different > results from my script when I run it from IDLE versus just double- > clicking the .py file and having it run through the command line. > Basically, my script read

Re: copying all data(tags and values) after a particular XML tag

2008-03-12 Thread Chris
On Mar 13, 8:21 am, [EMAIL PROTECTED] wrote: > i've an XML file with the following structure > > > > > . > . > . > . > . > > > > what i want to do is copy all data(tags and all) between N and N+k > appearances of . I am a python newbie. How do I do it? > > Thanks. You can take a look at t

Re: List mutation method gotcha - How well known?

2008-03-13 Thread Chris
On Mar 13, 9:36 am, "Hendrik van Rooyen" <[EMAIL PROTECTED]> wrote: > Hi, > > I am surprised that it took me so long to bloody my nose on this one. > > It must be well known - and I would like to find out how well known. > > So here is a CLOSED BOOK multiple choice question - no RTFM, > no playing

Re: Need Script For read multiple files(.txt) from a folder

2008-03-13 Thread Chris
On Mar 14, 6:28 am, jai_python <[EMAIL PROTECTED]> wrote: > hi frenz I  Need a Python Script For read multiple files(.txt) from a > folder and write it in a single text file > > Thanks Take a look at the OS Module for the listdir funtion, you can use it to build a list of all files in the give

Re: Need Script For read multiple files(.txt) from a folder

2008-03-14 Thread Chris
On Mar 14, 8:36 am, Dennis Lee Bieber <[EMAIL PROTECTED]> wrote: > On Thu, 13 Mar 2008 21:28:18 -0700 (PDT), jai_python > <[EMAIL PROTECTED]> declaimed the following in comp.lang.python: > > > hi frenz I  Need a Python Script For read multiple files(.txt) from a > > folder and write it in a single

Re: finding items that occur more than once in a list

2008-03-18 Thread Chris
On Mar 18, 11:57 am, Simon Forman <[EMAIL PROTECTED]> wrote: > Is there a more efficient way to do this? > > def f(L): >     '''Return a set of the items that occur more than once in L.''' >     L = list(L) >     for item in set(L): >         L.remove(item) >     return set(L) > > |>> f([0, 0, 1, 1

Re: A question about a metacharacter

2008-03-20 Thread Chris
On Mar 20, 1:19 pm, igbt <[EMAIL PROTECTED]> wrote: > I am creating a simple script which is using gtk. In this script you > must enter a text, if you do not enter anything or you enter a dot, > the script will be finished. However, if you don't enter anything the > script works but if you enter a

Re: Break large file down into multiple files

2009-02-13 Thread Chris
On Feb 13, 10:02 am, redbaron wrote: > > New to python I have a large file that I need to break up into > > multiple smaller files. I need to break the large file into sections > > where there are 65535 lines and then write those sections to seperate > > files. > > If your lines are variable-l

Re: Break large file down into multiple files

2009-02-13 Thread Chris
On Feb 13, 1:19 pm, Chris wrote: > On Feb 13, 10:02 am, redbaron wrote: > > > > > > New to python I have a large file that I need to break up into > > > multiple smaller files. I need to break the large file into sections > > > where there are 65535

Re: Delete lines which contain string in a file

2009-02-19 Thread Chris
On Feb 19, 12:24 am, Steve Holden wrote: > Rudi Goldman wrote: > > Hi, > > Go easy on me as I am a new to Python and am trying to solve a practical > > problem that is driving me bananas. > > Basically I have 2 text files, a source and a target. I want to be able > > to delete all of the lines in

Re: Checking a string against multiple matches

2008-12-02 Thread Chris
On Dec 2, 3:01 am, alex23 <[EMAIL PROTECTED]> wrote: > On Dec 2, 5:31 am, Aaron Scott <[EMAIL PROTECTED]> wrote: > > > I was using .index on the > > list, but it would return True for strings that contained the search > > string rather than match it exactly, leading to false positives in my > > cod

Re: separate shared libraries or different Linux/Unix

2008-11-04 Thread chris
> > Just don't even think of passing --enable-shared to Python's configure, > and it will all work fine, and you won't need to use ldconfig. > Well I've done --enable-shared so that I can compile mod_python as a shared object within apache. Created /etc/ld.so.conf.d/python2.5.conf on a redhat syste

Re: setting permissions to a file from linux.

2008-11-18 Thread Chris
On Nov 18, 2:36 pm, gaurav kashyap <[EMAIL PROTECTED]> wrote: > Hi all, > I have a text file in a directory on unix system. > Using a python program i want to change that file's permissions. > How could this be done. > > Thanks help(os.chmod) Help on built-in function chmod in module nt: chmod(..

Re: can error messages be improved or can they be overridden ?

2009-02-23 Thread Chris
On Feb 23, 11:57 am, Stef Mientki wrote: > thanks Ron, > > but I was looking for a more general solution, > in which I don't change the program itself, > and where the error messages (in general) become more informative than > it is by default. > > cheers, > Stef > > Barak, Ron wrote: > > Hi Stef,

Re: Caught out by daylight saving :-(

2009-03-30 Thread Chris
On Mar 30, 1:47 pm, CinnamonDonkey wrote: > Hi All, > > I had the following bit of code which was working fine until we went > into Daylight saving this weekend, now the result is an hour out. > >     timeString = "20090330 15:45:23" > >     timeFormat = '%Y-%m-%d %H:%M:%S' > >     modificationTim

"where" in python

2009-06-04 Thread Chris
I am a newby in Python and I'm first looking for equivalent to things I already manage: IDL. For example, I want to plot a sub-set of points, selected from a bigger set by applying some filter. In my example, I want to select only the values > 0. I succeed to write 5 different ways to do this, whic

Re: do you fail at FizzBuzz? simple prog test

2008-05-12 Thread Chris
On May 11, 3:12 am, globalrev <[EMAIL PROTECTED]> wrote: > http://reddit.com/r/programming/info/18td4/comments > > claims people take a lot of time to write a simple program like this: > > "Write a program that prints the numbers from 1 to 100. But for > multiples of three print "Fizz" instead of t

Re: datamining .txt-files, library?

2008-05-15 Thread Chris
On May 15, 2:27 pm, globalrev <[EMAIL PROTECTED]> wrote: > i have a big collection of .txt files that i want to open and parse to > extract information. > > is there a library for this or maybe even built in? os.open to open the files and iterate through it and built in string functions to parse i

Re: Problem creating a shorcut

2008-05-15 Thread Chris
On May 15, 5:13 pm, Mike Driscoll <[EMAIL PROTECTED]> wrote: > Hi, > > I've had this niggling issue from time to time. I want to create a > shortcut on the user's desktop to a website that specifically loads > Firefox even if Firefox is not the default browser. > > I usually use COM as it allows ve

Re: iterate start at second row in file not first

2008-05-21 Thread Chris
On May 20, 8:34 pm, [EMAIL PROTECTED] wrote: > i have a big file with sentences, the first file of each sentence > contains a colon(:) somewher eon that line > i want to jump past that sentence. > > if all(x != ':' for x in line): > > this way i can check but i dont want to check for every line in

Re: UTF-8 and stdin/stdout?

2008-05-28 Thread Chris
On May 28, 11:08 am, [EMAIL PROTECTED] wrote: > Hi, > > I have problems getting my Python code to work with UTF-8 encoding > when reading from stdin / writing to stdout. > > Say I have a file, utf8_input, that contains a single character, é, > coded as UTF-8: > >         $ hexdump -C utf8_input >  

Re: Does this path exist?

2008-05-28 Thread Chris
On May 28, 10:59 am, [EMAIL PROTECTED] wrote: > On May 28, 3:47 am, Matt Nordhoff <[EMAIL PROTECTED]> wrote: > > > > > [EMAIL PROTECTED] wrote: > > > I wanted to ask for ways to test whether a path exists. I usually use > > > os.path.exists(), which does a stat call on the path and returns True > >

Re: A quick question

2008-05-28 Thread Chris
On May 28, 12:25 pm, "James" <[EMAIL PROTECTED]> wrote: > Hey everyone, > > I just started using python and cant figure this out, I'm trying to > make a program where someone types in a word and the program gives it > back backwards.  For example if the person puts in "cat" I want the > program to

Re: Compare 2 files and discard common lines

2008-05-29 Thread Chris
On May 29, 10:36 am, loial <[EMAIL PROTECTED]> wrote: > I have a requirement to compare 2 text files and write to a 3rd file > only those lines that appear in the 2nd file but not in the 1st file. > > Rather than re-invent the wheel I am wondering if anyone has written > anything already? How larg

Re: Formatting Output

2008-06-02 Thread Chris
On Jun 2, 9:34 am, "[EMAIL PROTECTED]" <[EMAIL PROTECTED]> wrote: > Hi, > > i am building a little script and i want to output a series of columns > more or less like this: > > 1  5  6 > 2  2  8 > 2  9  5 > > The matter is that i don't know in advance how many columns there will > be. By the way, e

Re: Shed my a light :)

2008-06-02 Thread Chris
On Jun 2, 12:35 pm, TheSaint <[EMAIL PROTECTED]> wrote: > Hi, > I using eval for quite strange reason, as long as I don't know a different > way to implement. > > An example: > > actions= ('print', 'sum', 'divide', 'myfunction') > parameters=(5, 'nothing',5.63, object) > > for routines in actions:

Re: Formatting Output

2008-06-02 Thread Chris
On Jun 2, 9:43 pm, Doug Morse <[EMAIL PROTECTED]> wrote: > On Mon, 2 Jun 2008 12:42:12 -0700 (PDT), Mensanator <[EMAIL PROTECTED]> wrote: > >  On Jun 2, 3:38 am, Chris <[EMAIL PROTECTED]> wrote: > > > On Jun 2, 9:34 am, "[EMAIL PROTECTED]" > > &g

Re: Formatting Output

2008-06-02 Thread Chris
On Jun 2, 11:34 pm, Chris <[EMAIL PROTECTED]> wrote: > On Jun 2, 9:43 pm, Doug Morse <[EMAIL PROTECTED]> wrote: > > > > > On Mon, 2 Jun 2008 12:42:12 -0700 (PDT), Mensanator <[EMAIL PROTECTED]> > > wrote: > > >  On Jun 2, 3:38 am, Chris &

Re: New variable?

2008-06-03 Thread Chris
On Jun 3, 8:40 pm, tmallen <[EMAIL PROTECTED]> wrote: > What's the proper way to instantiate a new variable? x = ""? You don't need to pre-declare your variables. Just assign them as you need them and they will take the correct type. -- http://mail.python.org/mailman/listinfo/python-list

Re: defaultdict.fromkeys returns a surprising defaultdict

2008-06-03 Thread Chris
On Jun 3, 10:11 pm, Matthew Wilson <[EMAIL PROTECTED]> wrote: > I used defaultdict.fromkeys to make a new defaultdict instance, but I > was surprised by behavior: > >     >>> b = defaultdict.fromkeys(['x', 'y'], list) > >     >>> b >     defaultdict(None, {'y': , 'x': }) > >     >>> b['x'] >     >

Re: New variable?

2008-06-03 Thread Chris
On Jun 3, 9:34 pm, "Dan Upton" <[EMAIL PROTECTED]> wrote: > On Tue, Jun 3, 2008 at 3:16 PM, tmallen <[EMAIL PROTECTED]> wrote: > > On Jun 3, 3:03 pm, Chris <[EMAIL PROTECTED]> wrote: > >> On Jun 3, 8:40 pm, tmallen <[EMAIL PROTECTED]> wrote:

Re: Help need with subprocess communicate

2008-06-04 Thread Chris
On Jun 4, 9:56 am, Dennis Lee Bieber <[EMAIL PROTECTED]> wrote: > On Tue, 3 Jun 2008 23:48:38 -0700 (PDT), [EMAIL PROTECTED] declaimed the > following in comp.lang.python: > > > Is there way to configure the stdout buffer size so that it flushes > > earlier.. > > Is there a way to make above mentio

Re: readline() & seek() ???

2008-06-05 Thread Chris
On Jun 6, 5:13 am, Kam-Hung Soh <[EMAIL PROTECTED]> wrote: > Tim Roberts wrote: > > DataSmash <[EMAIL PROTECTED]> wrote: > >> I have a text file that contains thousands of lines and each line is > >> 256 characters long. > > >> This is my task: > >> For each line in the file, move to the 25th chara

Re: import cherrypy2

2008-06-06 Thread Chris
On Jun 6, 10:22 am, luca72 <[EMAIL PROTECTED]> wrote: > Hello i can't import cherrypy2 but i don't know why this is the sys > path: > > '', '/home/pirataja/opo.net/python/lib/python2.5/site-packages/ > setuptools-0.6c7-py2.5.egg', '/home/pirataja/opo.net/python/lib/ > python2.5/site-packages/TurboG

Re: import cherrypy2

2008-06-06 Thread Chris
On Jun 6, 10:59 am, luca72 <[EMAIL PROTECTED]> wrote: > On 6 Giu, 10:31, Chris <[EMAIL PROTECTED]> wrote: > > > > > On Jun 6, 10:22 am, luca72 <[EMAIL PROTECTED]> wrote: > > > > Hello i can't import cherrypy2 but i don't know why this

Re: How to find the first space?

2008-06-09 Thread Chris
On Jun 9, 5:02 pm, Johny <[EMAIL PROTECTED]> wrote: > How can I find the first space using regex? > > For example I have text > Text=' This is a sample ' > > The last space I can remove by > Text=re.sub(r"\s(?!\w)",'',Text) > > but I do not know how to remove the first space. > Can anyone help? > >

Re: catastrophic regexp, help!

2008-06-11 Thread Chris
On Jun 11, 6:20 am, cirfu <[EMAIL PROTECTED]> wrote: > pat = re.compile("(\w* *)*") > this matches all sentences. > if fed the string "are you crazy? i am" it will return "are you > crazy". > > i want to find a in a big string a sentence containing Zlatan > Ibrahimovic and some other text. > ie ret

Re: can't assign to literal

2008-06-11 Thread Chris
On Jun 11, 10:32 am, MRAB <[EMAIL PROTECTED]> wrote: > On Jun 10, 10:57 pm, "Steven Clark" <[EMAIL PROTECTED]> wrote: > > > > for 1 in oids, vals head_oids: > > > SyntaxError: can't assign to literal > > > -- > > > 1 is a literal, you can't assign it to something. Are you trying to > > use it as a

Re: can't assign to literal

2008-06-11 Thread Chris
On Jun 12, 8:03 am, TheSaint <[EMAIL PROTECTED]> wrote: > On 01:37, giovedì 12 giugno 2008 Ethan Furman wrote: > > > Do you mean indenting, or wrapping? > > I mean fill the line by increasing spaces between words in order to get a > paragraph aligned both side, left and right on the page. > So if t

Re: get keys with the same values

2008-06-12 Thread Chris
On Jun 12, 1:48 pm, Nader <[EMAIL PROTECTED]> wrote: > On Jun 12, 1:35 pm, [EMAIL PROTECTED] wrote: > > > > > Nader: > > > > d = {('a' : 1), ('b' : 3), ('c' : 2),('d' : 3),('e' : 1),('f' : 4)} > > > I will something as : > > > d.keys(where their values are the same) > > > That's magic. > > > > With

Re: get keys with the same values

2008-06-12 Thread Chris
On Jun 12, 2:15 pm, Nader <[EMAIL PROTECTED]> wrote: > On Jun 12, 2:05 pm, Chris <[EMAIL PROTECTED]> wrote: > > > > > On Jun 12, 1:48 pm, Nader <[EMAIL PROTECTED]> wrote: > > > > On Jun 12, 1:35 pm, [EMAIL PROTECTED] wrote: > > > > > N

Re: Summing a 2D list

2008-06-12 Thread Chris
On Jun 12, 3:48 pm, Mark <[EMAIL PROTECTED]> wrote: > Hi all, > > I have a scenario where I have a list like this: > > User            Score > 1                 0 > 1                 1 > 1                 5 > 2                 3 > 2                 1 > 3                 2 > 4                 3 > 4

Re: Comments on my first script?

2008-06-12 Thread Chris
On Jun 12, 4:27 pm, Phillip B Oldham <[EMAIL PROTECTED]> wrote: > I'm keen on learning python, with a heavy lean on doing things the > "pythonic" way, so threw the following script together in a few hours > as a first-attempt in programming python. > > I'd like the community's thoughts/comments on

Re: Comments on my first script?

2008-06-13 Thread Chris
ill that cause any weird errors? > > Also, Chris, can you explain this: > a, b = line.split(': ')[:2] > > I understand the first section, but I've not seen [:2] before. That's slicing at work. What it is doing is only taking the first two elements

Re: Create list from string

2008-06-13 Thread Chris
On Jun 13, 4:15 pm, ericdaniel <[EMAIL PROTECTED]> wrote: > Hi, > > I'm new to Python and I need to do the following: > > from this:   s = "978654321" > to this :      ["978", "654", "321"] > > Any help is appreciated > > Thanks, > > Eric What you could do is iterate over the string appending the

Re: urllib (54, 'Connection reset by peer') error

2008-06-13 Thread Chris
Error: [Errno socket error] (54, 'Connection reset by peer') > > > > My script code is as follows: > - > import os > import urllib > > volume_number = 149 # The volumes number 150 to 544 > > while volume_number < 544

Pattern Matching Over Python Lists

2008-06-16 Thread Chris
Is anyone aware of any prior work done with searching or matching a pattern over nested Python lists? I have this problem where I have a list like: [1, 2, [1, 2, [1, 7], 9, 9], 10] and I'd like to search for the pattern [1, 2, ANY] so that is returns: [1, 2, [1, 2, [6, 7], 9, 9], 10] [1, 2, [6,

Re: How to catch StopIteration?

2008-06-16 Thread Chris
On Jun 17, 5:50 am, [EMAIL PROTECTED] wrote: > I'm writing to see calcuration process. > And so, I can't catch StopIteration... > > What is mistake? > > def collatz(n): >   r=[] >   while n>1: >     r.append(n) >     n = 3*n+1 if n%2 else n/2 >     yield r > > for i, x in enumerate(collatz(13)): >

Re: How to catch StopIteration?

2008-06-16 Thread Chris
On Jun 17, 8:43 am, Chris <[EMAIL PROTECTED]> wrote: > On Jun 17, 5:50 am, [EMAIL PROTECTED] wrote: > > > > > I'm writing to see calcuration process. > > And so, I can't catch StopIteration... > > > What is mistake? > > > def collatz(n):

Re: print problem

2008-06-17 Thread Chris
On Jun 17, 8:15 am, pirata <[EMAIL PROTECTED]> wrote: > I was trying to print a dot on console every second to indicates > running process, so I wrote, for example: > > for i in xrange(10): >     print ".", >     time.sleep(1) > > Idealy, a dot will be printed out each second. But there is nothing

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