Re: Dynamical loading of modules

2005-10-03 Thread Carsten Haese
On Mon, 2005-10-03 at 15:52, Jacob Kroon wrote: > Hi, I'm having some problems with implementing dynamical module loading. > First let me > describe the scenario with an example: > > modules/ > fruit/ > __init__.py > apple.py > banana.py > > apple.py defines a class '

Re: Dynamical loading of modules

2005-10-03 Thread Carsten Haese
On Mon, 2005-10-03 at 16:41, Carsten Haese wrote: > On Mon, 2005-10-03 at 15:52, Jacob Kroon wrote: > > Hi, I'm having some problems with implementing dynamical module loading. > > First let me > > describe the scenario with an example: > > > > modules/

Re: Dynamical loading of modules

2005-10-04 Thread Carsten Haese
On Mon, 2005-10-03 at 17:37, Steve Holden wrote: > Carsten Haese wrote: > > On Mon, 2005-10-03 at 16:41, Carsten Haese wrote: > > > >>On Mon, 2005-10-03 at 15:52, Jacob Kroon wrote: > >> > >>>Hi, I'm having some problems with implementing dynamica

Re: Dynamical loading of modules

2005-10-04 Thread Carsten Haese
On Tue, 2005-10-04 at 08:32, Steve Holden wrote: > Carsten Haese wrote: > > On Mon, 2005-10-03 at 17:37, Steve Holden wrote: > > > >>Carsten Haese wrote: > >> > >>>On Mon, 2005-10-03 at 16:41, Carsten Haese wrote: > >>> &

Re: Python interpreter bug

2005-10-07 Thread Carsten Haese
. The "in" operator doesn't use object identity, it uses object equality, and __cmp__ does serve to test object equality (if no __eq__ method is present). Perhaps the following example will clarify the behavior of "in": >>> A = [1] >>> B = [1] >>>

Re: Help creating extension for C function

2005-10-11 Thread Carsten Haese
On Tue, 2005-10-11 at 15:14, Java and Swing wrote: > Anyhow, I need PyBuildValue to work. Try Py_BuildValue. HTH, Carsten Haese. -- http://mail.python.org/mailman/listinfo/python-list

[ANN] Python API InformixDB-2.0 released

2005-10-24 Thread Carsten Haese
won't develop InformixDB-1.5 any further. Best regards, Carsten Haese. -- http://mail.python.org/mailman/listinfo/python-list

Re: syntax question - if 1:print 'a';else:print 'b'

2005-10-27 Thread Carsten Haese
On Thu, 2005-10-27 at 14:00, Gregory Piñero wrote: > Not quite because if something(3) fails, I still want something(4) to > run. def something_ignore_exceptions(x): try: something(x) except: pass something_ignore_exceptions(1) something_ignore_exceptions(2) # etc... HTH, Carsten

Re: Function returns none

2005-10-31 Thread Carsten Haese
On Mon, 2005-10-31 at 14:12, [EMAIL PROTECTED] wrote: > I'm trying to write a website updating script, but when I run the > script, my function to search the DOM tree returns None instead of what > it should. > > I have this program: > > import sys > from xml.dom.minidom import parse > >

Re: Retain reference to a struct

2005-11-02 Thread Carsten Haese
e from a call to PQconnectdb. The user could pass in any integer and (probably successfully) attempt to crash the system. You should really wrap the C struct (or the pointer to the C struct) into a Python object instead. By the way, it looks like you're trying to write some sort of database access module. The 'pq' looks suspiciously like it's for PostgreSQL. If that's the case, can't you just use an existing module for connecting to PostgreSQL? HTH, Carsten Haese. -- http://mail.python.org/mailman/listinfo/python-list

Re: mod_python

2005-11-06 Thread Carsten Haese
d think about sanitising user input a bit. The OP is using execute() with a parameter tuple. This is the correct method for executing a parametrized query, and it is immune to SQL injection as long as the DB module implements parameter substitution in a sane way. Best regards, Carsten Haese. -- http://mail.python.org/mailman/listinfo/python-list

