Re: Lambda going out of fashion

2004-12-23 Thread Fredrik Lundh
Craig Ringer wrote: > It's hard to consistently support Unicode in extension modules without > doing a lot of jumping through hoops. Unicode in docstrings is > particularly painful. This may not be a big deal for normal extension > modules, but when embedding Python it's a source of considerable

Re: Why are tuples immutable?

2004-12-23 Thread Antoon Pardon
Op 2004-12-22, Jeff Shannon schreef <[EMAIL PROTECTED]>: > Antoon Pardon wrote: > >>Op 2004-12-21, Jeff Shannon schreef <[EMAIL PROTECTED]>: >> >> >>How does the dict know which value is associated with which key? >> >> >> >>Because there is a link between the key and the value. The problem >>

deriving from str

2004-12-23 Thread Paolo Veronelli
I want to add some methods to str class ,but when I change the __init__ methods I break into problems class Uri(str): def __init__(self,*inputs): print inputs if len(inputs)>1: str.__init__(self,'<%s:%s>'%inputs[:2])

Replacing lambda() examples... (Re: Lambda going out of fashion)

2004-12-23 Thread Petr Prikryl
Hi, I suggest to post here simplified examples that use the lambda to be replaced by non-lambda Pythonic solutions. The ideal result would be the set of rules, how lambdas can be replaced by in future when they become deprecated. Less ideal but valuable may be short examples and counter-example

Re: Lambda going out of fashion

2004-12-23 Thread Alex Martelli
Keith Dart <[EMAIL PROTECTED]> wrote: > My personal gripe is this. I think the core language, as of 2.3 or 2.4 > is very good, has more features than most people will ever use, and they Indeed, it has _too many_ features. Look at the PEP about 3.0, and you'll see that removing redundant features

Re: list IndexError

2004-12-23 Thread Peter Otten
Steven Bethard wrote: > I thought it might be helpful to code some of the alternatives you've > been given and look at the timings to put things into perspective. The > code: > > remove.py > def remove_lc(x, lst): > lst[:] = [item for item in lst if

Re: Problem with os.listdir and delay with unreachable network drives on Windows

2004-12-23 Thread Andrey Ivanov
[Read Roberts] > I wrote my own directory browser in order to get around a bug where > tkFileDialog.askdirectory() can't handle non-ascii paths. However, I > have a problem where I call os.listdir() on a mapped network drive, > e.g. os.listdir("Z:\\"), and if the network drive is unavailable, th

Re: list IndexError

2004-12-23 Thread Nick Coghlan
Steven Bethard wrote: Ishwor wrote: i am trying to remove an item 'e' from the list l I thought it might be helpful to code some of the alternatives you've been given and look at the timings to put things into perspective. The code: remove.py def remov

Re: list IndexError

2004-12-23 Thread Nick Coghlan
Peter Otten wrote: I do not think it measures what you think it measures. Ah, good point. . . so we were actually measuring how long it takes to make zero replacements on the modified list, which explains the downward trend of the timings (as the modified list gets shorter). Adding the list copy

Re: Lambda going out of fashion

2004-12-23 Thread Alan Gauld
On Thu, 23 Dec 2004 14:13:28 +1000, Stephen Thorne <[EMAIL PROTECTED]> wrote: > I'm a little worried about the expected disappearance of lambda in > python3000. I've had my brain badly broken by functional programming > in the past, and I would hate to see things suddenly become harder > than they

Re: regular expression: perl ==> python

2004-12-23 Thread Nick Craig-Wood
Fredrik Lundh <[EMAIL PROTECTED]> wrote: > that's not a very efficient way to match multiple patterns, though. a > much better way is to combine the patterns into a single one, and use > the "lastindex" attribute to figure out which one that matched. lastindex is useful, yes. > see > >

Re: Lambda going out of fashion

2004-12-23 Thread Alan Gauld
On 22 Dec 2004 23:21:37 -0800, [EMAIL PROTECTED] wrote: > but if lambda keyword is removed, I swear I will not use the python > anymore. While I would be dissappointed to lose lambda, I think losing Python would hurt me a lot more! After all we aren't losing functionality here, just adding sonme

Re: Lambda going out of fashion

2004-12-23 Thread Paul Rubin
Alan Gauld <[EMAIL PROTECTED]> writes: > readability. Pythonic lambdas are just syntactic sugar in > practice, Actually it's the other way around: it's named functions that are the syntactic sugar. -- http://mail.python.org/mailman/listinfo/python-list

Optional Static Typing

