Re: OT: Question about RGB color method

2007-04-10 Thread Carsten Haese
On Tue, 2007-04-10 at 15:32 -0400, John Salerno wrote: Sorry for this non-Python question, but since it's computer related I know you guys will have an answer, and I don't really know where else to ask. Mainly I'm just curious anyway. I'm wondering, why do computers use a RGB color scheme

Re: tuples, index method, Python's design

2007-04-10 Thread Carsten Haese
On Tue, 2007-04-10 at 21:23 -0700, Paul Rubin wrote: Carsten Haese [EMAIL PROTECTED] writes: You have a point. Here is my revised solution: assert current_player in p opponents = tuple(x for x in p if x is not current_player) Still wrong on two counts. First, assert is a no-op

Re: tuples, index method, Python's design

2007-04-09 Thread Carsten Haese
On Mon, 2007-04-09 at 11:50 +1000, Steven D'Aprano wrote: On Sun, 08 Apr 2007 20:10:21 -0400, Carsten Haese wrote: Will tuples also get a sort method? What about append and extend? pop? __iadd__? __delslice__? Since tuples are immutable, no. [...] If you see tuples as an immutable list

Re: doubt with importing module, given module name

2007-04-09 Thread Carsten Haese
On Mon, 2007-04-09 at 22:52 +0530, Pradnyesh Sawant wrote: Hello, I have a string which in reality is the name of a module to be imported. The name of the class contained in the module also has the same (although with different capitalization). My requirement is to import the module, and also

Re: tuples, index method, Python's design

2007-04-08 Thread Carsten Haese
On Sun, 2007-04-08 at 07:51 -0700, Paul Rubin wrote: Carsten Haese [EMAIL PROTECTED] writes: Maybe we can add such methods to the PyPy tuples for some time, to experimentally see if they make the language worse :-) Adding useless features always makes a product worse. What's your use

Re: tuples, index method, Python's design

2007-04-08 Thread Carsten Haese
On Sun, 2007-04-08 at 13:10 -0700, Paul Rubin wrote: Carsten Haese [EMAIL PROTECTED] writes: Do you not see the gratuituous inconsistency between tuples and lists as a useless feature? What is the use case for keeping it? When a new feature is requested, the burden of proof

Re: tuples, index method, Python's design

2007-04-07 Thread Carsten Haese
On Sat, 2007-04-07 at 06:45 -0700, [EMAIL PROTECTED] wrote: Carsten Haese: The lack of convincing use cases is still a pertinent reason today. Note that the original poster on this thread did not present a use case for tuple.index, they were only asking out of curiosity. If you have a use

Re: tuples, index method, Python's design

2007-04-07 Thread Carsten Haese
On Sun, 08 Apr 2007 02:40:52 GMT, Alan Isaac wrote Carsten Haese [EMAIL PROTECTED] wrote in message news:[EMAIL PROTECTED] Adding useless features always makes a product worse. What's your use case for tuple.index? [...] consider a game, where the fixed set p of players have a fixed order

Re: tuples, index method, Python's design

2007-04-06 Thread Carsten Haese
On Fri, 2007-04-06 at 11:33 -0700, 7stud wrote: On Apr 6, 7:56 am, Paul Boddie [EMAIL PROTECTED] wrote: The problem with 7stud's quote from GvR is that it's out of date: I would argue that it shows the very guy who invented the language stated publicly there was no good reason for tuples

Re: RFC: Assignment as expression (pre-PEP)

2007-04-05 Thread Carsten Haese
On Thu, 2007-04-05 at 12:51 -0700, [EMAIL PROTECTED] wrote: I would like to gauge interest in the following proposal: Problem: Assignment statements cannot be used as expressions. Performing a list of mutually exclusive checks that require data processing can cause excessive

Re: Extracting a file from a tarball

2007-04-03 Thread Carsten Haese
On Tue, 2007-04-03 at 13:26 -0400, Boudreau, Emile wrote: I am trying to extract one file from a tarball, without success. This is the code I'm using to open the tarball and extract the file: tar = tarfile.open(component+'-win32-app-'+bestVersion+'-dev.tar.gz', 'r') extractedFile =

Re: I can't get multi-dimensional array to work...

2007-03-30 Thread Carsten Haese
On Fri, 2007-03-30 at 14:34 -0700, erikcw wrote: On Mar 30, 5:23 pm, [EMAIL PROTECTED] wrote: I haven't tested it, but superficially I'd suggest giving this a try: def endElement(self, name): if name == 'row' : if not self.data.has_key(self.parent):

Re: Multi-line strings with formatting