Re: Python obfuscation

2005-11-10 Thread Carsten Haese
d, all copies are identical and therefore indistinguishable. +1 QOTW! -- Carsten Haese - Software Engineer | Phone: (419) 794-2531 Unique Systems, Inc. | FAX: (419) 893-2840 1687 Woodlands Drive | Cell: (419) 343-7045 Maumee, OH 43537

Re: How to avoid "f.close" (no parens) bug?

2005-11-13 Thread Carsten Haese
quot; instead of "f.close()". D) Something else. Please elaborate by giving us a code example, a description of what you expected to happen, and a description of what happened instead. Best regards, Carsten Haese. -- http://mail.python.org/mailman/listinfo/python-list

Re: How to - import code not in current directory

2005-11-17 Thread Carsten Haese
On Thu, 2005-11-17 at 08:41, py wrote: > Claudio Grondi wrote: > > so this should work in your case: > > > > import sys > > sys.path.append("C:\some\other\directory") > > import bar > > ...that will certainly work. Only issue is that each time I start up > foo.py in the python shell I have to ret

Re: How to convert a "long in a string" to a "long"?

2005-11-18 Thread Carsten Haese
On Fri, 2005-11-18 at 11:04, [EMAIL PROTECTED] wrote: > Hello, > > I need to convert the string "" to a long. To convert this > string I tried the following: > >>> 0x > -1 > >>> 0xL > 4294967295L > > OK, this is what I want, so I tried > > s = long("0xL") > ValueE

[ANN] Python API InformixDB-2.1 released

2005-11-20 Thread Carsten Haese
Types Downloads and more info at http://informixdb.sourceforge.net/ Enjoy, Carsten Haese. -- http://mail.python.org/mailman/listinfo/python-list

Re: Why are there no ordered dictionaries?

2005-11-22 Thread Carsten Haese
On Tue, 2005-11-22 at 13:37, Christoph Zwerschke wrote: > Would the default semantics below really be that suprising? > > "An ordered dictionary remembers the order in which keys are first seen > [...] Overwriting an entry replaces > its value, but does not affect its position in the key order.

Re: Why are there no ordered dictionaries?

2005-11-22 Thread Carsten Haese
On Tue, 2005-11-22 at 14:37, Christoph Zwerschke wrote: > In Foord/Larosa's odict, the keys are exposed as a public member which > also seems to be a bad idea ("If you alter the sequence list so that it > no longer reflects the contents of the dictionary, you have broken your > OrderedDict"). T

Re: Why are there no ordered dictionaries?

2005-11-23 Thread Carsten Haese
On Tue, 2005-11-22 at 20:44, Tom Anderson wrote: > On Tue, 22 Nov 2005, Carsten Haese wrote: > > > On Tue, 2005-11-22 at 14:37, Christoph Zwerschke wrote: > > > >> In Foord/Larosa's odict, the keys are exposed as a public member which > >> also seems to

Re: syntax errors while building pypgsql

2005-11-23 Thread Carsten Haese
On Wed, 2005-11-23 at 08:01, Tin Gherdanarra wrote: > Hallo, > > I'm trying to install pypgsql. However, I get syntax errors > while compiling the C sources. The following excerpt > from pgconnection.h looks a little funny to me: > > typedef struct { > PyObject_HEAD /* Here is the syntax err

Re: Why are there no ordered dictionaries?

2005-11-23 Thread Carsten Haese
On Wed, 2005-11-23 at 15:17, Christoph Zwerschke wrote: > Bengt Richter wrote: > > I think the concept has converged to a replace-or-append-by-key ordering > > of key:value items with methods approximately like a dict. We're now > > into usability aspects such as syntactic sugar vs essential pri

Re: Why are there no ordered dictionaries?

2005-11-23 Thread Carsten Haese
On Wed, 23 Nov 2005 23:39:22 +0100, Christoph Zwerschke wrote > Carsten Haese schrieb: > > > Thus quoth the Zen of Python: > > "Explicit is better than implicit." > > "In the face of ambiguity, refuse the temptation to guess." > > > >