2004-12-23 Thread bearophileHUGS
Adding Optional Static Typing to Python looks like a quite complex thing, but useful too: http://www.artima.com/weblogs/viewpost.jsp?thread=85551 I have just a couple of notes: Boo (http://boo.codehaus.org/) is a different language, but I like its "as" instead of ":" and "->", to have: def min(a

RE: Metaclasses

2004-12-23 Thread Bob . Cowdery
Title: RE: Metaclasses Robert Brewer wrote: >Okay. It depends on where you're getting that capability information from, but the simplest approach I can > >think of would be to stick it in the class: > >class API(object): >    __metaclass__ = MetaAPI >    >    capmap = global_map_getter(userco

Re: (Mac-specific) AppScript bug

2004-12-23 Thread has
George van den Driessche wrote: > (This is really for Hamish Sanderson, I think, but I can't find an > e-mail address for him.) No worries. (Email addy is buried in appscript-0.7.1 > Manual.txt > Authors, though some releases listed a duff address which certainly didn't help. Better documentation

RE: Metaclasses

2004-12-23 Thread Bob . Cowdery
Title: RE: Metaclasses Shalabh Yes I am realising there are variaous ways to achieve the same end. I guess I am in research mode at the moment and understanding what metaclasses can do is important even if I end up not using them. There is another thread on this question where I am trying to

Re: Lambda going out of fashion

2004-12-23 Thread Alex Martelli
Craig Ringer <[EMAIL PROTECTED]> wrote: ... > Couldn't agree more. One of the things I find most valuable about Python > is the ability to use functional style where it's the most appropriate > tool to solve a problem - WITHOUT being locked into a pure-functional > purist language where I have t

Re: Tabnanny really useful?

2004-12-23 Thread Stuart Bishop
-BEGIN PGP SIGNED MESSAGE- Hash: SHA1 Franz Steinhaeusler wrote: | Not really soo useful, because most syntax and also indentation errors | are actually detected by invoking python, i.e. the command compile. | But as combination for this: yes why not. | I looked for Stanis spe editor, which

Re: Why are tuples immutable?

2004-12-23 Thread Antoon Pardon
Op 2004-12-22, Jeff Shannon schreef <[EMAIL PROTECTED]>: > Antoon Pardon wrote: > >>Op 2004-12-21, Jeff Shannon schreef <[EMAIL PROTECTED]>: >> >> >>>Antoon Pardon wrote: >>> >>> >>>So show us a dictionary (i.e. hash table) implementation that can do >>>this. >>> >>> >> >>Why should I, D

Re: Lambda going out of fashion

2004-12-23 Thread Stephen Thorne
On 23 Dec 2004 00:52:53 -0800, Paul Rubin <"http://phr.cx"@nospam.invalid> wrote: > Alan Gauld <[EMAIL PROTECTED]> writes: > > readability. Pythonic lambdas are just syntactic sugar in > > practice, > > Actually it's the other way around: it's named functions that are the > syntactic sugar. Not t

Re: Jython performance

2004-12-23 Thread Kent Johnson
Sean Blakey wrote: On Wed, 22 Dec 2004 17:03:55 -0200, Gabriel Cosentino de Barros <[EMAIL PROTECTED]> wrote: On the "Best GUI for small-scale accounting app?" tread some people mentioned jython. I went to read about it, but i was wondering if anyone has any real project done with it and can give r

Re: regular expression: perl ==> python

2004-12-23 Thread Fredrik Lundh
Nick Craig-Wood wrote: > I take your point. However I don't find the below very readable - > making 5 small regexps into 1 big one, plus a game of count the > brackets doesn't strike me as a huge win... if you're doing that a lot, you might wish to create a helper function. the undocumented sre.

Re: PHP vs. Python

2004-12-23 Thread JZ
Dnia Wed, 22 Dec 2004 20:57:07 -0500, Robert Kern napisał(a): > I think he means, "scale to larger programs," not "scale to more > processors." Yes. I will try to be more specific. There is several reasons why Python scales better than PHP. (1) Python uses namespaces, PHP - not. The bigger pro

Re: Lambda going out of fashion

2004-12-23 Thread Fredrik Lundh
Stephen Thorne wrote: > Not true, you can't re-write > > def f(): >raise ValueError, "Don't call f" f = lambda: eval(compile("raise ValueError(\"Don't call f\")", "", "exec")) note that lambdas have names too, btw: print f.func_name -- http://mail.python.org/mailman/list

Re: Mutable objects which define __hash__ (was Re: Why are tuples immutable?)