2007-03-23 Thread Carsten Haese
On Fri, 2007-03-23 at 09:54 -0700, [EMAIL PROTECTED] wrote: When constructing a particularly long and complicated command to be sent to the shell, I usually do something like this, to make the command as easy as possible to follow: commands.getoutput( 'mycommand -S %d -T %d ' %

Re: Technical Answer - Protecting code in python

2007-03-21 Thread Carsten Haese
On Wed, 2007-03-21 at 06:36 -0700, flit wrote: Hello All, I have a hard question, every time I look for this answer its get out from the technical domain and goes on in the moral/social domain. First, I live in third world with bad gov., bad education, bad police and a lot of taxes and

Re: Technical Answer - Protecting code in python

2007-03-21 Thread Carsten Haese
On Wed, 2007-03-21 at 11:33 -0700, gtb wrote: On Mar 21, 8:36 am, flit [EMAIL PROTECTED] wrote: 2 - If I put the code in web like a web service, how can I protect my code from being ripped? There is a way to avoid someone using my site and ripping the .py files? Maybe an application for

Re: help - Module needs access to another module

2007-03-20 Thread Carsten Haese
On Tue, 2007-03-20 at 06:46 -0700, abcd wrote: I have the following directory/file structure... c:\foo\utils.py c:\foo\bar\ok.py In ok.py I want to do something like... import utils utils.helpMeDoSomething() However, it seems that ok.py doesn't know about utils. Other than

Re: mysterious unicode

2007-03-20 Thread Carsten Haese
On Tue, 2007-03-20 at 16:47 -0700, Gerry wrote: I'm still mystified why: qno was ever unicode, Thus quoth http://www.lexicon.net/sjmachin/xlrd.html This module presents all text strings as Python unicode objects. -Carsten -- http://mail.python.org/mailman/listinfo/python-list

Re: mysterious unicode

2007-03-20 Thread Carsten Haese
On Tue, 2007-03-20 at 20:26 -0400, jim-on-linux wrote: I have been getting the same thing using SQLite3 when extracting data fron an SQLite3 database. Many APIs that exchange data choose to exchange text in Unicode because that eliminates encoding uncertainty. Whether an API uses Unicode would

Re: Load three different modules which have the same name

2007-03-19 Thread Carsten Haese
On Mon, 2007-03-19 at 11:42 -0700, abcd wrote: nevermind this took care of it: import sys def tryAllThree(): a = c:\\alpha b = c:\\beta g = c:\\gamma sys.path.append(a) import Person alpha = Person.Person() sys.path.remove(a) sys.path.append(b)

Re: Writing python module in C: wchar_t or Py_UNICODE?

2007-03-16 Thread Carsten Haese
On Fri, 2007-03-16 at 04:04 -0700, Yury wrote: I am new to python and programming generally, but someday it is time to start :) I am writing a python module in C and have a question about multibyte character strings in python=C. I want a C function which takes a string as argument from python

Re: Mocking OpenOffice in python?

2007-03-14 Thread Carsten Haese
On Wed, 2007-03-14 at 01:39 -0700, PaoloB wrote: Hi everyone, during our development, we need to write some unit tests that interact with OpenOffice through pyUno. Is there anyone who has got any experience on it? As OpenOffice is quite a large beast, and interaction is rather complex, I

Re: number generator

2007-03-12 Thread Carsten Haese
On Sat, 2007-03-10 at 22:27 -0500, Terry Reedy wrote: Anton Vredegoor [EMAIL PROTECTED] wrote in message news:[EMAIL PROTECTED] | Terry Reedy wrote: | | Partitioning positive count m into n positive counts that sum to m is a | standard combinatorial problem at least 300 years old. The

RE: backslashes in lists

2007-03-12 Thread Carsten Haese
On Mon, 2007-03-12 at 18:08 +0300, Fabio Gomes wrote: Yes, Luca. I noticed that printing the list item will show the string as expected. But I need to print the entire list in the script I'm writing and doing that, the list will will be repr()'ed. Is there any way to print the entire list

Re: number generator

2007-03-09 Thread Carsten Haese
On Fri, 2007-03-09 at 07:17 -0800, cesco wrote: On Mar 9, 3:51 pm, Paul Rubin http://[EMAIL PROTECTED] wrote: cesco [EMAIL PROTECTED] writes: I have to generate a list of N random numbers (integer) whose sum is equal to M. If, for example, I have to generate 5 random numbers whose sum

Re: is this a bug? (python 2.3)

2007-03-09 Thread Carsten Haese
On Fri, 2007-03-09 at 12:32 -0800, Sean McIlroy wrote: hi all when i run this code in python 2.3 ## BEGIN CODE class warfare: def __init__(self): self.pairs = [[0,0]]*2 def __str__(self): return str(self.pairs) def setfirst (self,i,value):