Re: Using Cron to run a python program

2005-11-23 Thread Carsten Haese
On 23 Nov 2005 16:23:11 -0800, vagrantbrad wrote > I'm using python 2.4 running on Fedora Core 4. I have written a python > program called ipscan.py that checks the external ip address of my > cable internet connection, and on change, will update the dns records > at my dns provider, zoneedit. So

Re: python speed

2005-11-30 Thread Carsten Haese
On Wed, 2005-11-30 at 14:53, Paul Boddie wrote: > [...] the Java virtual machine > is suitably designed/specified to permit just-in-time complication. +1 Freudian slip of the week :) -Carsten Haese -- http://mail.python.org/mailman/listinfo/python-list

Re: Why use #!/usr/bin/env python rather than #!python?

2005-12-02 Thread Carsten Haese
On Fri, 2005-12-02 at 09:12, Adriano Ferreira wrote: > On 12/2/05, Klaus Alexander Seistrup <[EMAIL PROTECTED]> wrote: > > #v+ > > > > $ ls -l /tmp/hello.py > > -rwxr-xr-x 1 klaus klaus 38 2005-12-02 14:59 /tmp/hello.py > > $ cat /tmp/hello.py > > #! python > > print 'Hello, world!' > > # eof > >

Re: insert a dictionary into sql data base

2005-12-05 Thread Carsten Haese
On Mon, 05 Dec 2005 18:00:21 -0700, David Bear wrote > Fredrik Lundh wrote: > > DON'T MANUALLY CONSTRUCT THE SQL INSERT STATEMENT. Use string > > formatting to insert the field names, but let the database layer deal with > > the values. > > > > If you want to do things in two steps, do the fields

Re: i=2; lst=[i**=2 while i<1000]

2005-12-06 Thread Carsten Haese
On Tue, 2005-12-06 at 10:44, Steve Holden wrote: > Daniel Schüle wrote: > >>>i=2 > >>>lst=[] > >>>while i<1000: > >>>i**=2 > >>>lst.append(i) > >>> > >> > > > > unless I am missing something obvious, I can not see why the loop should > > not terminate > > In that case, kindly explain how

Re: Spreadsheet with Python scripting and database interface?

2005-08-11 Thread Carsten Haese
script the office from within using a macro or from the outside via "remote control". PyUNO allows both, but Python macros are only possible with the OpenOffice 2 scripting framework. Hope this helps, Carsten Haese. -- http://mail.python.org/mailman/listinfo/python-list

Re: variable hell

