Re: is_iterable function.

2007-07-25 Thread Carsten Haese
False > dict is iterable = True > Iterable is iterable = True > NotIterable is iterable = False Testing for __iter__ alone is not enough: >>> class X(object): ... def __getitem__(self,i): ... if i<10: return i ... else: raise IndexError, i ... >>&g

Re: Why PHP is so much more popular for web-development

2007-07-25 Thread Carsten Haese
On Wed, 2007-07-25 at 13:55 -0700, walterbyrd wrote: > On Jul 25, 2:12 pm, Carsten Haese <[EMAIL PROTECTED]> wrote: > > > Also, CherryPy's requirements are very > > minimal. > > In terms of memory and CPU, maybe. But I think that *requires* apache > 2.x and

Re: is_iterable function.

2007-07-25 Thread Carsten Haese
in cursor", you can simulate it this way: for row in iter(cursor.fetchone, None): # do something Example 2: Reading a web page in chunks of 8kB: f = urllib.urlopen(url) for chunk in iter(lambda:f.read(8192), ""): # do something HTH, -- Carsten Haese http://inform

Re: Generating PDF reports

2007-07-26 Thread Carsten Haese
On Thu, 2007-07-26 at 16:02 +0200, marcpp wrote: > Hi i'm introducing to do reports from python, any recomendation? www.reportlab.org -- Carsten Haese http://informixdb.sourceforge.net -- http://mail.python.org/mailman/listinfo/python-list

Re: is_iterable function.

2007-07-25 Thread Carsten Haese
nes of text read from a socket. If the connection is faulty and closes the socket before you read the first line, the zeroth iteration raises an exception. Does that mean the object is iterable or not depending on the reliability of the socket connection? I find that notion hard to swallow. -- Carsten Haese http://informixdb.sourceforge.net -- http://mail.python.org/mailman/listinfo/python-list

Re: Why PHP is so much more popular for web-development

2007-07-25 Thread Carsten Haese
s. People claim they write desktop applications in PHP, but I don't believe them. Python is more powerful and offers a lot more choices. In order for Python to become more like PHP, somebody would have to make One True Way of developing web applications in Python, and that's never going to happen. Just my two cents, -- Carsten Haese http://informixdb.sourceforge.net -- http://mail.python.org/mailman/listinfo/python-list

Re: How do I 'stat' online files?

2007-07-25 Thread Carsten Haese
On Tue, 2007-07-24 at 22:23 -0300, Gabriel Genellina wrote: > En Tue, 24 Jul 2007 10:47:16 -0300, Carsten Haese <[EMAIL PROTECTED]> > escribió: > > > On Tue, 2007-07-24 at 09:07 -0400, DB Daniel Brown wrote: > >> I am working on a program that needs to stat files

Re: Why PHP is so much more popular for web-development

2007-07-25 Thread Carsten Haese
On Wed, 2007-07-25 at 12:34 -0700, walterbyrd wrote: > On Jul 25, 12:40 pm, Carsten Haese <[EMAIL PROTECTED]> wrote: > > > What exactly could Python learn from PHP? > > Remember, I'm a noob, I'm not trolling. I know. > When I posted "Python"

Re: Is access to locals() of "parent" namespace possible?

2007-07-27 Thread Carsten Haese
t the value of locals() of the "parent" > namespace. I thought it might be possible using sys._getframe, but I > have not been able to figure out why. inspect.currentframe(1).f_locals The same caveats for locals() apply here: Modifications to this dictionary may or may not be visi

Re: Detecting __future__ features

2007-07-30 Thread Carsten Haese
e scoped to the module. Observe: $ cat f1.py def f1(): print 1/2 f1() import f2 f2.f2() $ cat f2.py from __future__ import division def f2(): print 1/2 $ python f1.py 0 0.5 As you can see, f1 uses past semantics, f2 uses future semantics. Just use whatever __future__ directives you need for your module at the beginning of your module, and everything will just work. HTH, -- Carsten Haese http://informixdb.sourceforge.net -- http://mail.python.org/mailman/listinfo/python-list

Re: Detecting __future__ features