Re: Is numeric keys of Python's dictionary automatically sorted?

2007-03-07 Thread Carsten Haese
On Wed, 2007-03-07 at 15:18 -0500, John wrote: I am coding a radix sort in python and I think that Python's dictionary may be a choice for bucket. The only problem is that dictionary is a mapping without order. But I just found that if the keys are numeric, the keys themselves are ordered

Re: Regex - where do I make a mistake?

2007-02-16 Thread Carsten Haese
On Fri, 2007-02-16 at 05:34 -0800, Johny wrote: On Feb 16, 2:14 pm, Peter Otten [EMAIL PROTECTED] wrote: Johny wrote: I have string=span class=test45655/span. tdspan class=test123128/span span class=test789170/span where I need to replace span class=test45655/span.

Re: python+ncurses: I can't display accents

2007-01-27 Thread Carsten Haese
On 27 Jan 2007 07:43:59 GMT, Fabrice DELENTE wrote Incidentally, I noticed something about the environment: in my script, I use the LINES and COLUMNS environment vars that are set in my shell: columns=int(os.environ.get(COLUMNS)) lines=int(os.environ.get(LINES)) In the shell, I get

Re: Rational Numbers

2007-01-12 Thread Carsten Haese
On Thu, 2007-01-11 at 23:47 +, Nick Maclaren wrote: In article [EMAIL PROTECTED], Facundo Batista [EMAIL PROTECTED] writes: | Noud Aldenhoven wrote: | | When I was programming in a mathematical project I began to wonder if python | supports rational numbers[1]. In a language like

Re: Rational Numbers

2007-01-12 Thread Carsten Haese
On Fri, 2007-01-12 at 15:05 +, Nick Maclaren wrote: In article [EMAIL PROTECTED], Carsten Haese [EMAIL PROTECTED] writes: | On Thu, 2007-01-11 at 23:47 +, Nick Maclaren wrote: | In article [EMAIL PROTECTED], | Facundo Batista [EMAIL PROTECTED] writes: | | Python does not have

Re: dynamic argument name for functions

