RE: newby qn about functions

2011-01-18 Thread Joe Goldthwaite
I'm not sure I understand the question completely but maybe the function below does what you want. def lower_case(s): return “Testing Functions-lower case: ” + s.lower() print lower_case(‘AbCdEfG’) From: python-list-bounces+joe=goldthwaites@p

RE: Functions Not Fun (yet)-please help!

2011-01-16 Thread Joe Goldthwaite
Hi Kathy, The defaults only get assigned when you leave them out of the list. This will work the way you want by setting b & c to the defaults. print my_func(a) When you try this; a = "testing" b = "defaults" print my_func(a, b, c)

RE: Parsing markup.

2010-11-29 Thread Joe Goldthwaite
s+joe=goldthwaites@python.org [mailto:python-list-bounces+joe=goldthwaites@python.org] On Behalf Of MRAB Sent: Thursday, November 25, 2010 9:03 PM To: python-list@python.org Subject: Re: Parsing markup. On 26/11/2010 03:28, Joe Goldthwaite wrote: > I'm attempting to parse some basic tagged

Parsing markup.

2010-11-25 Thread Joe Goldthwaite
I'm attempting to parse some basic tagged markup. The output of the TinyMCE editor returns a string that looks something like this; This is a paragraph with bold and italic elements in itIt can be made up of multiple lines separated by pagagraph tags. I'm trying to render the paragraph int

locale and number formatting.

2010-08-03 Thread Joe Goldthwaite
I've been working with some developers on a project. Our standard number formatting for the entire web site is comma separated with no decimals. Currency is formatted with the dollar sign. This is basically how they did it; import locale def currency(value): return locale.currency(va

RE: Ascii to Unicode.

2010-07-29 Thread Joe Goldthwaite
Hi Ulrich, Ascii.csv isn't really a latin-1 encoded file. It's an ascii file with a few characters above the 128 range that are causing Postgresql Unicode errors. Those characters work fine in the Windows world but they're not the correct byte representation for Unicode. What I'm attempting to d

RE: Ascii to Unicode.

2010-07-29 Thread Joe Goldthwaite
Hi Steven, I read through the article you referenced. I understand Unicode better now. I wasn't completely ignorant of the subject. My confusion is more about how Python is handling Unicode than Unicode itself. I guess I'm fighting my own misconceptions. I do that a lot. It's hard for me to un

RE: Ascii to Unicode.

2010-07-28 Thread Joe Goldthwaite
> Hello hello ... you are running on Windows; the likelihood that you > actually have data encoded in latin1 is very very small. Follow MRAB's > answer but replace "latin1" by "cp1252". I think you're right. The database I'm working with is a US zip code database. It gets updated monthly. The p

Ascii to Unicode.

2010-07-28 Thread Joe Goldthwaite
Thanks to all of you who responded. I guess I was working from the wrong premise. I was thinking that a file could write any kind of data and that once I had my Unicode string, I could just write it out with a standard file.write() operation. What is actually happening is the file.write() operati

Ascii to Unicode.

2010-07-28 Thread Joe Goldthwaite
Hi, I've got an Ascii file with some latin characters. Specifically \xe1 and \xfc. I'm trying to import it into a Postgresql database that's running in Unicode mode. The Unicode converter chokes on those two characters. I could just manually replace those to characters with something valid but i

RE: SQLite and Python 2.4

2008-07-03 Thread Joe Goldthwaite
7;localhost' cookiedict = {} GetFirefoxCookies(domain, cookiedict) print cookiedict -Original Message- From: Guilherme Polo [mailto:[EMAIL PROTECTED] Sent: Tuesday, July 01, 2008 6:15 PM To: [EMAIL PROTECTED]; python-list@python.org Subject: Re: SQLite and Python 2.4 On T

SQLite and Python 2.4

2008-07-01 Thread Joe Goldthwaite
e way. Since I didn't get an error message, I'm thinking that I've got the wrong version for the Firefox cookies.sqlite file. I don't have a clue as to where else to look to trace it down. I'm hoping that someone here is more familiar with it and can give me some pointers. Thanks, Joe Goldthwaite -- http://mail.python.org/mailman/listinfo/python-list

RE: I'm missing something here with range vs. xrange

2007-12-10 Thread Joe Goldthwaite
>You bring up an excellent point. It might seem like I'm actually running on >a Macbook Pro with an Intel Core 2 Duo at 2.33 GHz with 2 GB of ram. Err... Uhh... What I meant to say was "It might seem like I'm running on an old slow POS but I'm actually running on a Macbook Pro..." Sorry, me fl

RE: I'm missing something here with range vs. xrange

2007-12-10 Thread Joe Goldthwaite
>You can't imagine why someone might prefer an iterative solution over >a greedy one? Depending on the conditions, the cost of creating the >list can be a greater or a lesser part of the total time spent. Actual >iteration is essentially the same cost for both. Try looking at memory >usage while yo

RE: I'm missing something here with range vs. xrange

2007-12-07 Thread Joe Goldthwaite
>90+ seconds?? What hardware, OS, and Python version? What else was >running in the background? >With this kit: >OS Name: Microsoft Windows XP Professional >Version: 5.1.2600 Service Pack 2 Build 2600 >Processor: x86 Family 15 Model 36 Stepping 2 AuthenticAMD ~1995 Mhz >Python: Pyt

RE: I'm missing something here with range vs. xrange

2007-12-07 Thread Joe Goldthwaite
ern Schliessmann Sent: Thursday, December 06, 2007 3:33 PM To: python-list@python.org Subject: Re: I'm missing something here with range vs. xrange Joe Goldthwaite wrote: > I read that the range function builds a list and that xrange > returns an iterator and is therefore more effici

RE: File to dict

2007-12-07 Thread Joe Goldthwaite
Duncan Booth wrote: >for item in list: >if item == 'searched.domain': >return item... [EMAIL PROTECTED] wrote: >Sure, but I have two options here, none of them nice: either "write C >in Python" or do it inefficient and still elaborate way. I don't understand your point at all. How

I'm missing something here with range vs. xrange

2007-12-06 Thread Joe Goldthwaite
I've been playing with Python a bit. Doing little performance benchmarks and working with Psyco. It's been fun and I've been learning a lot. For example, in a previous post, I was looking for a way to dynamically add new runtime function to a class. Martin told me to use a class instance variabl

Dynamically adding a runtime generated method to a class.

2007-11-29 Thread Joe Goldthwaite
I'm not sure how to even ask this question. I'm working on a financial reporting application. The current system is very limited in what it can display. You can see reports with columns of Period, Quarter, Year to date or you can see a yearly trend. I'd like for the users to be able to define t

RE: A question on python performance.

2007-09-27 Thread Joe Goldthwaite
[EMAIL PROTECTED] wrote: >Makes perfect sense to me! Think about it: > >method 1: looks up the method directly from the object (fastest) >method 2: looks up __class__, then looks up __dict__, then gets the >element from __dict__ >method 3: looks up caller, looks up __class__, looks up __dict__, ge

A question on python performance.

2007-09-26 Thread Joe Goldthwaite
Hi everyone, I'm a developer who's been using python for a couple of years. I wrote a fairly large application using it but I was learning the language at the same time so it most of the code kind of sucks. I've learned a lot since then and I've been going through my code trying to organize it b