Re: quiet conversion functions

2006-04-13 Thread Sion Arrowsmith
Tim Chase [EMAIL PROTECTED] wrote: def CFloat(value): try: value = float(value) except (ValueError, TypeError): value = 0 return value type(CFloat(None)) type 'int' I think you want value = 0.0 . And you might also want to consider what errors

Re: list.clear() missing?!?

2006-04-13 Thread Sion Arrowsmith
Fredrik Lundh [EMAIL PROTECTED] wrote: except that arguments along the line of if the syntax is not obj.method(), it's not OO enough are likely to be mostly ignored. (nobody's going to be impressed by yet another len(obj) isn't OO variant) Does that suggest that what's needed is clear(obj) and

Re: Characters contain themselves?

2006-04-11 Thread Sion Arrowsmith
Graham Fawcett [EMAIL PROTECTED] wrote: You could always use an is-proper-subset-of function, which is closer to the intent of your algorithm. Using Jamitzky's very clever infix recipe [1], you can even write it as an infix operator: #Jamitzky's infix-operator class, abbreviated class Infix: [

Re: About classes and OOP in Python

2006-04-10 Thread Sion Arrowsmith
fyhuang [EMAIL PROTECTED] wrote: [ ... ] no such thing as a private variable. Any part of the code is allowed access to any variable in any class, and even non-existant variables can be accessed: they are simply created. You're confusing two issues: encapsulation and dynamic name binding. You

Re: shelve and .bak .dat .dir files

2006-04-07 Thread Sion Arrowsmith
Michele Petrazzo [EMAIL PROTECTED] wrote: Sion Arrowsmith wrote: This is a documented behaviour of shelve: [ open(filename) may create files with names based on filename + ext ] (and I fail to understand why it is a problem). Because: 1) I pass a name that, after, I'll pass to another program

Re: passing argument to script

2006-04-07 Thread Sion Arrowsmith
Daniel Nogradi [EMAIL PROTECTED] wrote: If you execute your script from the command line on Linux you need to enclose it in quotation marks otherwise your shell will interfere. So you need to invoke your program as python yourscript.py ABCE-123456 ABC_DEF_Suggest(abc def ghi).txt Same is true

Re: shelve and .bak .dat .dir files

2006-04-06 Thread Sion Arrowsmith
Michele Petrazzo [EMAIL PROTECTED] wrote: I'm trying a script on a debian 3.1 that has problems on shelve library. The same script work well on a fedora 2 and I don't know why it create this problem on debian: [ ... ] Now I see that shelve create not my file, but three files that has the name

Re: pre-PEP: The create statement