2004-12-23 Thread Antoon Pardon
Op 2004-12-22, Nick Coghlan schreef <[EMAIL PROTECTED]>: >> I'm currently not under the impression I'm able to. Sure I could >> implement the above mentioned classes, but my feeling is that >> should I present them here, nobody would be waiting for them. >> Not because they would be unusfull, but b

Re: Lambda going out of fashion

2004-12-23 Thread Nick Coghlan
Alan Gauld wrote: It can't be that hard to maintain the lambda code, why not just leave it there for the minority of us who like the concept? Because one of the points of Py3K is to clean up the language concepts and syntax, and the current lambda just doesn't fit cleanly. If it was proposed in a

Re: mathmatical expressions evaluation

2004-12-23 Thread Kent Johnson
Tonino wrote: thanks all for the info - and yes - speed is not really an issue and no - it is not an implementation of a complete financial system - but rather a small subset of a investment portfolio management system developed by "another company" ... What I am trying to achieve is to parse a for

Re: Lambda going out of fashion

2004-12-23 Thread Alex Martelli
Alan Gauld <[EMAIL PROTECTED]> wrote: ... > It can't be that hard to maintain the lambda code, why not just > leave it there for the minority of us who like the concept? I guess the key motivator is the usual set of design principles: 3. Keep the language small and simple.

Re: Lambda going out of fashion

2004-12-23 Thread Fredrik Lundh
Alex Martelli wrote: > I think I'll scream, though not quite as loud as for my next seeing: > > map(lambda x: f(x), ... > > instead of > > map(f, ... note that if you replace "map" with "some function that takes a callable", the difference between these two constructs may be crucially important.

Re: Why are tuples immutable?

2004-12-23 Thread Alex Martelli
Jeff Shannon <[EMAIL PROTECTED]> wrote: ... > But, you generally don't "retrieve" _keys_ from dicts. You *use* keys > to retrieve *values* from a dict. The only way to get a dict to give > you a key is by using the keys() method (or items() method) to give you > *all* of the keys. There are

Re: Mutable objects which define __hash__ (was Re: Why are tuples immutable?)

2004-12-23 Thread Antoon Pardon
Op 2004-12-23, Nick Coghlan schreef <[EMAIL PROTECTED]>: > Steven Bethard wrote: >> Of course, if rehash worked in place, you could probably do some >> optimizations to only rehash the necessary items. > > Yep, especially given this little critter from dictobject.h which contains > everything nee

Re: Python on Linux Cluster

2004-12-23 Thread Irmen de Jong
Gurpreet Sachdeva wrote: I have shifted my python script on a 4 node open ssi cluster. Please guide me what changes do I have to do in my python scripts to fully utilize the cluster. How do we introduce parralel processing in python??? There was a very recent thread about this subject: http://tinyu

Re: Keyword arguments - strange behaviour?

2004-12-23 Thread brian . bird
> Channelling the effbot, I think he was asking what namespace context you > expected the expression "arg=otherfunction(x)" to be evaluated in when > it's used at the time of a function call to dynamically create a new > default value for arg. Thanks, I realise now that's what was meant. I think I

Re: deriving from str

2004-12-23 Thread Nick Coghlan
Paolo Veronelli wrote: I want to add some methods to str class ,but when I change the __init__ methods I break into problems class Uri(str): def __init__(self,*inputs): print inputs if len(inputs)>1: str.__init__(self,'<%s:%s>'%inputs[:2]) else:

Re: Keyword arguments - strange behaviour?

2004-12-23 Thread Fuzzyman
[EMAIL PROTECTED] wrote: > > Channelling the effbot, I think he was asking what namespace context > you > > expected the expression "arg=otherfunction(x)" to be evaluated in > when > > it's used at the time of a function call to dynamically create a new > > default value for arg. > > Thanks, I rea

Re: Keyword arguments - strange behaviour?

2004-12-23 Thread Fuzzyman
[EMAIL PROTECTED] wrote: > > Channelling the effbot, I think he was asking what namespace context > you > > expected the expression "arg=otherfunction(x)" to be evaluated in > when > > it's used at the time of a function call to dynamically create a new > > default value for arg. > > Thanks, I rea

Re: Keyword arguments - strange behaviour?

2004-12-23 Thread Fuzzyman
Steven Bethard wrote: > [EMAIL PROTECTED] wrote: > > However, is there a good reason why default parameters aren't evaluated > > as the function is called? (apart from efficiency and backwards > > compatibility)? > > So, one of my really common use cases that takes advantage of the fact > that def

Reading and Writing