2007-07-30 Thread Carsten Haese
You > can't use "from __future__ import" in your module." > > If that were true, I think it would indeed be lame. Of course, it > isn't true, right? Correct, the statement you're referring to is not true. See my earlier reply on this thread for details. --

Re: Help text embedding in C code?

2007-07-30 Thread Carsten Haese
trings embedded in the C source. HTH, -- Carsten Haese http://informixdb.sourceforge.net -- http://mail.python.org/mailman/listinfo/python-list

Re: Pysqlite storing file as blob example

2007-07-30 Thread Carsten Haese
version of the sqlite module. The module that is included with Python2.5 is called sqlite3, and it lives in .../python/site-packages/sqlite3/* and .../python/lib-dynload/_sqlite3.so. HTH, -- Carsten Haese http://informixdb.sourceforge.net -- http://mail.python.org/mailman/listinfo/python-list

Re: Pysqlite storing file as blob example

2007-07-31 Thread Carsten Haese
lite3.Binary(contents). What is wrong, though, is passing the filename into it instead of the contents. This is in addition to the wrong execute call and using the wrong version of the sqlite module, as I pointed out in my previous reply. -- Carsten Haese http://informixdb.sourceforge.net -- http://mail.python.org/mailman/listinfo/python-list

Re: With Statement Contexts and Context Managers

2007-07-31 Thread Carsten Haese
definition of "good," but it should at least get you started. HTH, -- Carsten Haese http://informixdb.sourceforge.net -- http://mail.python.org/mailman/listinfo/python-list

Re: split a string of space separated substrings - elegant solution?

2007-07-31 Thread Carsten Haese
em are quoted substrings like > > abc "xy z" "1 2 3" "a \" x" > > should be split into ('abc','xy z','1 2 3','a " x') >>> import shlex >>> shlex.split('abc "xy z"

Re: Plain old SAX and minidom useable? But how then?

2007-08-01 Thread Carsten Haese
>> print things[0].hasAttribute("class") False >>> print things[0].getAttribute("class") >>> print things[1].childNodes [] >>> print things[1].childNodes[0].nodeValue Holy Grail >>> print things[1].hasAttribute("class") True

Re: frequency analysis of a DB column

2007-08-02 Thread Carsten Haese
27;re always going to be equal to column. -- Carsten Haese http://informixdb.sourceforge.net -- http://mail.python.org/mailman/listinfo/python-list

Re: Using cursor.callproc with zxJDBC

2007-08-03 Thread Carsten Haese
y happy to get a > response from you You haven't asked a question, and you're not describing what your problem is. I'm going to guess what your problem is: You're always getting the result "shite" regardless of whether the procedure worked or not. curs.fetchall()

Re: Global package variable, is it possible?

2007-08-03 Thread Carsten Haese
ce, and subsequent changes in the original namespace will, in general, not have any effect in the current namespace. This should do the trick: # module configure.py value1 = 10 value2 = 20 ... # other module import configure var = configure.value1 * configure.value2 HTH, -- Carsten Haese h

Re: downloading files

2007-08-03 Thread Carsten Haese
t; def download(url,fileName): > """Copy the contents of a file from a given URL > to a local file. > """ > import urllib > webFile = urllib.urlopen(url) > localFile = open(fileName, 'w') > [...]

Re: How to pass a reference to the current module

2007-08-03 Thread Carsten Haese
ly trying to accomplish, but it seems to me that instead of passing a reference to the current module and a function name, you should just pass a reference to the function that you want do_something_with to call. If I missed the point of your question, please describe less abstractly what you're trying to do. -- Carsten Haese http://informixdb.sourceforge.net -- http://mail.python.org/mailman/listinfo/python-list

Re: How to pass a reference to the current module

2007-08-03 Thread Carsten Haese
reference to the module, it only needs a reference to the function to call. Maybe your hurdle is how to obtain a reference to a function from the current module when all you have is the name of the function in a string. The answer to that would be "globals()[funcname]". -- Carsten Haese http://informixdb.sourceforge.net -- http://mail.python.org/mailman/listinfo/python-list

Re: How to pass a reference to the current module

2007-08-03 Thread Carsten Haese
On Fri, 2007-08-03 at 18:31 -0700, James Stroud wrote: > Carsten Haese wrote: > > please describe less abstractly what you're trying to do. > > You sound like my former thesis adviser. Thanks. I guess. > OK. From an external source, such as configuration file, the user wi

Re: Problems with headers in email.message

2007-08-04 Thread Carsten Haese
lude the Unix From envelope. I'd also like to point out that email.message is overkill for your simple use case. An email message is simply a series of headers followed by a blank line followed by the message body, which you can easily build manually if the headers aren't too long and the body is plain text: email_message = """\ From: %s To: %s Subject: %s %s""" % (email_from, email_to, email_subject, email_body) HTH, -- Carsten Haese http://informixdb.sourceforge.net -- http://mail.python.org/mailman/listinfo/python-list

Re: Problems with headers in email.message

2007-08-04 Thread Carsten Haese
zed names to lowercase names for Python 2.5. -- Carsten Haese http://informixdb.sourceforge.net -- http://mail.python.org/mailman/listinfo/python-list

Re: sqlite3 create table col width?

2007-08-04 Thread Carsten Haese
XXX',) (u'XX',) (u'',) (u'XX',) (u'XXXXXXXX

Re: Encoding DeprecationWarning

2007-08-04 Thread Carsten Haese
On Sat, 2007-08-04 at 12:07 -0700, [EMAIL PROTECTED] wrote: > Hey There, > > Sorry if I am missing something here, but I get a DeprecationWarning > when importing a list which has some unicode characters in it Please copy and paste the full text of the warning. -- Carste

Re: Encoding DeprecationWarning

2007-08-04 Thread Carsten Haese
asked you to post the full warning message, to get you to take another look at it. Mission accomplished ;) -- Carsten Haese http://informixdb.sourceforge.net -- http://mail.python.org/mailman/listinfo/python-list

Re: Misleading wikipedia article on Python 3?

2007-08-05 Thread Carsten Haese
cceptable depends on the features you need and how much "yak shaving" you find acceptable. For instance, if you never use print statements in your code, you won't notice that print is becoming a function. If you do, you'll have to make appropriate accommodations. HT

Re: udp, datagram sockets

2007-08-06 Thread Carsten Haese
uot;, total_sent, len(message) I don't think that sending the datagram to port on localhost sends the message back to the client. I'm guessing the server is sending the message back to itself, which throws it into the infinite feedback loop you're experiencing. HTH, -- Carsten Haese http://informixdb.sourceforge.net -- http://mail.python.org/mailman/listinfo/python-list

Re: Something in the function tutorial confused me.

2007-08-08 Thread Carsten Haese
difies a namespace and never modifies an object. In that sense, the mutability of None really isn't the issue. If you use the broader sense in which "assignment" includes augmented assignments, the mutability of None does become relevant. I agree that greg's delivery was unduly d

Re: accessing static attributes

2007-08-09 Thread Carsten Haese
;> request.user == request.__class__.user True >>> request.user = "nobody" >>> request.user == request.__class__.user False -- Carsten Haese http://informixdb.sourceforge.net -- http://mail.python.org/mailman/listinfo/python-list

Re: Hijack! Different book: (was: Opinions about this new Python book?

2007-08-16 Thread Carsten Haese
ms a bit too ambitious, > especially for a book in print. The book was co-authored by Kevin Dangoor, who is the principal developer of TurboGears. He probably had a pretty good idea of what the stable release was going to look like. -- Carsten Haese http://informixdb.sourceforge

Re: How to say $a=$b->{"A"} ||={} in Python?

2007-08-16 Thread Carsten Haese
our dict key, i.e. a[k1,k2] = v, unless you have some other constraints you're not telling us. HTH, -- Carsten Haese http://informixdb.sourceforge.net -- http://mail.python.org/mailman/listinfo/python-list

Re: How to say $a=$b->{"A"} ||={} in Python?

2007-08-16 Thread Carsten Haese
On Fri, 17 Aug 2007 03:15:10 -, beginner wrote > On Aug 16, 9:32 pm, Carsten Haese <[EMAIL PROTECTED]> wrote: > > What is the best solution in Perl need not be the best solution in > > Python. In Python you should just use a tuple as your dict key, i.e. > > a[k1,k2

Re: defaultdict of arbitrary depth

2007-08-16 Thread Carsten Haese
_getitem__(*args) > def __setitem__(self,*args): > return self.__dd.__setitem__(*args) This is shorter: from collections import defaultdict class recursivedefaultdict(defaultdict): def __init__(self): self.default_factory = type(self) -- Carsten Haese http://informixdb.sourceforge.

Re: defaultdict of arbitrary depth

2007-08-16 Thread Carsten Haese
practice is, of course, a different question. -- Carsten Haese http://informixdb.sourceforge.net -- http://mail.python.org/mailman/listinfo/python-list

Re: Question about 'for' loop

2007-08-17 Thread Carsten Haese
27;str' and 'list' objects" > > How can I achieve the above? Thanks for reading. You must have done something different than what you're describing above to get that error message. The code you posted works as expected: >>> mylist = [ ... "Hello &qu

Re: Xah's Edu Corner: Under the spell of Leibniz's dream

2007-08-20 Thread Carsten Haese
, or whose attitude is patronizing." (From "The elements of Style" by Strunk and White as quoted by Dijkstra in the very paper Xah Lee pointed out to us.) -- Carsten Haese http://informixdb.sourceforge.net -- http://mail.python.org/mailman/listinfo/python-list

Re: str().join() isn't working

2007-08-20 Thread Carsten Haese
Running that join expression on the lists you quoted works just fine. Either the lists contain something other than what you claim, or the expression you're using is different in reality. We can't help you if you don't post the code you're running. HTH, -- Carsten Haese http://informixdb.sourceforge.net -- http://mail.python.org/mailman/listinfo/python-list

Re: Baby Steps, optionDB

2007-08-23 Thread Carsten Haese
s you to express your ideas more concisely than you could in other programming languages. -- Carsten Haese http://informixdb.sourceforge.net -- http://mail.python.org/mailman/listinfo/python-list

Re: Baby Steps, optionDB

2007-08-23 Thread Carsten Haese
On Thu, 2007-08-23 at 14:38 +, W. Watson wrote: > The ultimate in conciseness was APL. I think you are mistaking terseness for conciseness. -- Carsten Haese http://informixdb.sourceforge.net -- http://mail.python.org/mailman/listinfo/python-list

RE: creating a tar file with python

2007-08-24 Thread Carsten Haese
On Thu, 2007-08-23 at 23:27 -0400, Brian McCann wrote: > > > Steve, > > I ran the code as you suggested, didn't work, tried variations of it > didn't work, > If you don't know the answer don't pretend you do! > > Apology not accepted, please don't wake up! > > Future correspondence on any py

RE: creating a tar file with python

2007-08-24 Thread Carsten Haese
Most importantly, let's keep in mind that the limited medium of an Internet mailing list paints a very skewed picture of who we are, and we should give each other the benefit of the doubt as much as possible. Ultimately, we're all here to talk about Python and help each other out

RE: copying files

2007-08-29 Thread Carsten Haese
On Wed, 2007-08-29 at 17:03 -0400, Brian McCann wrote: > what do the + signs do? Start here: http://docs.python.org/tut/ -- Carsten Haese http://informixdb.sourceforge.net -- http://mail.python.org/mailman/listinfo/python-list

Re: Is LOAD_GLOBAL really that slow?

2007-08-29 Thread Carsten Haese
depend on how many name lookups your code makes and how much else it's doing, but if you're doing a lot of number crunching and not a lot of I/O, the difference might be significant. Also, even if using local names is only slightly faster than using globals, it's still not slower, and the resulting code is still more readable and more maintainable. Using locals is a win-win scenario. Hope this helps, -- Carsten Haese http://informixdb.sourceforge.net -- http://mail.python.org/mailman/listinfo/python-list

Re: list index()

2007-08-30 Thread Carsten Haese
i!=ThingNotFoundIndicator: # Do something with i else: # Do something if thing not found ? -- Carsten Haese http://informixdb.sourceforge.net -- http://mail.python.org/mailman/listinfo/python-list

Re: SAXParseException: not well-formed (invalid token)

2007-08-30 Thread Carsten Haese
oded. If the string is encoded in latin-1, you can transcode it to utf-8 like this: contents = contents.decode("latin-1").encode("utf-8") HTH, -- Carsten Haese http://informixdb.sourceforge.net -- http://mail.python.org/mailman/listinfo/python-list

Re: SAXParseException: not well-formed (invalid token)

2007-08-30 Thread Carsten Haese
y, I wanted to add that you might find the following How-To helpful in demystifying Unicode: http://www.amk.ca/python/howto/unicode -- Carsten Haese http://informixdb.sourceforge.net -- http://mail.python.org/mailman/listinfo/python-list

Re: list index()

2007-08-30 Thread Carsten Haese
es. I want to see > what files are in directory A that are not in directory B. > [...] list.index() is the wrong tool for that job. Python has sets, use them. -- Carsten Haese http://informixdb.sourceforge.net -- http://mail.python.org/mailman/listinfo/python-list

Re: list index()

2007-08-30 Thread Carsten Haese
t one religious zealot. While I agree that Bruno's response was perhaps needlessly snippy, your original question was needlessly inflammatory, as if you somehow wanted some "religious zealot" to act the way Bruno did. If we start labeling people, this thread will earn you a l

Re: list index()

2007-08-30 Thread Carsten Haese
;in", which is faster and more concise. -- Carsten Haese http://informixdb.sourceforge.net -- http://mail.python.org/mailman/listinfo/python-list

Re: list index()

2007-08-30 Thread Carsten Haese
lly some reason "key" IN dict can be implemented faster > than dict.has_key("key")??? Yes, see e.g. http://groups.google.com/group/comp.lang.python/msg/03e9b4276846b9c0 -- Carsten Haese http://informixdb.sourceforge.net -- http://mail.python.org/mailman/listinfo/python-list

Re: list index()

2007-08-30 Thread Carsten Haese
print "Yup, got it!" ... Yup, got it! This feature may be older than version 1.5.2, but this is the oldest version that I still have running anywhere. -- Carsten Haese http://informixdb.sourceforge.net -- http://mail.python.org/mailman/listinfo/python-list

Re: list index()

2007-08-30 Thread Carsten Haese
s own right, a built-in > construct cannot. ...and that's why we have operator.contains(): >>> import operator >>> help(operator.contains) Help on built-in function contains in module operator: contains(...) contains(a, b) -- Same as b in a (note reversed operan

Re: list index()

2007-08-30 Thread Carsten Haese
is in section 3.6.4 of the library reference (http://docs.python.org/lib/typesseq-mutable.html), whereas "in" is in section 3.6 of the library reference (http://docs.python.org/lib/typesseq.html). I'm wondering how you managed to find subsection 3.6.4 without finding s

Re: list index()

2007-08-30 Thread Carsten Haese
lists. > > > > > if mylist.contains("hello): > > > > Genius. Why didn't anyone think of that before? > > With an attitude like that Chris, don't expect to be getting an > invite to beta test my Python 3 fork. Welcome to comp.lang.python, where

Re: list index()

2007-08-31 Thread Carsten Haese
On Thu, 30 Aug 2007 21:33:43 -0700, TheFlyingDutchman wrote > On Aug 30, 9:06 pm, "Carsten Haese" <[EMAIL PROTECTED]> wrote: > > On Thu, 30 Aug 2007 20:17:00 -0700, zzbbaadd wrote > > > > > Well IN was what I was looking for and would have saved this thread.

Re: So what exactly is a complex number?

2007-08-31 Thread Carsten Haese
On Thu, 2007-08-30 at 20:11 -0500, Lamonte Harris wrote: > Like in math where you put letters that represent numbers for place > holders to try to find the answer type complex numbers? Is English your native language? I'm having a hard time decoding your question. -- Carsten

Re: So what exactly is a complex number?

2007-08-31 Thread Carsten Haese
On Fri, 2007-08-31 at 11:13 -0600, Lamonte Harris wrote: > >Is English your native language? I'm having a hard time decoding your > question. > dont be an ass I'm sorry you took it this way. I was only trying to help. It won't happen again. -- Carsten Haese http:/

Re: Python Unicode to String conversion

2007-08-31 Thread Carsten Haese
o that, we'd have to see your code. For now, I'll give you the generic advice of taking a look at http://www.amk.ca/python/howto/unicode . HTH, -- Carsten Haese http://informixdb.sourceforge.net -- http://mail.python.org/mailman/listinfo/python-list

Re: list index()

2007-08-31 Thread Carsten Haese
On Sat, 2007-09-01 at 13:50 +1200, Lawrence D'Oliveiro wrote: > In message <[EMAIL PROTECTED]>, Carsten > Haese wrote: > > has_key() will go away, period. It has been made obsolete by "in", which > > is faster and more concise. > > And is also a ba

Re: list index()

2007-09-03 Thread Carsten Haese
On Mon, 03 Sep 2007 19:56:04 -0700, TheFlyingDutchman wrote > [...] my fork of Python 3, which I am > pleased to announce now, is called Python 3.01 while in development, > and will be known as Python 3000 or Python 3K when it gets to a productional > release. I hope you're joking. -Carsten --

Re: sqlite3.OperationalError: Could not decode to UTF-8 column

2007-09-05 Thread Carsten Haese
factory = str where conn is the name of your sqlite3 connection object. See http://docs.python.org/lib/sqlite3-Connection-Objects.html for more information. HTH, -- Carsten Haese http://informixdb.sourceforge.net -- http://mail.python.org/mailman/listinfo/python-list

Re: Give List to Format String - How To

2007-09-05 Thread Carsten Haese
1, in ? > TypeError: not enough arguments for format string To format multiple objects, the right operand must be a tuple. A list is not a tuple, so '%' only sees one argument. You want something like this: >>> '%s aaa %s aa %s' % tuple('test' for i in ra

Re: startswith( prefix[, start[, end]]) Query

2007-09-06 Thread Carsten Haese
information. >>> "blah".startswith(("a","b")) Traceback (most recent call last): File "", line 1, in ? TypeError: expected a character buffer object ### HTH, -- Carsten Haese http://informixdb.sourceforge.net -- http://mail.python.org/mailman/listinfo/python-list

Re: Beginners Query - Simple counter problem

2007-09-06 Thread Carsten Haese
ndint(1, 6) for die in range(count)) -- Carsten Haese http://informixdb.sourceforge.net -- http://mail.python.org/mailman/listinfo/python-list

Re: Beginners Query - Simple counter problem

2007-09-06 Thread Carsten Haese
On Thu, 2007-09-06 at 11:24 -0700, Ian Clark wrote: > Carsten Haese wrote: > > def d6(count): > > return sum(random.randint(1, 6) for die in range(count)) > > > > My stab at it: > > >>> def roll(times=1, sides=6): > ... return rand

Re: MySQLdb: ValueError Something Stupid

2007-09-07 Thread Carsten Haese
; On that particular table it did not like * for all fields. > > Any reason why that would be the case ? None that we can divine without more information. What's the schema for the table in question, which column(s) are you excluding to make the query work, and what kind of dat

Re: How to convert None to null value

2007-09-07 Thread Carsten Haese
of wrapper around a DB-API module. In any case, you should try to find out how to do parameter binding with whatever it is you're using. If it doesn't have a parameter binding mechanism, you should throw it away and replace it with a DB-API complaint module. HTH, -- Carsten Haese http://informixdb.sourceforge.net -- http://mail.python.org/mailman/listinfo/python-list

Re: Is a Borg rebellion possible? (a metaclass question)

2007-09-07 Thread Carsten Haese
27;t need a metaclass. Just turn _shared_state into a dictionary of shared states, keyed by the group name: class SplinterBorg(object): _shared_states = {} def __new__(cls, *a, **k): group = k.pop("group","BORG") obj = object.__new__(cls, *a, **k) obj.__dict__ = cls._shared_states.setdefault(group,{}) return obj HTH, -- Carsten Haese http://informixdb.sourceforge.net -- http://mail.python.org/mailman/listinfo/python-list

Re: passing command line arguments

2007-09-07 Thread Carsten Haese
t; print 'The arguments of %s are "%s"' %s \ > NameError: name 's' is not defined Start here: http://catb.org/~esr/faqs/smart-questions.html#before -- Carsten Haese http://informixdb.sourceforge.net -- http://mail.python.org/mailman/listinfo/python-list

Re: Is a Borg rebellion possible? (a metaclass question)

2007-09-07 Thread Carsten Haese
obj.__dict__ = cls._shared_states.setdefault(group,{}) return obj class MyClass(SplinterBorg): def __init__(self, name): self.name = name The alternatives, as Steve just pointed out, would be not to subclass SplinterBorg or to provide an __init__ method that expects a "group" argument. HTH, -- Carsten Haese http://informixdb.sourceforge.net -- http://mail.python.org/mailman/listinfo/python-list

Re: How to convert None to null value

2007-09-07 Thread Carsten Haese
On Fri, 2007-09-07 at 12:10 -0700, Dennis Lee Bieber wrote: > On Fri, 07 Sep 2007 09:07:49 -0400, Carsten Haese <[EMAIL PROTECTED]> > declaimed the following in comp.lang.python: > > > > doesn't have a parameter binding mechanism, you should throw it away and

Re: Is a Borg rebellion possible? (a metaclass question)

2007-09-07 Thread Carsten Haese
On Fri, 2007-09-07 at 14:54 -0600, Steven Bethard wrote: > Carsten Haese wrote: > > [slightly convoluted example...] > > I think I would probably write that as:: > [concise example...] > > That is, I don't think there's really a need for __new__ if you

Re: Python Problem

2007-09-07 Thread Carsten Haese
enchant" is, simply issue "print enchant" after importing enchant in IDLE. It'll tell you from where the module was loaded. HTH, -- Carsten Haese http://informixdb.sourceforge.net -- http://mail.python.org/mailman/listinfo/python-list

Re: /dev/null as a file-like object, or logging to nothing

2007-09-08 Thread Carsten Haese
ass LogSink(object): def write(self, *args, **kwargs): pass def flush(self, *args, **kwargs): pass logging.basicConfig(stream=LogSink()) I haven't tested this thoroughly, so it's possible that there are more methods that the stream is expected to implement. HTH, -- Carsten Haese http://informixdb.sourceforge.net -- http://mail.python.org/mailman/listinfo/python-list

Re: encoding latin1 to utf-8

2007-09-10 Thread Carsten Haese
How are you telling it to use UTF-8 encoding? Hope this helps, -- Carsten Haese http://informixdb.sourceforge.net -- http://mail.python.org/mailman/listinfo/python-list

Re: Using a time duration to print out data where every 2 seconds is a pixel

2007-09-10 Thread Carsten Haese
y since Python 2.3. -- Carsten Haese http://informixdb.sourceforge.net -- http://mail.python.org/mailman/listinfo/python-list

Re: printing list containing unicode string

2007-09-10 Thread Carsten Haese
do it: print repr(ttt).decode("unicode_escape").encode("utf-8") However, I am getting the impression that this is a "How can I use 'X' to achieve 'Y'?" question instead of the preferable "How can I achieve 'Y'?"

Re: Error in random module, bad installation?

2007-09-12 Thread Carsten Haese
object is not callable You have a file called random.py in your current directory. It's shadowing the random module from the library. HTH, -- Carsten Haese http://informixdb.sourceforge.net -- http://mail.python.org/mailman/listinfo/python-list

Re: newbie: self.member syntax seems /really/ annoying

2007-09-13 Thread Carsten Haese
a function that uses local variables, instead of a method that uses instance attributes. Accessing local variables is faster than accessing instance attributes, and you get rid of the annoying self prefix. -- Carsten Haese http://informixdb.sourceforge.net -- http://mail.python.org/mailman/listinfo/python-list

Re: Quick Modules question

2007-09-13 Thread Carsten Haese
ttp://catb.org/~esr/faqs/smart-questions.html#before . -- Carsten Haese http://informixdb.sourceforge.net -- http://mail.python.org/mailman/listinfo/python-list

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 orde

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

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): self.p

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 o

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

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 compl

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

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

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

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 woul

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 appli

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 ' % (s_

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: 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 = ta

<    1   2   3   4   5   6   7   >