2006-04-06 Thread Sion Arrowsmith
Kay Schluehr [EMAIL PROTECTED] wrote: Steven Bethard wrote: Python-Version: 2.6 Have you a rough estimation how many modules will be broken when create is introduced as a keyword? A quick scan of the standard library suggests that it will have a grand total of 3 modules requiring a fix (it's a

Re: pre-PEP: The create statement

2006-04-06 Thread Sion Arrowsmith
Michele Simionato [EMAIL PROTECTED] wrote: Sion Arrowsmith wrote: A quick scan of the standard library suggests that it will have a grand total of 3 modules requiring a fix (it's a method name in imaplib and a named argument in a couple of places in bsddb and distutils). Your own code my fare

Re: using range() in for loops

2006-04-05 Thread Sion Arrowsmith
AndyL [EMAIL PROTECTED] wrote: Paul Rubin wrote: Normally you'd use range or xrange. range builds a complete list in memory so can be expensive if the number is large. xrange just counts up to that number. so when range would be used instead of xrange. if xrange is more efficient, why range

Re: how to comment lot of lines in python

2006-04-03 Thread Sion Arrowsmith
Eric Deveaud [EMAIL PROTECTED] wrote: some moderns editors allow you to comment/uncomment a selected Bunch of lines of code Out of curiousity, is there a modern editor which *doesn't* allow you to comment/uncomment a selected bunch of lines of code? -- \S -- [EMAIL PROTECTED] --

Re: string building

2006-04-03 Thread Sion Arrowsmith
John Salerno [EMAIL PROTECTED] wrote: Out of curiosity, is there any kind of equivalent in Python to the StringBuilder class in C#? Here's a quick description from the .NET documentation: This class represents a string-like object whose value is a mutable sequence of characters. The value is

Re: problems with looping, i suppose

2006-03-28 Thread Sion Arrowsmith
John Salerno [EMAIL PROTECTED] wrote: Does what I originally pasted in my message look incorrect? To me, it all seems indented properly. Yes. Somewhere or other you've got your tabstop set to 4, and python treats literal tabs as being of equivalent indent to 8 spaces. As does my newsreader, so

Re: in-place string reversal

2006-03-28 Thread Sion Arrowsmith
Sathyaish [EMAIL PROTECTED] wrote: How would you reverse a string in place in python? [ ... ] Forget it! I got the answer to my own question. Strings are immutable, *even* in python. I'm not sure what that *even* is about, but glad that You can't, strings are immutable is a satisfactory answer.

Re: What's the best way to learn perl for a python programmer?

2006-03-28 Thread Sion Arrowsmith
Magnus Lycka [EMAIL PROTECTED] wrote: The thing that really bit me when I tried to go back to Perl after years with Python was dereferencing. Completely obvious things in Python, such as extracting an element from a list inside a dict in another list felt like black magic. Not that long ago I

Re: in-place string reversal

2006-03-28 Thread Sion Arrowsmith
Felipe Almeida Lessa [EMAIL PROTECTED] wrote: Em Ter, 2006-03-28 às 16:03 +0100, Sion Arrowsmith escreveu: .join(reversed(foo)) $ python2.4 -mtimeit '.join(reversed(foo))' 10 loops, best of 3: 2.58 usec per loop But note that a significant chunk is the join(): $ python2.4 -mtimeit '.join

Re: don't understand popen2

2006-03-24 Thread Sion Arrowsmith
Kent Johnson [EMAIL PROTECTED] wrote: Sion Arrowsmith wrote: (and please avoid the abuse of raw strings for Windows paths). Why do you consider that abuse of raw strings? I consider it abuse because it's not what they were invented for. I consider discouraging it to be a good thing in order

Re: don't understand popen2

2006-03-23 Thread Sion Arrowsmith
Martin P. Hellwig [EMAIL PROTECTED] wrote: std_out, std_in = popen2.popen2(F:\coding\pwSync\popen_test\testia.py) ^^ Your problem is, I suspect, nothing to do with popen2(), which is supported by the fact that the only thing other than

Re: Can XML-RPC performance be improved?

2006-03-23 Thread Sion Arrowsmith
[EMAIL PROTECTED] wrote: Diez Sion Arrowsmith wrote: I've got an established client-server application here where there is now a need to shovel huge amounts of data (structured as lists of lists) between the two, and the performance bottleneck has become the amount of time

Re: Default/editable string to raw_input

2006-03-23 Thread Sion Arrowsmith
Sybren Stuvel [EMAIL PROTECTED] wrote: Paraic Gallagher enlightened us with: While I agree in principal to your opinion, the idea is that an absolute moron would be able to configure a testcell with smallest amount of effort possible. Then explain to me why learning how to use your program to

Re: Can XML-RPC performance be improved?

2006-03-23 Thread Sion Arrowsmith
[EMAIL PROTECTED] wrote: Steve I suppose there *was* a good reason for using XML-RPC in the Steve first place? I don't know about the OP, but in my case it was a drop-dead simple cross-language RPC protocol. I am the OP and *I* don't know if there was a good reason for using XML-RPC in

Re: Can I use a conditional in a variable declaration?

2006-03-21 Thread Sion Arrowsmith
Ron Adam [EMAIL PROTECTED] wrote: [EMAIL PROTECTED] wrote: I want the equivalent of this: if a == yes: answer = go ahead else: answer = stop in [a] more compact form: I sometimes find it useful to do: answers = {True: go ahead, False: stop} answer = answers[a == yes]

Can XML-RPC performance be improved?

2006-03-21 Thread Sion Arrowsmith
I've got an established client-server application here where there is now a need to shovel huge amounts of data (structured as lists of lists) between the two, and the performance bottleneck has become the amount of time spent parsing XML (it's taking 100% CPU on one or other end of the connection

Re: Exception not raised - May be the end

2006-03-03 Thread Sion Arrowsmith
Michele Petrazzo [EMAIL PROTECTED] wrote: some days ago I posted here and say that python forgot to raise an exception, but my code was too long for make some tries possible. But now I can reproduce the problem into another, little, project: www.unipex.it/vario/wxFrameSchedule.py

Re: except clause not catching IndexError

2006-02-23 Thread Sion Arrowsmith
Steven D'Aprano [EMAIL PROTECTED] wrote: You mean to say that except X,Y: gives different results to except (X,Y):? [ ... ] And here I was thinking that commas make tuples, not brackets. What is happening here? Similar kind of thing to what's happening here: print Hello,, world! Hello,

Re: Little tool - but very big size... :-(

2006-02-22 Thread Sion Arrowsmith
BJ in Texas [EMAIL PROTECTED] wrote: [EMAIL PROTECTED] wrote: || 11MB is seldom a concern for today's machine. A good windows/microsoft attitude.. :-) I wish 8-( : PID USER PR NI VIRT RES SHR S %CPU %MEMTIME+ COMMAND 3715 root 15 0 288m 128m 154m S 1.0 6.3 14902:42

[OT] Re: number ranges

2006-02-22 Thread Sion Arrowsmith
Steven D'Aprano [EMAIL PROTECTED] wrote: Colin J. Williams [EMAIL PROTECTED] wrote: 1. Why not treat '2 to 5' or '(2 to 5)' as a semi-open interval? I intellectually understand that semi-open intervals are the only way to go. But reading the words, the part of my brain that speaks English

Re: No

2006-02-22 Thread Sion Arrowsmith
Gaz [EMAIL PROTECTED] wrote: So, they can not upload the photos by FTP because its too geek for them. And i need to have a standarized form to handle the reports, because otherwise its a organizational mess. Am I missing something here, or is all you need a INPUT TYPE=FILE ... on your form? Then

Re: Determining an operating system's default browser

2006-02-10 Thread Sion Arrowsmith
John McMonagle [EMAIL PROTECTED] wrote: Is there a python module which can determine an operating system's default web browser application. http://docs.python.org/lib/module-webbrowser.html -- \S -- [EMAIL PROTECTED] -- http://www.chaos.org.uk/~sion/ ___ | Frankly I have no feelings

Re: Newbie Q: dynamically assigning object attribute

2006-02-10 Thread Sion Arrowsmith
Ben Wilson [EMAIL PROTECTED] wrote: I would like to dynamically assign object attributes: dict = { a : 1, b : 2, } for key,val in dict : obj.key = val I've googled to no effect, or maybe I'm needing to be hit with the appropriately sized clue-by-four. The conventional clue-by-four applied

Re: Number Format function

2006-02-09 Thread Sion Arrowsmith
Rick Zantow [EMAIL PROTECTED] wrote: print number_format( 2312753.4450, 2 ) 2,312,753.44 print number_format( 2312753.4451, 2 ) 2,312,753.45 I would expect the first to produce the same results as the second, but, I suppose because of one of floating point's features, it doesn't work

Re: how to remove BR using replace function?

2006-02-09 Thread Sion Arrowsmith
Duncan Booth [EMAIL PROTECTED] wrote: Although I generally advise against overuse of regular expressions, this is one situation where regular expressions might be useful: [ ... ] nobr = re.compile('\W*br.*?\W*', re.I) Agreed (on both counts), but r'\s*br.*?\s*' might be better (consider what

Re: apostrophe or double quote?

2006-02-09 Thread Sion Arrowsmith
Terry Hancock [EMAIL PROTECTED] wrote: [EMAIL PROTECTED] wrote: Just to present a complete picture, not mentioned in this thread are triple-quoted strings: [ ... ] Also in the mode of beating a dead horse ... ;-) Some people prefer to use single quotes for 'labels' (i.e. a name which is

Re: Finding the public callables of self

2006-02-09 Thread Sion Arrowsmith
Russell Warren [EMAIL PROTECTED] wrote: Is there any better way to get a list of the public callables of self other than this? myCallables = [] classDir = dir(self) for s in classDir: attr = self.__getattribute__(s) if callable(attr) and (not s.startswith(_)):

Re: apostrophe or double quote?

2006-02-08 Thread Sion Arrowsmith
Steve Holden [EMAIL PROTECTED] wrote: Huy wrote: I've been unable to find information clarifying this but. What is the difference between 'somestring' and somestring? It's just easier to have two permitted string quotes. That way, if your string has an apostrophe in it you can say s =

Re: 450 Pound Library Program

2006-02-08 Thread Sion Arrowsmith
mwt [EMAIL PROTECTED] wrote: while len(self.stacks) == 0: To (kind of) repeat myself, the idiomatic Python would be: while not self.stacks: An empty list is considered to be false, hence testing the list itself is the same as testing len(l) 0 . As someone else has noticed,

Re: Code Feedback

2006-02-07 Thread Sion Arrowsmith
mwt [EMAIL PROTECTED] wrote: 1) Is this good Python code? What should be changed to make it more Pythonesque? while not len(self.stacks) 0: while not self.stacks: An empty list is considered to be false, hence testing the list itself is the same as testing len(l) 0 . -- \S

Re: While loop - print several times but on 1 line.

2006-01-26 Thread Sion Arrowsmith
Danny [EMAIL PROTECTED] wrote: The programs output will be: text text (etc) How could I make this print: texttexttexttexttext? Ive researched and looked through google and so far I can't find anything that will help (or revelent for that matter). I'm kind of surprised this isn't a FAQ (if it's

Re: append to the end of a dictionary

2006-01-25 Thread Sion Arrowsmith
Magnus Lycka [EMAIL PROTECTED] wrote: orderedListOfTuples = [(k,mydict[k]) for k in sorted(mydict.keys())] Or: orderedListOfTuples = [(k,v) for k,v in sorted(mydict.items())] (k, mydict[k]) sets off warning bells for me that mydict.items() should be in use, which are nearly as loud as the ones

Re: append to the end of a dictionary

2006-01-25 Thread Sion Arrowsmith
I wrote: orderedListOfTuples = [(k,v) for k,v in sorted(mydict.items())] (k, mydict[k]) sets off warning bells for me that mydict.items() should be in use [ ... ] But apparently [ x for x in mylist ] doesn't yet trigger such a warning. -- \S -- [EMAIL PROTECTED] --

Re: Backreferences in python ?

2006-01-24 Thread Sion Arrowsmith
Pankaj [EMAIL PROTECTED] wrote: search for :for ( i = 0; i 10; i++) Replace with: for( printf( 10 ), i =0; i 10; i++) Where 10 is the line no. f = open( ./1.c, r) fNew = open( ./1_new.c, w) for l in f: print l lineno = lineno + 1 strToFind = for\((.*)\;(.*) [etc.]

Re: append to the end of a dictionary

2006-01-24 Thread Sion Arrowsmith
Tim Chase [EMAIL PROTECTED] wrote: unless you have a way of doing an in-line sort, in which you would be able to do something like orderedDict = [(k,mydict[k]) for k in mydict.keys().sort()] Unfortunately, the version I've got here doesn't seem to support a sort() method for the list

Re: flatten a level one list

2006-01-12 Thread Sion Arrowsmith
In article [EMAIL PROTECTED], Paul Rubin http://[EMAIL PROTECTED] wrote: Robin Becker [EMAIL PROTECTED] writes: reduce(operator.add,a) ... That's what I hoped sum would do, but instead it barfs with a type error. So much for duck typing. sum(...) sum(sequence, start=0) - value If you're

Re: Bitching about the documentation...

2005-12-08 Thread Sion Arrowsmith
Steven D'Aprano [EMAIL PROTECTED] wrote: Buffalo buffalo Buffalo buffalo buffalo buffalo Buffalo buffalo. S P O I L E R S P A C E (Good grief, I've not done that in *years*.) Buffalo from the city of Buffalo, which are intimidated by buffalo from Buffalo, also intimidate buffalo from

Re: i=2; lst=[i**=2 while i1000]

2005-12-06 Thread Sion Arrowsmith
[EMAIL PROTECTED] wrote: Bengt Richter wrote: list(iter(lambda b=[2]:b.append(b[0]**2) or b[0]1000 and b.pop(0) or None, None)) [2, 4, 16, 256] out of curiosity, what stops the iterator ? http://docs.python.org/lib/built-in-funcs.html: iter(o, sentinel) [ ... ] The iterator created in

Re: about sort and dictionary

2005-11-23 Thread Sion Arrowsmith
[EMAIL PROTECTED] [EMAIL PROTECTED] wrote: OKB (not okblacke) wrote: Fredrik Lundh wrote: [EMAIL PROTECTED] wrote: [ ... ] so what would an entry-level Python programmer expect from this piece of code? for item in a.reverse(): print item for item in

Re: What do you use as symbols for Python ?

2005-11-11 Thread Sion Arrowsmith
Gary Herron [EMAIL PROTECTED] wrote: Another similar approach that keeps those values together in a single namespace is this (my favorite): class State: OPENED, CLOSED, ERROR = range(3) Then you can refer to the values as State.OPENED State.CLOSED State.ERROR The extra

Re: help make it faster please

2005-11-11 Thread Sion Arrowsmith
[EMAIL PROTECTED] wrote: Oh sorry indentation was messed here...the wordlist = countDict.keys() wordlist.sort() should be outside the word loop now def create_words(lines): cnt = 0 spl_set = '[,;{}_?!():-[\.=+*\t\n\r]+' for content in lines: words=content.split()

Re: which feature of python do you like most?

2005-11-08 Thread Sion Arrowsmith
[EMAIL PROTECTED] [EMAIL PROTECTED] wrote: which feature of python do you like most? A different thing every time I encounter the corresponding misfeature in another language. But a lot of it boils down to the cleanliness of syntax when handling complex datastructures aggregated from basic types,

Re: strange sockets

2005-11-04 Thread Sion Arrowsmith
In article [EMAIL PROTECTED], Skink [EMAIL PROTECTED] wrote: % python client.py client.py client.py client.py server.py server.py init 0.00066089630127 client.py 0.000954866409302 client.py 0.0408389568329 client.py 0.0409188270569 server.py 0.0409059524536 server.py 0.0409259796143 what's wrong

Re: Python and MySQL

2005-11-03 Thread Sion Arrowsmith
Aquarius [EMAIL PROTECTED] wrote: I want to know if there is a way to interface a MySQL database without Python-MySQL or without installing anything that has C files that need to be compiled. The reason for this, is that I want to develop a certain web application, but my hosting provider ([EMAIL

Re: Python vs Ruby

2005-10-21 Thread Sion Arrowsmith
bruno modulix [EMAIL PROTECTED] wrote: Casey Hawthorne [EMAIL PROTECTED] wrote in message news:[EMAIL PROTECTED] I have heard, but have not been able to verify that if a program is about 10,000 lines in C++ it is about 5,000 lines in Java and it is about 3,000 lines in Python (Ruby to?) For a

Re: [Info] PEP 308 accepted - new conditional expressions

2005-10-03 Thread Sion Arrowsmith
Ron Adam [EMAIL PROTECTED] wrote: So ... A if B else C + X * Y Would evaluate as... ? A if B else (C + X * Y) In general, 'if' and 'else' bind less tight than everything except lambda. http://mail.python.org/pipermail/python-dev/2005-September/056846.html -- \S -- [EMAIL PROTECTED]

Re: how to send a SIGINT to a Python process?

2005-10-03 Thread Sion Arrowsmith
Michele Simionato [EMAIL PROTECTED] wrote: Is there a way to send a SIGINT/KeyboardInterrupt to a Python process (knowing the pid) that works both on Unix and Windows? No. Windows doesn't support the sending of signals between processes (with the exception of an equivalent of SIGKILL). I guess

Re: What python idioms for private, protected and public?

2005-09-30 Thread Sion Arrowsmith
Michael Schneider [EMAIL PROTECTED] wrote: I have been coding in C++ since the late 80's and Java since the late 90's. I do use private in these languages, with accessors to get at internal data. This has become an ingrained idiom for me. The question is, has it become a purely instinctive

Re: What is self?

2005-09-23 Thread Sion Arrowsmith
Rick Wotnaz [EMAIL PROTECTED] wrote: I've long thought that Guido missed an opportunity by not choosing to use 'i' as the instance identifier, and making it a reserved word. For one thing, it would resonate with the personal pronoun 'I', and so carry essentially the same meaning as 'self'. It

Re: round() wrong in Python 2.4?

2005-09-13 Thread Sion Arrowsmith
Nils Grimsmo [EMAIL PROTECTED] wrote: Why did round() change in Python 2.4? $ python2.3 Python 2.3.5 (#2, Jun 19 2005, 13:28:00) [GCC 3.3.6 (Debian 1:3.3.6-6)] on linux2 round(0.0225, 3) 0.023 %.3f % round(0.0225, 3) '0.023' $ python2.4 Python 2.4.1 (#2, Jul 12 2005, 09:22:25) [GCC 4.0.1

Re: Is my thread safe from premature garbage collection?

2005-09-01 Thread Sion Arrowsmith
In article [EMAIL PROTECTED], Benjamin Niemann [EMAIL PROTECTED] wrote: [EMAIL PROTECTED] wrote: However, in my current project I'm creating a bunch of threads which are supposed to run until they've completed their run() method, and I'm worried that if I do not keep references to these thread

Re: Creating custom event in WxPython

2005-09-01 Thread Sion Arrowsmith
[EMAIL PROTECTED] wrote: Now when my socket thread detects an incoming message, I need my main thread to interpret the message and react to it by updating the GUI. IMO the best way to achieve this is by having my socket thread send a custom event to my application's event loop for the main thread

Re: newbie question: convert a list to one string

2005-08-25 Thread Sion Arrowsmith
[EMAIL PROTECTED] wrote: I'm searching for the fastest way to convert a list to one big string. The join() method of strings. The string instance in question being the separator you want, so: .join(test) -- \S -- [EMAIL PROTECTED] -- http://www.chaos.org.uk/~sion/ ___ | Frankly I have no

Re: RE Despair - help required

2005-08-25 Thread Sion Arrowsmith
In article [EMAIL PROTECTED], Yoav [EMAIL PROTECTED] wrote: Fredrik Lundh wrote: Yoav wrote: I am trying the following: re.search(r'\\[^\\]+(?=(?$))', c:\ret_files) instead of struggling with weird REs, why not use Python's standard filename manipulation library instead?

Re: Network performance

2005-08-23 Thread Sion Arrowsmith
Roland Hedberg [EMAIL PROTECTED] wrote: [ ... ] The client sends a number of lines (each ending with \n) and ends one set of lines with a empty line. When the client sends a line with only a . it means I'm done close the connection. Letting the client open the connection and sending a

Re: Newbie Question

2005-08-19 Thread Sion Arrowsmith
Tom Strickland [EMAIL PROTECTED] wrote: I have a file that contains many lines, each of which consists of a string of comma-separated variables, mostly floats but some strings. Each line looks like an obvious tuple to me. How do I save each line of this file as a tuple rather than a string? Or,

Re: searching a list of dictionaries for an element in a list.

2005-08-10 Thread Sion Arrowsmith
Dan [EMAIL PROTECTED] wrote: [ someone else wrote: ] I want to search list1, and the result should be all dictionaries where primarycolor is in input. I can do this using a double for-loop, but is there a more efficent way? Of course.:-) L = [dict for dict in list1 if

Re: What are modules really for?

2005-08-10 Thread Sion Arrowsmith
infidel [EMAIL PROTECTED] wrote: [ somebody else wrote: ] To my mind, although one CAN put many classes in a file, it is better to put one class per file, for readability and maintainability. Personally I find it easier to maintain a set of related classes when they're all in the same file.

Re: Dabo in 30 seconds?

2005-08-02 Thread Sion Arrowsmith
James Stroud [EMAIL PROTECTED] wrote: Perhaps some of us are writing software with non-developer end-users in mind and we kind of keep that mentality when evaluating modules our code uses. In the commercial environment I'm working in, non-developer end-users get a frozen executable. They don't

Re: multiple inheritance super()

2005-07-28 Thread Sion Arrowsmith
Reinhold Birkenfeld [EMAIL PROTECTED] wrote: Michele Simionato wrote: was I going to design a new language I would implement it *without* multiple inheritance). That way lies Java. The number of times I've wished an interface were actually a mixin *shudder* Multiple inheritance can be

Re: more newbie list questions

2005-07-14 Thread Sion Arrowsmith
Bernhard Holzmayer [EMAIL PROTECTED] wrote: googleboy wrote: I have a cell.txt file that looks like this: ++ The title is %title%. brbr The author is %author1% %author2% brbr The Publisher is %publisher1% %publisher2% brbr The ISBN is %ISBN% brbr ++ This looks like a DOS-batch-file.

Re: Consecutive Character Sequences

2005-07-14 Thread Sion Arrowsmith
Aries Sun [EMAIL PROTECTED] wrote: I used Python 2.4.1, the following are the command lines. But the reslut was still False. Is there anything wrong with below codes? import itertools as it def hasConsequent(aString, minConsequent): for _,group in it.groupby(aString): if

Re: Strange os.path.exists() behaviour

2005-07-07 Thread Sion Arrowsmith
Jeff Epler [EMAIL PROTECTED] wrote: Pierre wrote: Python 2.4 (#60, Nov 30 2004, 11:49:19) [MSC v.1310 32 bit (Intel)] on wi= n32 = ^^^ Here's the bug. You're using Windows. It's a filesystem, but not as we kn= ow it...

Re: map/filter/reduce/lambda opinions and background unscientific mini-survey

2005-07-07 Thread Sion Arrowsmith
=?ISO-8859-2?Q?Pawe=B3?= Sakowski [EMAIL PROTECTED] wrote: ll=[[1,2],[3,4,5],[6]] sum(ll,[]) [1, 2, 3, 4, 5, 6] That's a great argument for list.__add__ having the semantics of extend rather than append 8-) -- \S -- [EMAIL PROTECTED] -- http://www.chaos.org.uk/~sion/ ___ | Frankly I have

Re: map vs. list-comprehension

2005-07-01 Thread Sion Arrowsmith
Tom Anderson [EMAIL PROTECTED] wrote: On Thu, 30 Jun 2005, Roy Smith wrote: Even some of the relatively recent library enhancements have been kind of complicated. The logging module, for example, seems way over the top. Exactly the same thing happened with Java. I was under the impression

Re: Inheriting from object

2005-06-30 Thread Sion Arrowsmith
Bruno Desthuilliers [EMAIL PROTECTED] wrote: Fuzzyman a écrit : *Should* I in fact write : class foo(object): def __init__(self, *args, **kwargs): object.__init__(self) ? Nope. And if you were to do so, surely: class foo(object): def __init__(self, *args, **kwargs):

Re: also to balance else ?

2005-06-14 Thread Sion Arrowsmith
Fredrik Lundh [EMAIL PROTECTED] wrote: Ron Adam wrote: True, but I think this is considerably less clear. The current for-else is IMHO is reversed to how the else is used in an if statement. nope. else works in exactly the same way for all statements that support it: if the controlling

Re: Just remember that Python is sexy

2005-05-26 Thread Sion Arrowsmith
Duncan Booth [EMAIL PROTECTED] wrote: Ville Vainio wrote: Peter == Peter Hansen [EMAIL PROTECTED] writes: Peter Sion Arrowsmith wrote: But can you come up with a method for remembering which way round str.find() and str.index() are? Peter Don't use str and you won't have

Re: Just remember that Python is sexy

2005-05-25 Thread Sion Arrowsmith
Scott Kirkwood [EMAIL PROTECTED] wrote: I often can't remember that to remove spaces from a string whether it's strip() or trim(), and when finding patterns with the re library whether it's find() or search() and when iterating over key, values of a dictionary whether it's items() or entries().

Re: Regarding Mail sending smtplib Module

2005-05-11 Thread Sion Arrowsmith
praba kar [EMAIL PROTECTED] wrote: Here I want to avoid this line Received: from unknown (HELO prabahar.enmail.com) (59.92.13.47) by mailserver with SMTP; 11 May 2005 10:09:11 - How can I do this? . Why python give this line? . Mail sending Module in php will not give this type line.

Re: Advice needed on __del__

2005-05-10 Thread Sion Arrowsmith
=?ISO-8859-1?Q?Andr=E9_Roberge?= [EMAIL PROTECTED] wrote: If I need to have the user call Evil.destroy() as Evil is getting out of scope, it would miss the whole point of teaching about the natural way scope and namespace work. The problem, it seems to me, is that in Python scope applies to

Re: what is the best way to determine system OS?

2005-04-25 Thread Sion Arrowsmith
Philippe C. Martin [EMAIL PROTECTED] wrote: How about popen of 'uname -r' ? os.uname()[2] is probably a better way (ie it doesn't spawning another process) of getting this information. I don't think it will help the original poster though (depending on *what* it is about FC3 which is breaking

Re: Why Python does *SLICING* the way it does??

2005-04-20 Thread Sion Arrowsmith
Raymond Hettinger [EMAIL PROTECTED] wrote: [EMAIL PROTECTED] Many people I know ask why Python does slicing the way it does. Python's way has some useful properties: * s == s[:i] + s[i:] * len(s[i:j]) == j-i # if s is long enough The latter being particularly helpful when i = 0 -- the

Re: curious problem with large numbers

2005-04-08 Thread Sion Arrowsmith
Michael Spencer [EMAIL PROTECTED] wrote: Terry Reedy wrote: Chris Fonnesbeck [EMAIL PROTECTED] wrote However, on Windows (have tried on Mac, Linux) I get the following behaviour: inf = 1e1 inf 1.0 On my Windows machine with 2.2.1, I get exactly what you expected: 1e1 1.#INF On my

Re: injecting set into 2.3's builtins?

2005-03-11 Thread Sion Arrowsmith
Stephen Thorne [EMAIL PROTECTED] wrote: I have: try: set except NameError: from sets import Set as set in my code in a few places. Is there any reason to prefer this over the idiom I have: if sys.version_info (2, 4): from sets import Set as set ? (I've also used the same kind of

Re: Problem with the sort() function

2005-02-22 Thread Sion Arrowsmith
clementine [EMAIL PROTECTED] wrote: Thanx Nick...I forgot to mention im using python 2.2 and along with a host of other things it doesnt seem to have the enumarate built in function :(:(:(...is it possible to replace it by something else? I dont think simulating it will be feasible Here's one

Re: Stable GUI + wxPython memory leak

2005-02-17 Thread Sion Arrowsmith
Peter Hansen [EMAIL PROTECTED] wrote: Viktor wrote: I just noticed that wxPython is leaking memory?! Playing with wxPython-demo, I started with 19MB used, and ended whith almost 150MB used?! It's wxPython 2.5.3.1 running on Python 2.4. On which platform? And how are you measuring this

Re: Why doesn't join() call str() on its arguments?

2005-02-17 Thread Sion Arrowsmith
In article [EMAIL PROTECTED], ! Nick Vargish [EMAIL PROTECTED] wrote: If a non-string-type has managed to get into my list-of-strings, then something has gone wrong and I would like to know about this potential problem. Thinking about where I use join(), I agree. If there's something other

Re: Install MySQLdb on Mac OS X (10.3)

2005-02-11 Thread Sion Arrowsmith
Skip Montanaro [EMAIL PROTECTED] wrote: Try a more recent version of mysql-python. I think 1.1.7 is the latest. 1.2.0 -- it appears to be moving extremely rapidly (especially given how long it was at 0.9.2 -- although Waiting for MySQL 4.1 to become stable would be a good explanation for that).

Re: turing machine in an LC

2005-02-10 Thread Sion Arrowsmith
Greg Ewing [EMAIL PROTECTED] wrote: As a fellow named Church once pointed out, lambdas are really *all* you need in a language... ... where as others argue that it is impractical not to have some form of runtime data storage, thereby giving rise to the separation of Church and state. -- \S --

Re: RE:private variables a.k.a. name mangling (WAS: What is print? A function?)

2005-01-25 Thread Sion Arrowsmith
Jeremy Bowers [EMAIL PROTECTED] wrote: [ ... ] the Python community, and in general the dynamic language community, has become increasingly confident that private variables don't solve *real* problems. Years of writing and maintaining others' C++ and Java code (plus one year of maintaining

Re: What YAML engine do you use?

2005-01-24 Thread Sion Arrowsmith
Paul Rubin http://[EMAIL PROTECTED] wrote: YAML looks to me to be completely insane, even compared to Python lists. I think it would be great if the Python library exposed an interface for parsing constant list and dict expressions, e.g.: [1, 2, 'Joe Smith', 8237972883334L, # comment

Re: What is print? A function?

2005-01-24 Thread Sion Arrowsmith
Michael Hoffman [EMAIL PROTECTED] wrote: Frans Englich wrote: Nah, I don't think it's a function, but rather a builtin statement. But it's possible to invoke it as an function; print( test ) works fine. That is not invoking it as a function. The parentheses are only for ordering the

Re: Why no list heritable type?

2004-12-17 Thread Sion Arrowsmith
In article [EMAIL PROTECTED], Mike Meyer [EMAIL PROTECTED] wrote: And before Python 2.2 there was the UserList class in the standard library. Which is still there in 2.4. Shouldn't it be depreciated by this point? Apart from compatibility issues as mentioned in the UserList documentation,

Re: wxPython bug

2004-12-10 Thread Sion Arrowsmith
Jive [EMAIL PROTECTED] wrote: In wxPython 2.5, run the demo, samples/wxProject/wxProject.py [ ... ] TypeError: TreeCtrl_GetFirstChild() takes exactly 2 arguments (3 given) GetFirstChild() changed from taking 2 arguments in wxPython 2.4 to (the more sensible) 1 in wxPython 2.5. Clearly wxProject

<    1   2   3