2004-12-23 Thread elias . goodman
I am new to Python and programming. I am looking for some basic instruction here. How should I: Open a Text file, read from it, modify it, print to another .txt? For instance: Read a string, sort it, write the sorted string. I understand the algorithms but I don't know the actual mechanics of P

Re: Mutable objects which define __hash__ (was Re: Why are tuples immutable?)

2004-12-23 Thread Nick Coghlan
Antoon Pardon wrote: I don't think I would recommend adding hash methods to mutable builtins. Storing keys by identity or value both can make sense for these kind of objects. And since python prefers not to guess I think it is a good thing there is no default hash for mutable objects. In that case,

Re: Mutable objects which define __hash__ (was Re: Why are tuples immutable?)

2004-12-23 Thread Nick Coghlan
Antoon Pardon wrote: I don't understand why the ease of mutating an object that should remain stable should cause more unease in a person just because the subject is dictionary keys, except maybe because of custom. But I'm obviously in the minority here. Nah - just fighting against long-held assump

Re: Lambda going out of fashion

2004-12-23 Thread Peter Otten
Alex Martelli wrote: > if len(somecontainer) > 0: > > instead of the obvious > > if somecontainer: > > so it's not as if pythonistas in general are blessed with some magical > "redundancy avoidance spell"... That is not always equivalent: >>> z = Numeric.zeros(5) >>> z array([0, 0, 0, 0, 0])

Re: Lambda going out of fashion

2004-12-23 Thread Alex Martelli
Fredrik Lundh <[EMAIL PROTECTED]> wrote: > Alex Martelli wrote: > > > I think I'll scream, though not quite as loud as for my next seeing: > > > > map(lambda x: f(x), ... > > > > instead of > > > > map(f, ... > > note that if you replace "map" with "some function that takes a callable", > the di

Re: Newbie namespace question

2004-12-23 Thread Brandon
I did the constructor thing and just didn't like it, it didn't feel clean (I know, I know and monkeying with __builtin__ is?) As for global, that will just make it modlue-level global (I think?) and I have this reference in multiple modules. I think I tried it already, but I can't remember for su

Re: Lambda going out of fashion

2004-12-23 Thread jfj
Stephen Thorne wrote: Hi guys, I'm a little worried about the expected disappearance of lambda in python3000. I've had my brain badly broken by functional programming in the past, and I would hate to see things suddenly become harder than they need to be. Don't worry, it's not gonna go away because

Re: Reading and Writing

2004-12-23 Thread Sir Galahad the chaste
Hi, [EMAIL PROTECTED] wrote: How should I: Open a Text file, read from it, modify it, print to another .txt? For instance: Read a string, sort it, write the sorted string. What do you mean by "sorting"? If you want to sort the lines contained in a file, you could do something like this. $ cat in.

Re: Lambda going out of fashion

2004-12-23 Thread Alex Martelli
Peter Otten <[EMAIL PROTECTED]> wrote: > Alex Martelli wrote: > > > if len(somecontainer) > 0: > > > > instead of the obvious > > > > if somecontainer: > > > > so it's not as if pythonistas in general are blessed with some magical > > "redundancy avoidance spell"... > > That is not always eq

Re: Lambda going out of fashion

2004-12-23 Thread Nick Coghlan
jfj wrote: Stephen Thorne wrote: Hi guys, I'm a little worried about the expected disappearance of lambda in python3000. I've had my brain badly broken by functional programming in the past, and I would hate to see things suddenly become harder than they need to be. Don't worry, it's not gonna go a

Re: Lambda going out of fashion

2004-12-23 Thread Alex Martelli
Nick Coghlan <[EMAIL PROTECTED]> wrote: ... > Perhaps something like: > > accepts_func( (def (a, b, c) to f(a) + o(b) - o(c)) ) Nice, except I think 'as' would be better than 'to'. 'as' should be a full keyword in 3.0 anyway (rather than a surprisingly-NOT-keyword like today), and "define som

Re: Newbie namespace question

2004-12-23 Thread Nick Coghlan
Brandon wrote: I did the constructor thing and just didn't like it, it didn't feel clean (I know, I know and monkeying with __builtin__ is?) As for global, that will just make it modlue-level global (I think?) and I have this reference in multiple modules. I think I tried it already, but I can't r

Re: Python for Series 60 update

2004-12-23 Thread Jukka Laurila
On Thu, 23 Dec 2004 06:52:28 +0800, Tim Hoffman <[EMAIL PROTECTED]> wrote: > I did find a problem with it on my 7610. > It works, but I had to hard code my bluetooth mac address (I assume > thats what it is called in bluetooth). The bt_discover() call > didn't seem to find my host. How did it f