2007-01-12 Thread Carsten Haese
On Fri, 2007-01-12 at 12:17 -0800, mark wrote: I want to pass a value to an argument of a function. The argument name is dynamic and is stored in a variable. How do I call the function using with arg_name and value as the parameters. thanks mark For ex: def function(arg1='None',

Re: dynamic argument name for functions

2007-01-12 Thread Carsten Haese
On Fri, 2007-01-12 at 20:22 +, Simon Brunning wrote: On 1/12/07, mark [EMAIL PROTECTED] wrote: I want to pass a value to an argument of a function. The argument name is dynamic and is stored in a variable. How do I call the function using with arg_name and value as the parameters.

Re: where to find the spec of format in PyObject_CallMethod

2007-01-10 Thread Carsten Haese
On Wed, 2007-01-10 at 14:05 -0800, Huayang Xia wrote: I am trying to use PyObject_CallMethod. It needs a format string to specify what are the followed arguments. Is it possible to use a PyObject* as an argument? Where can I find the spec for the format? Thanks in advance. See

Re: Maths error

2007-01-09 Thread Carsten Haese
On Tue, 2007-01-09 at 11:38 +, Nick Maclaren wrote: | Rory Campbell-Lange wrote: | | Is using the decimal module the best way around this? (I'm | expecting the first sum to match the second). It seem | anachronistic that decimal takes strings as input, though. As Dan Bishop says,

Re: Python re expr from Perl to Python

2007-01-06 Thread Carsten Haese
On Sat, 2007-01-06 at 15:43 +0100, Michael M. wrote: In Perl, it was: ## Example: Abc | def | ghi | jkl ## - Abc ghi jkl ## Take only the text betewwn the 2nd pipe (=cut the text in the 1st pipe). $na =~ s/\ \|(.*?)\ \|(.*?)\ \|/$2/g; ## -- remove [ and ] in text

Re: Turn off line wrap for lists?

2007-01-04 Thread Carsten Haese
On Thu, 2007-01-04 at 17:01 -0800, _ wrote: (I did google for this, I promise) How do I get python NOT to insert newlines into string representations of lists when I do something like this: strCollector += %s % (['a', 'list', 'with', 'lots', 'of', 'elements'] * 100) What makes you think

Re: function without brackets ?

2007-01-03 Thread Carsten Haese
On Wed, 2007-01-03 at 15:37 +0100, Stef Mientki wrote: If I call a parameterless function without brackets at the end, the function is not performed, but ... I don't get an error message ??? Is this normal behavior ? Yes. If you call a function without brackets, it's not a call. Remember

Re: Sorting on multiple values, some ascending, some descending

2007-01-03 Thread Carsten Haese
On Wed, 2007-01-03 at 10:48 -0800, dwelden wrote: I have successfully used the sort lambda construct described in http://mail.python.org/pipermail/python-list/2006-April/377443.html. However, how do I take it one step further such that some values can be sorted ascending and others descending?

Re: Special Characters (Unicode, Ascii) in Python and MySQL

2007-01-02 Thread Carsten Haese
On Mon, 2007-01-01 at 21:57 -0800, ronrsr wrote: I have an MySQL database called zingers. The structure is: zid - integer, key, autoincrement keyword - varchar citation - text quotation - text I am having trouble storing text, as typed in latter two fields. Special characters and

Re: How do I add users using Python scripts on a Linux machine

2007-01-02 Thread Carsten Haese
On Tue, 2007-01-02 at 17:17 +0100, Sebastian 'lunar' Wiesner wrote: Ravi Teja [EMAIL PROTECTED] typed Ivan Voras wrote: Ramdas wrote: Well, I need to add users from a web interface for a web server, which runs only Python. I need to add users, set quotas and in future even

Re: Missing erf()

2007-01-01 Thread Carsten Haese
On Sun, 2006-12-31 at 13:23 -0600, [EMAIL PROTECTED] wrote: rrenaud Is there a reason why erf() is not included in the math rrenaud package? According to the following URL it looks like it has rrenaud been standard C since 1999. Python is implemented in the C89 dialect. Maybe

Re: how to serve image files without disk use?

2006-12-29 Thread Carsten Haese
On Fri, 2006-12-29 at 09:30 -0600, Chris Mellon wrote: On 12/28/06, Ray Schumacher [EMAIL PROTECTED] wrote: s = socket.socket(socket.AF_INET, socket.SOCK_STREAM) s.bind((HOST, PORT)) s.listen(1) conn, addr = s.accept() while 1: data = conn.recv(1024) if data[:3] == 'GET':

Re: Getting VideoCapture to work with Python 2.5

2006-12-29 Thread Carsten Haese
On Fri, 2006-12-29 at 19:15 +, Just Another Victim of the Ambient Morality wrote: I can't seem to get VideoCapture (http://videocapture.sourceforge.net/) to work with my version of Python (2.5). Why is that? I've followed the instructions which made it look easy but, as it happens

Re: How to return a simple variable from a function (still newbie) ?

2006-12-28 Thread Carsten Haese
On Thu, 2006-12-28 at 16:14 +0100, Stef Mientki wrote: I want to return a simple variable from a function, not using the function result. Is that in any way possible ?? The code below is from O'Reilly, Learning Python, and there seems no way to return a simple var like z in the example

Re: How to return a simple variable from a function (still newbie) ?

2006-12-28 Thread Carsten Haese
On Thu, 2006-12-28 at 15:28 +, Paul Hummer wrote: You'd have to either pass the variables by reference into the function, [...] In Python, all function calls are call by reference. Period. The key difference between Python and other programming languages is in the behavior of the assignment

Re: How to return a simple variable from a function (still newbie) ?

2006-12-28 Thread Carsten Haese
On Thu, 2006-12-28 at 19:49 +0100, Stef Mientki wrote: [...] When I replace the assignment to filter_prev, by a loop, the function works as expected. Python #filter_prev = Extended [ len(Signal_IN) : ] for i in range( len(filter_prev )): filter_prev[i] = Extended [ len(Signal_IN)

Re: how can I modify an imported variable ?

2006-12-27 Thread Carsten Haese
On Wed, 2006-12-27 at 18:10 +, yomgui wrote: actually, it is not linked to threading but to the scope. the second attempt to access MyPackage.aVariable is inside the __init__ of a class and this seems to be the problem. I believe it is a genuine python bug. Please post a minimal but

Re: Passing variable number of named arguments

2006-12-27 Thread Carsten Haese
On Wed, 2006-12-27 at 10:37 -0800, Ramashish Baranwal wrote: [...] def fun2(**kwargs): # get id param id = kwargs.pop('id', '') # pass on remaining to fun1 fun1(kwargs) When I try to call fun2 I get the following error- TypeError: fun1() takes exactly 0 arguments (1

Re: Superclass for Errors?

2006-12-27 Thread Carsten Haese
On Wed, 2006-12-27 at 12:13 -0800, tac-tics wrote: I have a program which has a GUI front-end which that runs a separate thread to handle all the important stuff. However, if there is a problem with the important stuff, I want the GUI to raise a MessageBox alert to indicate this. For

Re: How to stop program when threads is sleeping

2006-12-26 Thread Carsten Haese
On 25 Dec 2006 21:50:15 -0800, many_years_after wrote While , there is something wrong in my expression. What I mean is the thread will wait some time after doing some tasks. I want to know is there any method to end the thread or make it out of execution of waiting. I use time.sleep() to let

Re: Q: How to generate code object from bytecode?

2006-12-26 Thread Carsten Haese
On Tue, 2006-12-26 at 11:15 -0800, [EMAIL PROTECTED] wrote: Hi, It is possible to get bytecode from code object. Reversely, is it possible to create code object from bytecode? ex. ## python code (not a module) pycode = '''\ print ul\n for item in items: print li%s/li\n %

Re: Q: How to generate code object from bytecode?

2006-12-26 Thread Carsten Haese
On Tue, 2006-12-26 at 14:48 -0500, Carsten Haese wrote: * Code objects come in two flavors: statements and expressions. * exec can execute a 'statement' flavored code object. * eval can evaluate an 'expression' flavored code object. * Your code snippet is a statement, actually, a suite

Re: Fuzzy string comparison

2006-12-26 Thread Carsten Haese
On Tue, 2006-12-26 at 13:08 -0800, John Machin wrote: Wojciech Mula wrote: Steve Bergman wrote: I'm looking for a module to do fuzzy comparison of strings. [...] Check module difflib, it returns difference between two sequences. and it's intended for comparing text files, and is

Re: How to stop program when threads is sleeping

2006-12-25 Thread Carsten Haese
On Sun, 2006-12-24 at 22:55 -0800, many_years_after wrote: Hi, pythoners: There is a problem I couldn't dispose. I start a thread in the my program. The thread will do something before executing time.sleep(). When the user give a signal to the main thread (such as click the 'end'

Re: How a script can know if it has been called with the -i command line option?

2006-12-21 Thread Carsten Haese
On Thu, 2006-12-21 at 11:22 -0800, [EMAIL PROTECTED] wrote: Michele Simionato wrote: The subject says it all, I would like a script to act differently when called as $ python script.py and when called as $ python -i script.py. I looked at the sys module but I don't see a way to retrieve

Re: TypeError: cannot concatenate 'str' and 'NoneType' objects

2006-12-20 Thread Carsten Haese
On Wed, 2006-12-20 at 20:22 +0100, Fredrik Lundh wrote: [EMAIL PROTECTED] wrote: I'm extremely new to Python and programming as a whole. I have written a python script with the assistance of ESRI ArcGIS 9.2, which uses Python 2.4.1, however, it gives me this error when I try to run it.

Re: TypeError: cannot concatenate 'str' and 'NoneType' objects

2006-12-20 Thread Carsten Haese
On Wed, 2006-12-20 at 11:33 -0800, Mark Peters wrote: Warning: I know nothing about the Python ArcGIS stuff. The first thing that jumps out at me is your while condition. You are testing Townshps when it seems from the code that you should be testing Townshp. However, the typical Python

Re: Roundtrip SQL data especially datetime

2006-12-16 Thread Carsten Haese
On Sat, 2006-12-16 at 20:48 +, John Nagle wrote: The SourceForge page http://sourceforge.net/project/showfiles.php?group_id=22307 says MySQL versions 3.23-5.0; and Python versions 2.3-2.4 are supported. Last release was April, 2006. There's no binary for Python 2.5

Re: Roundtrip SQL data especially datetime

2006-12-15 Thread Carsten Haese
On Sat, 2006-12-16 at 04:27 +, dyork wrote: John Machin [EMAIL PROTECTED] wrote in message news:[EMAIL PROTECTED] I suppose it all depends on your definition of obvious :-) I was looking for a constructor that was the complement of str(). Most/many languages would provide that.

Re: Non greedy regex

2006-12-14 Thread Carsten Haese
On Thu, 2006-12-14 at 06:45 -0800, [EMAIL PROTECTED] wrote: Can someone please explain why these expressions both produce the same result? Surely this means that non-greedy regex does not work? print re.sub( 'a.*b', '', 'ababc' ) gives: 'c' Understandable. But print re.sub( 'a.*?b',

Re: tuple.index()

2006-12-14 Thread Carsten Haese
On Thu, 2006-12-14 at 15:57 +, Nick Maclaren wrote: In article [EMAIL PROTECTED], Fredrik Lundh [EMAIL PROTECTED] writes: | | The point is that an index method makes sense on ANY data structure that | can be subscripted by an integer value but, for reasons that aren't at | all clear,

Re: how to convert a function into generator?

2006-12-06 Thread Carsten Haese
On Wed, 2006-12-06 at 17:33 +0100, Schüle Daniel wrote: def permute3gen(lst): lenlst = len(lst) def permute(perm, level): if level == 1: yield perm return # not sure return without a value is allowed, theoretically it could be replaces with

Re: Why not just show the out-of-range index?

2006-12-04 Thread Carsten Haese
On Mon, 2006-12-04 at 01:04 -0800, Russ wrote: Robert Kern wrote: Nothing is going to happen until you do one of these two things. Being more rude (and yes, you are being incredibly rude and insulting) won't move things along. I re-read the thread, and I don't see anywhere where I

Re: Why not just show the out-of-range index?

2006-12-04 Thread Carsten Haese
On Mon, 2006-12-04 at 08:49 -0800, [EMAIL PROTECTED] wrote: Carsten Haese wrote: On Mon, 2006-12-04 at 01:04 -0800, Russ wrote: Robert Kern wrote: Nothing is going to happen until you do one of these two things. Being more rude (and yes, you are being incredibly rude

Re: decorators question

2006-12-04 Thread Carsten Haese
On Mon, 2006-12-04 at 14:03 -0800, king kikapu wrote: I recap: if i put only functions declarations on a .py file, like these: def A(): print a def B(): print b def C(): print c and run the program, nothing happens, nothing executed. Nothing *visible* happens. The def statements *do* get

Re: decorators question

2006-12-04 Thread Carsten Haese
On Mon, 2006-12-04 at 23:44 +0100, Fredrik Lundh wrote: Carsten Haese wrote: * The function body gets compiled into byte code (but not executed). careful: when you get as far as executing the def statement, the function body has already been compiled. the byte code for the function

[ANN] InformixDB-2.4 released

2006-12-01 Thread Carsten Haese
opaque types in their binary representation Downloads and info at http://informixdb.sourceforge.net Best regards, Carsten Haese -- http://mail.python.org/mailman/listinfo/python-list

Re: Inheritance from builtin list and override of methods.

2006-11-27 Thread Carsten Haese
On Mon, 2006-11-27 at 19:14 +, OKB (not okblacke) wrote: Duncan Booth wrote: And is there a mechanism in Python that will allow me to override the operators of a class, for all its occurrences, even the ones implemented on C built-in objects? No. For what it's worth,

RE: String Replace only if whole word?

2006-11-17 Thread Carsten Haese
On Fri, 2006-11-17 at 10:43 -0500, Michael Yanowitz wrote: Your pattern would be [^A-Za-z0-9_]word[^A-Za-z0-9_] -- Juho Schultz Thanks. This works great except for one thing: The character after the replacement is deleted, so that if I have send_data (LAPTOP, test_string)

Re: Decimal() instead of float?

2006-11-17 Thread Carsten Haese
On Fri, 2006-11-17 at 16:51 -0500, Michael B. Trausch wrote: [...] Let's say that I want to work with the latitude 33.6907570. In Python, that number can not be stored exactly without the aid of decimal.Decimal(). 33.6907570 33.6907568 You say that like it's Python's fault. Can

Re: Decimal() instead of float?

2006-11-17 Thread Carsten Haese
On Fri, 2006-11-17 at 16:51 -0500, Michael B. Trausch wrote: On Fri, 2006-11-17 at 21:25 +0100, Fredrik Lundh wrote: Some of the lat/long pairs that I have used seem to come out fine, but some do not. Because the mathmatics used with them involve complex equations when determining

Re: Yield

2006-11-16 Thread Carsten Haese
On Thu, 2006-11-16 at 07:32 -0800, Danny Colligan wrote: Carsten mentioned that generators are more memory-efficient to use when dealing with large numbers of objects. Is this the main advantage of using generators? Also, in what other novel ways are generators used that are clearly superior

Re: Yield

2006-11-16 Thread Carsten Haese
On Thu, 2006-11-16 at 08:09 -0800, Danny Colligan wrote: The more trivial the example, the harder it is to see the advantage. I absoultely agree. Thanks for pointing me out to some real-world code. However, the function you pointed me to is not a generator (there is no yield statement...

Re: atexit.register does not return the registered function. IMHO, it should.

2006-11-16 Thread Carsten Haese
On Thu, 2006-11-16 at 08:03 -0800, [EMAIL PROTECTED] wrote: @atexit.register def goodbye(): print Goodbye, terminating... However, there is one fundamental problem with this: atexit.register() returns None. Since the above code corresponds to:: def goodbye(): print

Re: Yield

2006-11-15 Thread Carsten Haese
On Wed, 2006-11-15 at 09:13 -0800, Mateuszk87 wrote: Hi. may someone explain yield function, please. how does it actually work and when do you use it? [There is probably a much better explanation of this somewhere on the net already, but I feel like writing this out myself.] yield is a

Re: Noob | datetime question

2006-11-14 Thread Carsten Haese
On Tue, 2006-11-14 at 09:33 -0600, Kevin Kelley wrote: import time FORMAT='%Y%m%d' time.strftime(FORMAT,time.gmtime(time.time()+8380800)) output = '20070219' While the above works, the following variation using datetime is more readable: import datetime someday = datetime.date.today() +

Re: jython's future (was: Python development time is faster.)

2006-11-13 Thread Carsten Haese
On Mon, 2006-11-13 at 18:34 +0100, Stefan Behnel wrote: Honestly, how many important Python modules do still run on 2.2? InformixDB still compiles on 2.2 except when I accidentally temporarily break backwards compatibility. Of course it's a matter of opinion whether it qualifies as an important

Re: Is python for me?

2006-11-13 Thread Carsten Haese
On Mon, 2006-11-13 at 10:14 -0800, Dan Lenski wrote: lennart wrote: So i ask myself is python the language I'm looking for? Yep! Python is very much a jack-of-all-trades language. I'll run the risk of being nitpicky, but the full phrase is Jack of all trades, master of none, which doesn't

Re: Fredrik Lundh [was Re: explicit self revisited]

2006-11-12 Thread Carsten Haese
On Sat, 2006-11-11 at 23:14 -0800, Doug wrote: Fredrik Lundh wrote: Doug wrote: Fredrik Lundh wrote: Fredrik Lundh wrote: cannot all you clueless trolls who cannot think of a single useful thing to contribute to Python start your own newsgroup? and before anyone complains;

Re: Py3K idea: why not drop the colon?

2006-11-12 Thread Carsten Haese
On Sat, 2006-11-11 at 23:18 -0800, Doug wrote: Michael Hobbs wrote: I think the colon could be omitted from every type of compound statement: 'if', 'for', 'def', 'class', whatever. Am I missing anything? Thanks, - Mike It is a very good idea as the colon is technically redundant (not

Re: decorators

2006-11-08 Thread Carsten Haese
On Wed, 2006-11-08 at 12:37 -0800, John Henry wrote: I must be very thick. I keep reading about what decorators are and I still don't have a good feel about it. See, for example: http://alex.dojotoolkit.org/?p=564 and: http://soiland.no/software/decorator What exactly do I use

Re: what's the difference between these two methods? (aka, why doesn't one of them work?)

2006-11-02 Thread Carsten Haese
On Thu, 2006-11-02 at 12:28 -0800, JohnJSal wrote: Can someone explain to me why the first version of this method works, but the second one doesn't? All I've changed (I think) is how the information is nested. The error I'm getting is that the call to xrc.XRCCTRL is not working in the second

Re: what's the difference between these two methods? (aka, why doesn't one of them work?)

2006-11-02 Thread Carsten Haese
On Thu, 2006-11-02 at 13:14 -0800, JohnJSal wrote: JohnJSal wrote: JohnJSal wrote: Peter Otten wrote: ...the above is not a 1-tuple, but an ordinary string. You forgot the trailing comma: ('notes',) Right you are! Now it works! :) Thanks! Oh great, now

Re: Sorting by item_in_another_list

2006-10-24 Thread Carsten Haese
On Tue, 2006-10-24 at 11:31, Gabriel Genellina wrote: At Tuesday 24/10/2006 04:35, Cameron Walsh wrote: c = set(B) a.sort(key=c.__contains__, reverse=True) Tim Delaney Depressingly simple. I like it. ...and fast! ...and not guaranteed to be correct:

Re: Sorting by item_in_another_list

2006-10-24 Thread Carsten Haese
On Tue, 2006-10-24 at 11:41, Carsten Haese wrote: On Tue, 2006-10-24 at 11:31, Gabriel Genellina wrote: At Tuesday 24/10/2006 04:35, Cameron Walsh wrote: c = set(B) a.sort(key=c.__contains__, reverse=True) Tim Delaney Depressingly simple. I like it. ...and fast

Re: proper format for this database table

2006-10-20 Thread Carsten Haese
On Fri, 2006-10-20 at 10:57, John Salerno wrote: [EMAIL PROTECTED] wrote: you should rethink it as [id] [university] [yearStart] [yearEnd] [degreeEarned] 1 U of I 19711975 BS 1 U of I 19751976 MS 1 U of I 19761977

Re: list comprehension (searching for onliners)

2006-10-20 Thread Carsten Haese
On Fri, 2006-10-20 at 10:53, Fredrik Lundh wrote: if you want to become a good Python programmer, you really need to get over that I need a oneliner idea. +1 QOTW -Carsten -- http://mail.python.org/mailman/listinfo/python-list

Re: why does this unpacking work

2006-10-20 Thread Carsten Haese
On Fri, 2006-10-20 at 15:14, John Salerno wrote: I'm a little confused, but I'm sure this is something trivial. I'm confused about why this works: t = (('hello', 'goodbye'), ('more', 'less'), ('something', 'nothing'), ('good', 'bad')) t (('hello', 'goodbye'),

Re: why does this unpacking work

2006-10-20 Thread Carsten Haese
On Fri, 2006-10-20 at 15:37, Carsten Haese wrote: for x in t: y,z = t # do something with y and z Typo here, of course I mean y,z = x. -Carsten -- http://mail.python.org/mailman/listinfo/python-list

Re: Newbie: datetime conversion question

2006-10-17 Thread Carsten Haese
On Tue, 2006-10-17 at 08:43, kevin evans wrote: Hi, I'm trying to convert some code from Ruby to Python, specifically.. timestamp = %08x % Time.now.to_i Make a hex version of the current timestamp. Any ideas how best to do this in python gratefully received.. import time timestamp = %08x

Re: Newbie: datetime conversion question

2006-10-17 Thread Carsten Haese
On Tue, 2006-10-17 at 08:49, hg wrote: import time %08X% (int)(time.mktime(time.localtime())) Have you not had your coffee yet or are you trying to win an obfuscated python programming competition? ;) -Carsten -- http://mail.python.org/mailman/listinfo/python-list

Re: Tertiary Operation

2006-10-17 Thread Carsten Haese
On Tue, 2006-10-17 at 09:30, abcd wrote: x = None result = (x is None and or str(x)) print result, type(result) --- OUTPUT --- None type 'str' The condition and result1 or result2 trick only works if result1 is an expression with a True boolean value. The empty

Re: Tertiary Operation

2006-10-17 Thread Carsten Haese
On Tue, 2006-10-17 at 09:48, Tim Chase wrote: [...] Either of the following should suffice: # return a non-empty string x is None and None or str(x) This one can be optimized to just str(x) since str(None)==None. [...] There are more baroque ways of writing the terniary

Re: Strange Behavior

2006-10-16 Thread Carsten Haese
On Mon, 2006-10-16 at 10:51, Steven D'Aprano wrote: On Mon, 16 Oct 2006 07:26:05 -0700, abcd wrote: class Foo: def __init__(self, name, data=[]): The binding of the name data to the empty list happens at compile time, not runtime. I think this statement needs to be clarified. The

Re: problem with the 'math' module in 2.5?

2006-10-14 Thread Carsten Haese
On 14 Oct 2006 20:33:13 -0700, Chris wrote from math import * sin(0) 0.0 sin(pi) 1.2246063538223773e-016 sin(2*pi) -2.4492127076447545e-016 cos(0) 1.0 cos(pi) -1.0 cos(2*pi) 1.0 The cosine function works fine, but I'm getting weird answers for sine. Is this a bug? Am I

Re: How do I put % in a format sting?

2006-10-05 Thread Carsten Haese
On Thu, 2006-10-05 at 16:15, John Salerno wrote: But I think SQL has other recommended methods. At least with SQLite, it is recommended you not use Python's %s formatter but instead the ? formatter. While I wholeheartedly agree with the sentiment, calling the ? a formatter only blurs the

Re: Instantiating an object when the type is only known at runtime

2006-10-04 Thread Carsten Haese
On Tue, 2006-10-03 at 18:19, Samuel wrote: Thanks, that's what I was looking for. m = __import__( StringIO ) x = getattr( m, StringIO )() x StringIO.StringIO instance at 0x00A47710 For the records: If the module is already loaded, this also works: if

[ANN] InformixDB-2.3 released

2006-10-01 Thread Carsten Haese
. * EXECUTE PROCEDURE erroneously attempted to open a results cursor for procedures that don't return results. * Date columns were read incorrectly on 64 bit platforms due to mixup of int4 versus long. Downloads and info at http://informixdb.sourceforge.net Best regards, Carsten Haese

Re: QuoteSQL

2006-09-26 Thread Carsten Haese
On Tue, 2006-09-26 at 07:08, Lawrence D'Oliveiro wrote: So yes, there should be two separate functions, one for escaping non-wildcard specials, and one for escaping wildcards. You only need the first one, since every database interface that follows PEP 249. You still need the second

Re: Need compile python code

2006-09-23 Thread Carsten Haese
On 23 Sep 2006 12:24:58 -0700, mistral wrote No, something is wrong there. what I need is just compile one python file which will generate html page, with parameters: exec python -O $0 $@ This is not a python script. It appears to be a Unix shell script that calls a python script. Maybe it

<    1   2   3   4   5   6   7   >