2005-08-25 Thread Carsten Haese
On Thu, 2005-08-25 at 10:43, Nx wrote: > Thanks for the many replies > > here is an example for what it will be used for , in this case > fixed at 31 fieldvalues: > > > inputvalues=(s0,s1,s2,s3,s4,s5,s6,s7,s8,s9,s10,s11,s12,s13,s14,s15,s16,s17,s18,s19,s20,s21,s22,s23,s24,s25, > s26,s2

Re: variable hell

2005-08-25 Thread Carsten Haese
On Thu, 2005-08-25 at 11:04, I hastily wrote: > On Thu, 2005-08-25 at 10:43, Nx wrote: > > Thanks for the many replies > > > > here is an example for what it will be used for , in this case > > fixed at 31 fieldvalues: > > > > > > inputvalues=(s0,s1,s2,s3,s4,s5,s6,s7,s8,s9,s10,s11,s12,s13,s14

Re: Find day of week from month and year

2005-09-02 Thread Carsten Haese
On Fri, 2005-09-02 at 16:46, Laguna wrote: > Paul, > > Thanks for the suggestion on calendar module. Here is my solution and > it works: > > def expiration(year, month): > weekday = calendar.weekday(year, month, 1) > table = [19, 18, 17, 16, 15, 21, 20] > return table[weekday] >

Re: MySQLdb error - PLEASE SAVE ME!

2005-09-17 Thread Carsten Haese
On Sat, 17 Sep 2005 15:50:29 -0400, Ed Hotchkiss wrote > Ok. I am trying to read a csv file with three strings separated by commas. > I am trying to insert them into a MySQL DB online. > MySQLdb is installed, no problems. > > I think that I am having some kind of error with my csv going into > th

InformixDB-1.5 released

2005-09-19 Thread Carsten Haese
es it didn't correspond to the most recent operation. Best regards, Carsten Haese. -- http://mail.python.org/mailman/listinfo/python-list

Looking for Stephen Turner, maintainer of informixdb

2005-03-28 Thread Carsten Haese
sts trying to locate Stephen. If anybody has any pointers for locating Stephen Turner, please let me know. If Stephen can't be located, I'd be willing to take over the project, but I'd prefer the torch be given to me rather than me just taking it. Thanks, -- Carsten Haese - Softwar

Re: Looking for Stephen Turner, maintainer of informixdb

2005-04-04 Thread Carsten Haese
On Tue, 2005-03-29 at 03:05, Michael Husmann wrote: > Carsten Haese wrote: > > > Hello everybody: > > > > I have discovered that the functionality for connecting Python to an > > Informix database is currently in a frustrating state of neglect. The > > lin

Re: Ply(LALR) and Yacc behaving differently

2005-04-08 Thread Carsten Haese
k """ def p_Block(p): """ Block : SEMI | T Block | S Block """ Of course, I don't know whether this rewrite is applicable to your larger grammar. Hope this helps, -- Carsten Haese - Software Engineer |Phone: (4

Informixdb: New maintainer, new version

2005-04-12 Thread Carsten Haese
estions or comments, please let me know. Best regards, -- Carsten Haese - Software Engineer |Phone: (419) 861-3331 Unique Systems, Inc. | FAX: (419) 861-3340 1446 Reynolds Rd, Suite 313 | Maumee, OH 43537| mailto:[EMAIL PROTECTED]

Re: "0 in [True,False]" returns True

2005-12-12 Thread Carsten Haese
On Mon, 2005-12-12 at 16:26, Pierre Quentel wrote: > Hi all, > > In some program I was testing if a variable was a boolean, with this > test : if v in [True,False] > > My script didn't work in some cases and I eventually found that for v = > 0 the test returned True > > So I changed my test fo

Re: Python C/API - *arg,**kwds variable argumnents

2005-12-14 Thread Carsten Haese
On Wed, 2005-12-14 at 12:00, [EMAIL PROTECTED] wrote: > essentially I already use PyArg_ParseTupleAndKeywords, but that seems > to emulate fixed arg list definitions like - >func (x,y,t=0,u=1) It's unclear what you are actually trying to accomplish. My guess is that you want to implement a fu

Re: Easiest way to calculate number of character in string

2005-12-21 Thread Carsten Haese
On Wed, 2005-12-21 at 09:03, P. Schmidt-Volkmar wrote: > Hi there, > > I have a string in which I want to calculate how often the character ';' > occurs. If the character does not occur 42 times, the ";" should be added so > the 42 are reached. > > My solution is slow and wrong: > for Posi

Re: Guido at Google

2005-12-22 Thread Carsten Haese
On Thu, 2005-12-22 at 07:01, Peter Hansen wrote: > [EMAIL PROTECTED] wrote: > > So exactly how high is python in Google's priority list ? Or in other > > words, if python is in a stand still as it is now, what would be the > > impact to Google ? > > Since when is Python in a standstill? I believ

Re: Guido at Google

2005-12-22 Thread Carsten Haese
On Thu, 2005-12-22 at 08:18, [EMAIL PROTECTED] wrote: > Cameron Laird wrote: > > In article <[EMAIL PROTECTED]>, > > <[EMAIL PROTECTED]> wrote: > > . > > . > > . > > >Well, this may be the CPython way of open source but I don't know if >

Re: print UTF-8 file with BOM

2005-12-23 Thread Carsten Haese
> 2005/12/23, David Xiao <[EMAIL PROTECTED]>: > Hi Kuan: > > Thanks a lot! One more question here: How to write if I want > to > specify locale other than current locale? > > For example, running on Korea locale system, and try read a >

Re: Modifying values in a list

2005-12-29 Thread Carsten Haese
On Thu, 2005-12-29 at 11:43, [EMAIL PROTECTED] wrote: > The following code: > > numbers = [1, 2, 3] > for value in numbers: > value *= 2 > print numbers > > results in the following output: > [1, 2, 3] > > The intent of the code was to produce this output: > [2, 4, 6] > > What is the reas

Re: MidiToText : EventDispatcher instance has no attribute 'sysex_events'

2005-12-30 Thread Carsten Haese
On Fri, 2005-12-30 at 09:52, tim wrote: > Trying to convert midi to text using MidiToText.py. > I get the following: > > midi_port: 0 > Traceback (most recent call last): > File "MidiToText.py", line 176, in ? > midiIn.read() > File "C:\Python24\Lib\site-packages\midi\MidiInFile.py", line

Re: Python and location of .so files?

2006-01-10 Thread Carsten Haese
On Tue, 2006-01-10 at 09:42, Efrat Regev wrote: >Hello, > >On FC4, I've generated an .so file from C++ which I want to use from > python. It works when I copy it into /usr/lib/python2.4/site-packages. > (I.e., say I have hello.so in that directory, then from the python > prompt I can 'im

Re: rational numbers

2006-01-17 Thread Carsten Haese
On Tue, 2006-01-17 at 11:22, Paul Rubin wrote: > Schüle Daniel <[EMAIL PROTECTED]> writes: > > does anybody know modules which make rational numbers available? > > Try gmpy.mpq (google for gmpy). > > > and are there considerations to add them to the core, like > > complex numbers (maybe in Python

Re: Need Help with Python/C API

2006-01-19 Thread Carsten Haese
On Thu, 2006-01-19 at 00:44, pycraze wrote: > Hi guys, > > I Need to know how do i create a dictionary... eg: > n = pali_hash > n={} > n={1:{ } } -> i need to know how to make a key of a dictionary, to a > dictionary using Python/C API's You can either use Py_BuildValue (See http://docs.py

Re: Static Variables in Python?

2006-07-31 Thread Carsten Haese
On Mon, 2006-07-31 at 15:21, Michael Yanowitz wrote: > Is it possible to have a static variable in Python - > a local variable in a function that retains its value. > > For example, suppose I have: > > def set_bit (bit_index, bit_value): >static bits = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,

Re: Can't get LCHARVAR's with InformixDB

2006-08-01 Thread Carsten Haese
On Tue, 2006-08-01 at 09:02, [EMAIL PROTECTED] wrote: > I'm using the InformixDB package, which has been a real lifesaver, but > I'm finding I can't get any data from the Informix LCHARVAR types. > They're coming in as empty strings. > > The cursor._description for the field in question is: > ('ms

Re: Can't get LCHARVAR's with InformixDB

2006-08-01 Thread Carsten Haese
On Tue, 2006-08-01 at 09:27, [EMAIL PROTECTED] wrote: > Carsten Haese wrote: > > What version are you using? I thought I fixed lvarchars a long time ago. > > 2.2, with Python 2.4 on Windows... I installed via > InformixDB-2.2.win32-py2.4.exe Hm, this certainly warrants furthe

Re: Can't get LCHARVAR's with InformixDB

2006-08-01 Thread Carsten Haese
On Tue, 2006-08-01 at 11:41, [EMAIL PROTECTED] wrote: > Carsten Haese wrote: > > Could you possibly send me a minimal test script that shows the problem? > > Also, in case it matters, I'd like to know which versions of IDS and > > CSDK or Informix Connect you're

Re: Can't get LCHARVAR's with InformixDB

2006-08-01 Thread Carsten Haese
On Tue, 2006-08-01 at 11:47, [EMAIL PROTECTED] wrote: > Another thing... > > > Output is: > > description is <('msg_tx', 'lvarchar', 0, 0, None, None, 1)> > > The 0's worried me, as I could see where they could be used as parms to > allocate/trim things as necessary... just a thought. That is i

Re: Can't get LCHARVAR's with InformixDB

2006-08-01 Thread Carsten Haese
On Tue, 2006-08-01 at 14:05, [EMAIL PROTECTED] wrote: > Carsten Haese wrote: > > Once again, I'll need > > the create table statement for the table you're selecting from in order > > to investigate what's happening. > > Here it is: > > CREATE TABLE

Re: Negative division bug?

2006-08-03 Thread Carsten Haese
On Thu, 2006-08-03 at 13:51, Michael Yanowitz wrote: > Hello: > > Just wondering if this is a bug, is this as designed, > or do I have to import math or something to make it correct: > >I was just screwing around. > and found: > >>> -1/100 > -1 > Shouldn't it be zero? > 1/100 returns 0 >

Re: how do you get the name of a dictionary?

2006-08-22 Thread Carsten Haese
On Tue, 2006-08-22 at 12:34, jojoba wrote: > Hello again, > > Fredrick said: > > > Python's object model. an object has a value, a type, and an identity, > > but no name. > > I say: > > Thank you Fredrick for the reply! > However, although python's object model does not currently support what

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 t

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

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 clarif

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 timestam

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 The "condition and result1 or result2" trick only works if result1 is an expression with a True boolean value. The emp

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 ter

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 1976

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', 'go

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: 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: http:

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) > > > > >

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 secon

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! :)

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

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 b

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 re

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 do

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.

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

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 superi

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 statemen

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(): >

Re: re.compile() doesn't work under Windows?

2006-08-31 Thread Carsten Haese
On Thu, 2006-08-31 at 17:38, ddtl wrote: > Hello everybody. > > My script uses re.compile() function, and while it rans without errors > under Linux, when I ran that script under Windows I get the following > error: > > Traceback (most recent call last): > File "C:\a\projects\re.py", line 4, in

Re: REQ: Java/J2EE Developer 10 Months

2006-09-15 Thread Carsten Haese
On Fri, 2006-09-15 at 14:41, Steve Holden wrote: > [EMAIL PROTECTED] wrote: > [...] > > Skill: > > > > > > *Java, 2 year UNIX - HP / Solaris, 2 yrs OOA+D, Corba, Perl, XML, UML. > > *Java dev experience, Swing, JPS, 2 years of OOA+D. > > Clearly not spam, since the guy is so in touch wit

Re: Python/MySQL problem on Windows

2006-09-20 Thread Carsten Haese
On Wed, 2006-09-20 at 16:37, Eric Smith wrote: > I'm trying to use Python 2.4.3 and pywin32-209 to access a MySQL > database on Windows Server 2003 Standard Edition, and not having much > luck. It seems like parts of the MySQLdb module are not getting loaded > correctly, but no error message is giv

Re: Nested Looping SQL Querys

2006-09-21 Thread Carsten Haese
On Thu, 2006-09-21 at 01:12, Dennis Lee Bieber wrote: > On Wed, 20 Sep 2006 13:21:54 -0400, Steve Holden <[EMAIL PROTECTED]> > declaimed the following in comp.lang.python: > > > .execute() is a cursor method, not a connection method. Some DB API > > modules do implement it as a connection method,

Re: Isn't bool __invert__ behaviour "strange"?

2006-09-22 Thread Carsten Haese
On Fri, 2006-09-22 at 11:25, Saizan wrote: > Bjoern Schliessmann wrote: > > Saizan wrote: > > > > > Why subclassing bool from int either __invert__ or __neg__ haven't > > > been overrided to produce a boolean negation? > > > > I wonder what -True or -False should evaluate to. > Well in boolean nota

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.

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 se

[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

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 > > > > >>> > > For the records: If the module is already loaded, this also works: > > if my_type_is_not_yet_loaded: >

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 fa

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 deter

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 wha

[ANN] InformixDB-2.4 released

2006-12-01 Thread Carsten Haese
o retrieve 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: 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 anywhe

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 > >

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" statem

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 c

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 w

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(

  1   2   3   4   5   6   7   >