Re: Lambda going out of fashion

2004-12-23 Thread Craig Ringer
Fredrik Lundh wrote: Craig Ringer wrote: It's hard to consistently support Unicode in extension modules without doing a lot of jumping through hoops. Unicode in docstrings is particularly painful. This may not be a big deal for normal extension modules, but when embedding Python it's a source of

Re: Lambda going out of fashion

2004-12-23 Thread Robin Becker
Alex Martelli wrote: . By the way, if that's very important to you, you might enjoy Mozart (http://www.mozart-oz.org/) -- I'm looking at it and it does appear to go even further in this specific regard (rich support for multi - paradigm programming). It's also blessed with a great book,

Re: Lambda going out of fashion

2004-12-23 Thread Nick Coghlan
Alex Martelli wrote: Nick Coghlan <[EMAIL PROTECTED]> wrote: ... Perhaps something like: accepts_func( (def (a, b, c) to f(a) + o(b) - o(c)) ) Nice, except I think 'as' would be better than 'to'. 'as' should be a full keyword in 3.0 anyway (rather than a surprisingly-NOT-keyword like today), a

Re: Lambda going out of fashion

2004-12-23 Thread Nick Coghlan
Nick Coghlan wrote: Indeed, lambda as it currently stands will disappear for the Python 2.x series. Will NOT disappear. I repeat, will NOT disappear. Cheers, Nick. Damn those missing negators. . . -- Nick Coghlan | [EMAIL PROTECTED] | Brisbane, Australia ---

Re: Lambda going out of fashion

2004-12-23 Thread Stephen Thorne
On Thu, 23 Dec 2004 13:47:49 +0100, Alex Martelli <[EMAIL PROTECTED]> wrote: > Nick Coghlan <[EMAIL PROTECTED]> wrote: >... > > Perhaps something like: > > > > accepts_func( (def (a, b, c) to f(a) + o(b) - o(c)) ) > > Nice, except I think 'as' would be better than 'to'. 'as' should be a > ful

Re: Lambda going out of fashion

2004-12-23 Thread rzed
Stephen Thorne <[EMAIL PROTECTED]> wrote in news:[EMAIL PROTECTED]: > Hi guys, > > I'm a little worried about the expected disappearance of lambda > in python3000. I've had my brain badly broken by functional > programming in the past, and I would hate to see things suddenly > become harder than

test

2004-12-23 Thread Per Erik Stendahl
sdfdsafasd -- http://mail.python.org/mailman/listinfo/python-list

odbc for solid

2004-12-23 Thread flupke
Hi, at work we use a solid database and i need to develop an application that accesses it. Problem is the drivers: i only have some dll's lying around and jar. On winsdows i could get by by using ODBC and the dll's to access the solid database but i want to eventually run it on a linux server. S

subclassing list

2004-12-23 Thread Uwe Mayer
Hi, I want to subclass "list". The documentation states to prefer subclassing list instead of UserList. How to you clear the contents of a list subclass without creating a new object? Thanks in advance Uwe -- http://mail.python.org/mailman/listinfo/python-list

urllib and sites that require passwds

2004-12-23 Thread [EMAIL PROTECTED]
Hello, I'm doing a small website survey as a consultant for a company that has a large private lan. Basically, I'm trying to determine how many web sites there are on their network and what content the sites contain (scary how they don't know this, but I suspect many companies are this way). Ever

list Integer indexing dies??

2004-12-23 Thread Ishwor
Hi all. Look at this snippet of code. >>> l = ['a','b','c','d'] >>> l ['a', 'b', 'c', 'd'] >>> l[0][0][0] 'a' It prints the value 'a'. Fine so far :-) l[0] ---> 'a' . l[0][0]---> 'a'[0] --> 'a'. l[0][0][0] ---> 'a'[0][0] --> 'a'[0] --> 'a' Now why doesnt this list which holds integer seem to wor

RE: list Integer indexing dies??

2004-12-23 Thread Batista, Facundo
Title: RE: list Integer indexing dies?? [Ishwor] #- Now why doesnt this list which holds integer seem to work?? #- #- >>> l = [1,2,3] #- >>> l[0] #- 1 #- >>> l[0][0] #- #- Traceback (most recent call last): #-   File "", line 1, in -toplevel- #- l[0][0] #- TypeError: unsubscriptable o

RE: Python Users Nederland - python-nl mailing list

2004-12-23 Thread Klaus Muller
Ik zal aan deze bijeenkomst deelnemen. Ik ben de developer van SimPy (Simulation in Python). Als er belangstelling bestaat, kan ik op een van de toekomstige meetings een presentatie over SimPy geven. Klaus Müller simpy.sourceforge.net > -Original Message- > From: Johannes Gijsbers [mailt

Re: list Integer indexing dies??

2004-12-23 Thread Antoon Pardon
Op 2004-12-23, Ishwor schreef <[EMAIL PROTECTED]>: > Hi all. Look at this snippet of code. > l = ['a','b','c','d'] l > ['a', 'b', 'c', 'd'] l[0][0][0] > 'a' > It prints the value 'a'. Fine so far :-) > l[0] ---> 'a' . > l[0][0]---> 'a'[0] --> 'a'. > l[0][0][0] ---> 'a'[0][0] --> 'a'

Re: list Integer indexing dies??

2004-12-23 Thread Ishwor
On Thu, 23 Dec 2004 11:17:57 -0300, Batista, Facundo <[EMAIL PROTECTED]> wrote: > [snip] > #- >>> 1[0] > #- > #- Traceback (most recent call last): > #- File "", line 1, in -toplevel- > #- 1[0] > #- TypeError: unsubscriptable object > #- >>> > > Well, because the integer is not a su

Re: Lambda going out of fashion

2004-12-23 Thread Jp Calderone
On Thu, 23 Dec 2004 13:36:08 GMT, rzed <[EMAIL PROTECTED]> wrote: >Stephen Thorne <[EMAIL PROTECTED]> wrote in > news:[EMAIL PROTECTED]: > > [snip] > > > > { > > 'one': lambda x:x.blat(), > > 'two': lambda x:x.blah(), > > }.get(someValue, lambda x:0)(someOtherValue) > > > > The alternatives to

Re: urllib and sites that require passwds

2004-12-23 Thread Fuzzyman
USe urllib2 which will fail with an exception. You can trap this exception and using the code attribute of the exception object, determine why it failed. The error code for 'authentication required' is 401. Off the top of my head : import urllib2 req = urllib2.Request(theurl) try: handle = urllib

RE: list Integer indexing dies??

2004-12-23 Thread Batista, Facundo
Title: RE: list Integer indexing dies?? [Ishwor] #- >>> 'invalid'[0] #- 'i' #- >>> 123232[-1] #- # Python should automagically infer here that user #- # means indexing and *not* the number per se. #- # (i mean list in context of the line :-) ) Python never should automagically infer noth

Re: subclassing list

2004-12-23 Thread Fuzzyman
class newList(list): def clear(self): self[:] = [] is one way. HTH Regards, Fuzzy http://www.voidspace.org.uk/python/index.shtml -- http://mail.python.org/mailman/listinfo/python-list

(no subject)

2004-12-23 Thread Ran Libeskind-Hadas
From: Ran Libeskind-Hadas (via the vacation program) Subject: Your e-mail This message was generated automatically in response to your e-mail. I will be traveling and away from my e-mail until Tuesday, December 28. I will respond to your e-mail when I return. Thank you, Ran -- http://mail.pytho

Re: list Integer indexing dies??

2004-12-23 Thread Ishwor
On 23 Dec 2004 14:28:37 GMT, Antoon Pardon <[EMAIL PROTECTED]> wrote: > Op 2004-12-23, Ishwor schreef <[EMAIL PROTECTED]>: > > Hi all. Look at this snippet of code. > > > l = ['a','b','c','d'] > l > > ['a', 'b', 'c', 'd'] > l[0][0][0] > > 'a' > > It prints the value 'a'. Fine so far

Re: subclassing list

2004-12-23 Thread Richie Hindle
[Uwe] > How [do] you clear the contents of a list subclass > without creating a new object? Use the paranoia emoticon: "del x[:]". For example: >>> class L(list): ... pass ... >>> x = L() >>> x.append("Spam") >>> del x[:] >>> x [] >>> type(x) >>> with-thanks-to-Gordon-McMillan-ly y'rs, --

Re: urllib and sites that require passwds

2004-12-23 Thread Fuzzyman
damn... I'm losing my leading spaces indentation should be obvious anyway... (everything below except is indented at least one step). Fuzzy -- http://mail.python.org/mailman/listinfo/python-list

Re: list Integer indexing dies??

2004-12-23 Thread Ishwor
On Thu, 23 Dec 2004 11:40:12 -0300, Batista, Facundo <[EMAIL PROTECTED]> wrote: > > > [Ishwor] > > #- >>> 'invalid'[0] > #- 'i' > #- >>> 123232[-1] > #- # Python should automagically infer here that user > #- # means indexing and *not* the number per se. > #- # (i mean list in context of t

Re: Best GUI for small-scale accounting app?

2004-12-23 Thread Steve Holden
huy wrote: Dave Cook wrote: On 2004-12-20, Paul Rubin wrote: I think I can put together a useable (but not visually stunning) web interface faster than I can put together any pure client-side interface. Web browser "widgets" seem pretty limited to me, though. You don't even have something as

soappy bug with dictionary?!?

2004-12-23 Thread elsarfhem
I have a problem with soappy when i try to send a python dictionary... i send something like this {'1':2,'3':4} and it returns something like this {'1':[2,4], '3':4} function on the server is simply an echo: def echo(arg): return arg i post the soap message, it may be useful... *** Incoming HT

Re: extract news article from web

2004-12-23 Thread Steve Holden
Zhang Le wrote: Thanks for the hint. The xml-rpc service is great, but I want some general techniques to parse news information in the usual html pages. Currently I'm looking at a script-based approach found at: http://www.namo.com/products/handstory/manual/hsceditor/ User can write some simple tem

Re: Killing a python thread with a signal

2004-12-23 Thread Philippe C. Martin
On Thu, 2004-12-23 at 04:51, James Lamanna wrote: > So I've created a thread with the threading.Thread class, but I want to > be able to kill this thread because it does a select() with a timeout of > None. I do not know what type of information your thread reads from the sockets, but I added a

Re: urllib and sites that require passwds

2004-12-23 Thread Ishwor
On 23 Dec 2004 06:46:50 -0800, Fuzzyman <[EMAIL PROTECTED]> wrote: > damn... I'm losing my leading spaces indentation should be obvious We'll forgive you for that. It was from "top-of-your-head" ~;-) > anyway... (everything below except is indented at least one step). > Fuzzy Its nice that url

Re: list IndexError

2004-12-23 Thread Mike C. Fletcher
Fredrik Lundh wrote: Mike C. Fletcher wrote: yeah actually i saw what Fedrik had to say above. I created a sliced copy of the l & did my homework within the for loop You might want to check it again before you hand it in ;) ... ... that's not the code he quoted in the mail you replie

Switch statement (was: Lambda going out of fashion)

2004-12-23 Thread Skip Montanaro
Stephen> { Stephen> 'one': lambda x:x.blat(), Stephen> 'two': lambda x:x.blah(), Stephen> }.get(someValue, lambda x:0)(someOtherValue) One thing to remember is that function calls in Python are pretty damn expensive. If x.blat() or x.blah() are themselves only one or two lines

Improving Python (was: Lambda going out of fashion)

2004-12-23 Thread Skip Montanaro
Keith> My personal gripe is this. I think the core language, as of 2.3 Keith> or 2.4 is very good, has more features than most people will ever Keith> use, and they (Guido, et al.) can stop tinkering with it now and Keith> concentrate more on the standard libraries. What keeps you

Re: list Integer indexing dies??

2004-12-23 Thread Antoon Pardon
Op 2004-12-23, Ishwor schreef <[EMAIL PROTECTED]>: > On 23 Dec 2004 14:28:37 GMT, Antoon Pardon <[EMAIL PROTECTED]> wrote: >> Op 2004-12-23, Ishwor schreef <[EMAIL PROTECTED]>: >> > Hi all. Look at this snippet of code. >> > >> l = ['a','b','c','d'] >> l >> > ['a', 'b', 'c', 'd'] >>

Re: Python, unix and mssql

2004-12-23 Thread Steve Holden
francisl wrote: We have to build some script were I work to make a dynamic server inventory. But, the project team, a windows crew, start it all in vbscript and on mssql. Note, due to political reason, we can not use mysql or anyother one that are not *authorize*, it's oracle or mssql. Now we h

Re: Keyword arguments - strange behaviour?

2004-12-23 Thread Steven Bethard
Fuzzyman wrote: Steven Bethard wrote: [EMAIL PROTECTED] wrote: However, is there a good reason why default parameters aren't evaluated as the function is called? (apart from efficiency and backwards compatibility)? So, one of my really common use cases that takes advantage of the fact that default

Re: Python for Series 60 update

2004-12-23 Thread Tim Hoffman
HI Jukka Laurila wrote: On Thu, 23 Dec 2004 06:52:28 +0800, Tim Hoffman <[EMAIL PROTECTED]> wrote: I did find a problem with it on my 7610. It works, but I had to hard code my bluetooth mac address (I assume thats what it is called in bluetooth). The bt_discover() call didn't seem to find my hos

Re: mathmatical expressions evaluation

2004-12-23 Thread Tonino
yes - this is what I have been doing - created a set of functions to handle the formula and they all calculate a section of the formula. Thanks for all the help ;) Tonino -- http://mail.python.org/mailman/listinfo/python-list

Re: odbc for solid

2004-12-23 Thread Steve Holden
flupke wrote: Hi, at work we use a solid database and i need to develop an application that accesses it. Problem is the drivers: i only have some dll's lying around and jar. On winsdows i could get by by using ODBC and the dll's to access the solid database but i want to eventually run it on a l

Re: extract news article from web

2004-12-23 Thread Fuzzyman
If you have a reliably structured page, then you can write a custom parser. As Steve points out - BeautifulSOup would be a very good place to start. This is the problem that RSS was designed to solve. Many newssites will supply exactly the information you want as an RSS feed. You should then use U

Re: Why are tuples immutable?

2004-12-23 Thread Antoon Pardon
Op 2004-12-23, Scott David Daniels schreef <[EMAIL PROTECTED]>: > Antoon Pardon wrote: >> Op 2004-12-22, Jeff Shannon schreef <[EMAIL PROTECTED]>: >>>The problem is that once the object has mutated, you *don't know* what >>>bucket it used to sort into. There is no point at which a dictionary >>>

Re: Lambda going out of fashion

2004-12-23 Thread Skip Montanaro
Craig> IMO the reference behaviour of functions in the C API could be Craig> clearer. One often has to simply know, or refer to the docs, to Craig> tell whether a particular call steals a reference or is reference Craig> neutral. Take, for example, PyDict_SetItemString vs Crai

Re: list IndexError

2004-12-23 Thread Steven Bethard
Steven Bethard wrote: Ishwor wrote: i am trying to remove an item 'e' from the list l I thought it might be helpful to code some of the alternatives you've been given and look at the timings to put things into perspective. Corrected timings[1] using: $ python -m timeit -s "import remove" "remove.

Re: Keyword arguments - strange behaviour?

2004-12-23 Thread Fuzzyman
Steven Bethard wrote: > Fuzzyman wrote: > > Steven Bethard wrote: > > > >>[EMAIL PROTECTED] wrote: > >> > >>>However, is there a good reason why default parameters aren't > >>>evaluated as the function is called? (apart from efficiency > >>>and backwards compatibility)? > >> > >>So, one of my real

Re: odbc for solid

2004-12-23 Thread flupke
> Steve Holden wrote: This might be of interest (and also possibly of relevance to an earlier query about accessing MS SQL Server from Unix in the "Python, unix and mssql" thread): http://sourceforge.net/projects/pyodb """PyODB is an ODBC Python module to provide an quick an easy way to work

Re: Lambda going out of fashion

2004-12-23 Thread Skip Montanaro
>> readability. Pythonic lambdas are just syntactic sugar in practice, Paul> Actually it's the other way around: it's named functions that are Paul> the syntactic sugar. While I'm sure it can be done, I'd hate to see a non-trivial Python program written with lambda instead of def. (

Re: Python, unix and mssql

2004-12-23 Thread Scott David Daniels
francisl wrote: Can we, directly from unix select and insert data in a remote mssql database? In some sense you can. I used python and mxODBC to talk ODBC protocol to DB2 / MS SqlServer / Access. It was quite a while ago, and I may have had to use an odbc-on-linux piece I don't know about. But

Re: Newbie question - default values of a function

2004-12-23 Thread Steve Holden
Bulba! wrote: Thanks everyone (esp. Fredrik, http://www.effbot.org/zone/index.htm contains lotsa goodies by him I intend to study), I'm going offline to reboot my brain. ;-) Bulba, with reference to your "don't laugh" comment, I'd just like to say that for a newbie your questions do have a habi

Re: list IndexError

2004-12-23 Thread Steve Holden
M.E.Farmer wrote: Hello Ishwor , The simpliest way I can explain slicing is that the slices point to the spot *between* the items.. Take this list for example slicer = [0,1,2,3,4,5] slicer [1] 1 slicer [1:2] [1] slicer [:-1] [0,1,2,3,4] slicer[2,4] [2,3] You can also use a "stride" rather t

Unicode entries on sys.path

2004-12-23 Thread Thomas Heller
I was trying to track down a bug in py2exe where the executable did not work when it is in a directory containing japanese characters. Then, I discovered that part of the problem is in the zipimporter that py2exe uses, and finally I found that it didn't even work in Python itself. If the entry in

  1   2   3   >