Class: @property -> .__dict__

2011-12-16 Thread Ulrich
Good morning, I wonder if someone could please help me out with the @property function as illustrated in the following example. class te(): def __init__(self): self.a = 23 @property def b(self): return 2 * self.a t = te() In [4]: t.a Out[4]: 23 In [5]: t.b Out[5]: 4

Re: Class: @property -> .__dict__

2011-12-16 Thread Steven D'Aprano
On Fri, 16 Dec 2011 00:52:11 -0800, Ulrich wrote: > Good morning, > > I wonder if someone could please help me out with the @property function > as illustrated in the following example. > > class te(): > def __init__(self): > self.a = 23 > @property > def b(self): > r

Re: Class: @property -> .__dict__

2011-12-16 Thread Ulrich
On Dec 16, 10:03 am, Steven D'Aprano wrote: > On Fri, 16 Dec 2011 00:52:11 -0800, Ulrich wrote: > > Good morning, > > > I wonder if someone could please help me out with the @property function > > as illustrated in the following example. > > > class te(): > >     def __init__(self): > >         se

Re: Class: @property -> .__dict__

2011-12-16 Thread Ulrich
On Dec 16, 10:11 am, Ulrich wrote: > On Dec 16, 10:03 am, Steven D'Aprano > > > > > > > > > +comp.lang.pyt...@pearwood.info> wrote: > > On Fri, 16 Dec 2011 00:52:11 -0800, Ulrich wrote: > > > Good morning, > > > > I wonder if someone could please help me out with the @property function > > > as i

Re: AttributeError in "with" statement (3.2.2)

2011-12-16 Thread Steven D'Aprano
On Thu, 15 Dec 2011 19:39:17 -0500, Terry Reedy wrote: [...] After reading your post, I think I have worked out where our disagreement lines: you think that bound methods and instance methods are not the same thing, and that a function defined inside a class is different from a function outside

Re: Class: @property -> .__dict__

2011-12-16 Thread Peter Otten
Ulrich wrote: > if I replace it to > def attributelist(self): > # find all attributes to the class that are of type numpy > arrays: > return [attr for attr in dir(self) if > isinstance(getattr(self, attr), numpy.ndarray)] > > it crashes going into some kind of endless loop. > >

Re: Class: @property -> .__dict__

2011-12-16 Thread Thomas Rachel
Am 16.12.2011 09:52 schrieb Ulrich: Could anyone please explain me why this does not work / how to get b into .__dict__ / hint me to an explanation? b is not a data element of the particular instance, but it lives in the class. It is, roughly spoken, a "kind of method", just to be used witho

modifying a time.struct_time

2011-12-16 Thread Ulrich Eckhardt
Hi! I'm trying to create a struct_time that is e.g. one year ahead or a month back in order to test some parsing/formatting code with different dates. Now, the straightforward approach is t = time.localtime() t.tm_year += 1 This fails with "TypeError: readonly attribute". This kind-of m

Re: modifying a time.struct_time

2011-12-16 Thread Mazen Harake
Hi, Easiest way is to change the time to seconds, add as many seconds as a year/month/week/day/hour/minutes represent and then transform it back. E.g. >>> time.time() 1324031491.026137 >>> time.time() + 3600 # Add an hour 1324035105.082003 >>> time.gmtime(time.time() + 3600) time.struct_time(tm_

Re: % is not an operator [was Re: Verbose and flexible args and kwargs syntax]

2011-12-16 Thread Eelco
On Dec 16, 3:58 am, MRAB wrote: > On 16/12/2011 02:14, alex23 wrote: > > > Eelco  wrote: > >> To tie it back in with python language design; all the more reason > >> not to opt for pseudo-backwards compatibility. If python wants a > >> remainder function, call it 'remainder'. Not 'rem', not 'mod',

Re: % is not an operator [was Re: Verbose and flexible args and kwargs syntax]

2011-12-16 Thread Eelco
On Dec 16, 6:30 am, alex23 wrote: > On Dec 16, 3:01 pm, Chris Angelico wrote: > > > And I would be most sorry to see % renamed to mod in Python. > > > "Hello, %s! My favourite number is %d." mod ("Fred",42)   # This just > > looks wrong. > > Finally we can give this operator a more fitting name -

Re: modifying a time.struct_time

2011-12-16 Thread Steven D'Aprano
On Fri, 16 Dec 2011 10:45:22 +0100, Ulrich Eckhardt wrote: > Hi! > > I'm trying to create a struct_time that is e.g. one year ahead or a > month back in order to test some parsing/formatting code with different > dates. [...] > The second approach is this: > >l = list(t) # convert to a seque

Re: modifying a time.struct_time

2011-12-16 Thread Chris Angelico
On Fri, Dec 16, 2011 at 8:45 PM, Ulrich Eckhardt wrote: > I'm trying to create a struct_time that is e.g. one year ahead or a month > back in order to test some parsing/formatting code with different dates. Do you need it to be one exact calendar year, or would it make sense to add/subtract integ

Re: modifying a time.struct_time

2011-12-16 Thread Tim Golden
On 16/12/2011 10:44, Steven D'Aprano wrote: [ on time.struct_time ] Not a bug, but it does seem a very old and inelegant API more suited to hairy C programmers gathered around a smokey fire in a cave chewing on old dinosaur bones, and not worthy of space-age Python coders flying around on anti-g

GlobalLogic PYTHON/JAVA positions

2011-12-16 Thread Richa Sinha
Hi All , Trust you doing well.. GlobalLogic is looking for highly skilled *Python Developers/Sr.Developers* , *JAVA DEVELOPERS/Sr. Developers* for one of our strategic engagements with * GOOGLE. * Following are the details: > >> *Python Developer(s)/Sr. Developers* >> >> >> >> Experience: 1-5

ckjdlkfnl,ndf,nfd,fndfnkdnk mmdlssdlndnll; k; as; lkds sjdsljdlskjdsl; kdslksdl; ddlk

2011-12-16 Thread D. Mohan M. Dayalan
http;//123maza.com/48/moon670/ -- http://mail.python.org/mailman/listinfo/python-list

merging argparse parsers

2011-12-16 Thread Andrea Crotti
I would like to have something like merged_parser = LoggingParser() + OtherParser() Which should create an argument parser with all the options composed. Now for that I think I would need to subclass the argument, and something fancy with the overloading. The problem is that apparently there is

RE: Localhost client-server simple ssl socket test program problems

2011-12-16 Thread Yang Chun-Kai
> To: python-list@python.org > From: li...@cheimes.de > Subject: Re: Localhost client-server simple ssl socket test program problems > Date: Thu, 15 Dec 2011 20:45:43 +0100 > > Am 15.12.2011 20:09, schrieb Yang Chun-Kai: > > Server side error: > > > > File "views.py", line 17, in > > connstre

Make a small function thread safe

2011-12-16 Thread Brad Tilley
Hey guys, I have a C++ function that I'd like to replicate (as closely as possible) in Python. Here's an example: 107 void increment_counter( unsigned int& counter ) 108 { 109 boost::mutex::scoped_lock lock( counter_lock ); 110 ++counter; 111

Re: Make a small function thread safe

2011-12-16 Thread Tim Wintle
On Fri, 2011-12-16 at 05:21 -0800, Brad Tilley wrote: > 107 void increment_counter( unsigned int& counter ) > 108 { > 109 boost::mutex::scoped_lock lock( counter_lock ); > 110 ++counter; > 111 } with counter_lock: counter += 1 ... wher

Re: modifying a time.struct_time

2011-12-16 Thread Ulrich Eckhardt
Am 16.12.2011 10:45, schrieb Ulrich Eckhardt: I'm trying to create a struct_time that is e.g. one year ahead or a month back in order to test some parsing/formatting code with different dates. There is something I stumbled across that helps and that is the datetime module, which seems more rea

Re: Make a small function thread safe

2011-12-16 Thread Brad Tilley
On Fri, Dec 16, 2011 at 8:33 AM, Tim Wintle wrote: > On Fri, 2011-12-16 at 05:21 -0800, Brad Tilley wrote: > > 107 void increment_counter( unsigned int& counter ) > > 108 { > > 109 boost::mutex::scoped_lock lock( counter_lock ); > > 110 ++counter; >

Re: modifying a time.struct_time

2011-12-16 Thread Chris Angelico
On Sat, Dec 17, 2011 at 12:32 AM, Ulrich Eckhardt wrote: > Concerning the idea to use seconds, I'd rather not, because already the > number of seconds per minute ranges from 60 to 62, and it doesn't get better > with things like months (28...31 days), years (365...366 days) and all other > types b

Re: Make a small function thread safe

2011-12-16 Thread Brad Tilley
On Fri, Dec 16, 2011 at 9:24 AM, Brad Tilley wrote: > > > On Fri, Dec 16, 2011 at 8:33 AM, Tim Wintle wrote: > >> On Fri, 2011-12-16 at 05:21 -0800, Brad Tilley wrote: >> > 107 void increment_counter( unsigned int& counter ) >> > 108 { >> > 109 boost::mutex::scoped

Re: Make a small function thread safe

2011-12-16 Thread Tim Wintle
On Fri, 2011-12-16 at 09:24 -0500, Brad Tilley wrote: > So something like this then: > > import threading > > shared_container = [] > lock = threading.Lock() > > class thread_example( threading.Thread ): > > def __init__( self ): > threading.Thread.__init__ (self) > > def run(t

Re: ERP with Supply chain management (incl. POS) and Customer relationship management ??? What's available?

2011-12-16 Thread Grant Edwards
On 2011-12-16, Gregory Ewing wrote: >> On Thu, Dec 15, 2011 at 5:54 AM, Anurag Chourasia >> wrote: >> >>>I am building a POS/CRM (Loyalty Management) system as well. > > Is it just me, or does the phrase "Loyalty Management" have > a faintly ominous ring to it? Yea, sounds a bit like Newspeak -

Re: Make a small function thread safe

2011-12-16 Thread Brad Tilley
On Dec 16, 9:36 am, Tim Wintle wrote: > should be: >       def run(t): >           with lock: >               shared_container.append(t.name) > > (or lock.acquire() and lock.release() as you mentioned) Thanks Tim. The with statement is closer to the C++ code (IMO) more so than the explicit acqu

Re: ERP with Supply chain management (incl. POS) and Customer relationship management — What's available?

2011-12-16 Thread Emile van Sebille
On 12/15/2011 6:43 AM Alec Taylor said... On Thu, Dec 15, 2011 at 5:54 AM, Anurag Chourasia wrote: Hi Alec, I am building a POS/CRM (Loyalty Management) system as well. So far, the best I could find to use as a base OpenERP? Emile -- http://mail.python.org/mailman/listinfo/python-list

Re: Class: @property -> .__dict__

2011-12-16 Thread Ian Kelly
On Fri, Dec 16, 2011 at 2:32 AM, Peter Otten <__pete...@web.de> wrote: > Ulrich wrote: > >> if I replace it to >> def attributelist(self): >>          # find all attributes to the class that are of type numpy >> arrays: >>          return [attr for attr in dir(self) if >> isinstance(getattr(self, a

re.sub(): replace longest match instead of leftmost match?

2011-12-16 Thread John Gordon
According to the documentation on re.sub(), it replaces the leftmost matching pattern. However, I want to replace the *longest* matching pattern, which is not necessarily the leftmost match. Any suggestions? I'm working with IPv6 CIDR strings, and I want to replace the longest match of "(:|0

Re: re.sub(): replace longest match instead of leftmost match?

2011-12-16 Thread Devin Jeanpierre
You could use re.finditer to find the longest match, and then replace it manually by hand (via string slicing). (a match is the longest if (m.end() - m.start()) is the largest -- so, max(re.finditer(...), key=lambda m: (m.end() = m.start())) -- Devin P.S. does anyone else get bothered by how it'

Re: re.sub(): replace longest match instead of leftmost match?

2011-12-16 Thread MRAB
On 16/12/2011 16:49, John Gordon wrote: According to the documentation on re.sub(), it replaces the leftmost matching pattern. However, I want to replace the *longest* matching pattern, which is not necessarily the leftmost match. Any suggestions? I'm working with IPv6 CIDR strings, and I want

Re: % is not an operator [was Re: Verbose and flexible args and kwargs syntax]

2011-12-16 Thread rusi
On Dec 16, 3:25 pm, Eelco wrote: > Pseudo-backwards compatibility with other > languages, I couldnt not care less for. Double negations n Goedelian situations have interesting implications (tho here its triple) -- http://mail.python.org/mailman/listinfo/python-list

Making the case for "typed" lists/iterators in python

2011-12-16 Thread Nathan Rice
I realize this has been discussed in the past, I hope that I am presenting a slightly different take on the subject that will prove interesting. This is primarily motivated by my annoyance with using comprehensions in certain circumstances. Currently, if you want to perform successive transformat

Re: re.sub(): replace longest match instead of leftmost match?

2011-12-16 Thread Ian Kelly
On Fri, Dec 16, 2011 at 10:36 AM, MRAB wrote: > On 16/12/2011 16:49, John Gordon wrote: >> >> According to the documentation on re.sub(), it replaces the leftmost >> matching pattern. >> >> However, I want to replace the *longest* matching pattern, which is >> not necessarily the leftmost match.  

Re: Python Interpreter Error with PyDev (Eclipse IDE)

2011-12-16 Thread Fabio Zadrozny
It seems you have a version of Python 2.5 in your system and when starting up Python 3.2.2 it's getting things from 2.5 (this would probably also happen on the command line). The usual suspect is that you defined a PYTHONROOT variable which is pointing to Python 2.5 and not to the python you're us

Re: re.sub(): replace longest match instead of leftmost match?

2011-12-16 Thread Ian Kelly
On Fri, Dec 16, 2011 at 10:57 AM, Ian Kelly wrote: > On Fri, Dec 16, 2011 at 10:36 AM, MRAB wrote: >> On 16/12/2011 16:49, John Gordon wrote: >>> >>> According to the documentation on re.sub(), it replaces the leftmost >>> matching pattern. >>> >>> However, I want to replace the *longest* matchin

Re: Making the case for "typed" lists/iterators in python

2011-12-16 Thread Roy Smith
In article , Nathan Rice wrote: > I'd like to hear people's thoughts on the subject. Currently we are > throwing away useful information in many cases that could be used for > code analysis, optimization and simpler interfaces. Most of this was TL:DNR, but I will admit I often wish for a bett

Re: re.sub(): replace longest match instead of leftmost match?

2011-12-16 Thread MRAB
On 16/12/2011 17:57, Ian Kelly wrote: On Fri, Dec 16, 2011 at 10:36 AM, MRAB wrote: On 16/12/2011 16:49, John Gordon wrote: According to the documentation on re.sub(), it replaces the leftmost matching pattern. However, I want to replace the *longest* matching pattern, which is not nece

Re: Making the case for "typed" lists/iterators in python

2011-12-16 Thread Stefan Behnel
Nathan Rice, 16.12.2011 18:48: I realize this has been discussed in the past, I hope that I am presenting a slightly different take on the subject that will prove interesting. This is primarily motivated by my annoyance with using comprehensions in certain circumstances. Currently, if you want

Re: Making the case for "typed" lists/iterators in python

2011-12-16 Thread Chris Angelico
On Sat, Dec 17, 2011 at 5:05 AM, Roy Smith wrote: > Most of this was TL:DNR, but I will admit I often wish for a better way > to log intermediate values.  For example, a common pattern in the code > I'm working with now is functions that end in: > >   return [Foo(x) for x in bunch_of_x_thingies] >

Re: Making the case for "typed" lists/iterators in python

2011-12-16 Thread Arnaud Delobelle
On 16 December 2011 18:25, Chris Angelico wrote: > tee = lambda func,arg: (func(arg),arg)[1] What a strange way to spell it! def tee(func, arg): func(arg) return arg -- Arnaud -- http://mail.python.org/mailman/listinfo/python-list

Re: re.sub(): replace longest match instead of leftmost match?

2011-12-16 Thread Roy Smith
In article , John Gordon wrote: > I'm working with IPv6 CIDR strings, and I want to replace the longest > match of "(:|$)+" with ":". But when I use re.sub() it replaces > the leftmost match, even if there is a longer match later in the string. > > I'm also looking for a regexp that wi

Re: Making the case for "typed" lists/iterators in python

2011-12-16 Thread Chris Angelico
On Sat, Dec 17, 2011 at 5:38 AM, Arnaud Delobelle wrote: > On 16 December 2011 18:25, Chris Angelico wrote: > >> tee = lambda func,arg: (func(arg),arg)[1] > > What a strange way to spell it! > > def tee(func, arg): >    func(arg) >    return arg I started with that version and moved to the lambd

Re: Making the case for "typed" lists/iterators in python

2011-12-16 Thread Nathan Rice
Nothing stops me from implementing it, in fact it is VERY trivial to wrap member class methods onto a list subclass, and wrap functions to support vectorized behavior. The problem is that as soon as you hit anything outside your code that returns a list or iterator, everything gets blown away unle

Re: Making the case for "typed" lists/iterators in python

2011-12-16 Thread Devin Jeanpierre
> 2. One comprehension: > > L2 = [Z(X(Y(e))) for e in L1] > or > L2 = [e.X().Y().Z() for e in L1] I want to say that maybe this is better done by functions like map() (although, Python is missing a composition operator which might be handy, and mapping method calls isn't pretty). I don't know tha

Re: % is not an operator [was Re: Verbose and flexible args and kwargs syntax]

2011-12-16 Thread Eelco
On 16 dec, 18:38, rusi wrote: > On Dec 16, 3:25 pm, Eelco wrote: > > > Pseudo-backwards compatibility with other > > languages, I couldnt not care less for. > > Double negations n Goedelian situations have interesting implications > (tho here its triple) Heh. Well at least my extra (unintended)

Re: Making the case for "typed" lists/iterators in python

2011-12-16 Thread Mel Wilson
Chris Angelico wrote: > It's no more strange than the way some people omit the u from colour. :) Bonum Petronio Arbiteri, bonum mihi. Mel. -- http://mail.python.org/mailman/listinfo/python-list

Re: Making the case for "typed" lists/iterators in python

2011-12-16 Thread Stefan Behnel
Nathan Rice, 16.12.2011 19:51: Nothing stops me from implementing it, in fact it is VERY trivial to wrap member class methods onto a list subclass, and wrap functions to support vectorized behavior. The problem is that as soon as you hit anything outside your code that returns a list or iterator

Re: Making the case for "typed" lists/iterators in python

2011-12-16 Thread Ben Finney
Roy Smith writes: > When something goes amiss and I want to debug the problem, I often > transform that into: > > temp = [Foo(x) for x in bunch_of_x_thingies] > logger.debug(temp) > return temp > > It would be convenient to be able to get at and log the intermediate > value without

Re: Make a small function thread safe

2011-12-16 Thread Tim Delaney
On 17 December 2011 02:05, Brad Tilley wrote: > On Dec 16, 9:36 am, Tim Wintle wrote: > > > should be: > > def run(t): > > with lock: > > shared_container.append(t.name) > > > > (or lock.acquire() and lock.release() as you mentioned) > > > Thanks Tim. The with state

Re: re.sub(): replace longest match instead of leftmost match?

2011-12-16 Thread John Gordon
In Devin Jeanpierre writes: > You could use re.finditer to find the longest match, and then replace > it manually by hand (via string slicing). > (a match is the longest if (m.end() - m.start()) is the largest -- > so, max(re.finditer(...), key=3Dlambda m: (m.end() =3D m.start())) I ended up

Re: re.sub(): replace longest match instead of leftmost match?

2011-12-16 Thread John Gordon
In Ian Kelly writes: > >>> I'm also looking for a regexp that will remove leading zeroes in each > >>> four-digit group, but will leave a single zero if the group was all > >>> zeroes. > pattern = r'\b0{1,3}([1-9a-f][0-9a-f]*|0)\b' > re.sub(pattern, r'\1', string, flags=re.IGNORECASE) Perfect

Re: re.sub(): replace longest match instead of leftmost match?

2011-12-16 Thread John Gordon
In Roy Smith writes: > Having done quite a bit of IPv6 work, my opinion here is that you're > trying to do The Wrong Thing. > What you want is an IPv6 class which represents an address in some > canonical form. It would have constructors which accept any of the > RFC-2373 defined formats.

Re: re.sub(): replace longest match instead of leftmost match?

2011-12-16 Thread MRAB
On 16/12/2011 21:04, John Gordon wrote: In Devin Jeanpierre writes: You could use re.finditer to find the longest match, and then replace it manually by hand (via string slicing). (a match is the longest if (m.end() - m.start()) is the largest -- so, max(re.finditer(...), key=3Dlambda

Re: AttributeError in "with" statement (3.2.2)

2011-12-16 Thread Terry Reedy
On 12/16/2011 4:22 AM, Steven D'Aprano wrote: On Thu, 15 Dec 2011 19:39:17 -0500, Terry Reedy wrote: [...] After reading your post, I think I have worked out where our disagreement lines: you think that bound methods and instance methods are not the same thing, Do you agree that an unbound met

Re: Make a small function thread safe

2011-12-16 Thread Lie Ryan
On 12/17/2011 01:30 AM, Brad Tilley wrote: Or perhaps run should look like this instead: def run(t): lock.acquire() shared_container.append(t.name ) lock.release() That seems a bit barbaric to me, not sure. change that to: def run(t): with l

Re: Making the case for "typed" lists/iterators in python

2011-12-16 Thread Terry Reedy
On 12/16/2011 1:05 PM, Roy Smith wrote: I'm working with now is functions that end in: return [Foo(x) for x in bunch_of_x_thingies] When something goes amiss and I want to debug the problem, I often transform that into: temp = [Foo(x) for x in bunch_of_x_thingies] logger.debug(t

Re: re.sub(): replace longest match instead of leftmost match?

2011-12-16 Thread Terry Reedy
On 12/16/2011 1:36 PM, Roy Smith wrote: What you want is an IPv6 class which represents an address in some canonical form. It would have constructors which accept any of the RFC-2373 defined formats. It would also have string formatting methods to convert the internal form into any of these fo

Re: Python Interpreter Error with PyDev (Eclipse IDE)

2011-12-16 Thread Joshua Jodrey
Thanks Fabio! I looked at my environment variables, and the only one python related was PYTHONHOME, and that was set to C:\csvn\Python25.  So I changed that to C:\Python32\ and I added an environment variable for PYTHONROOT and set that to the same value.  It now seems to work! I must have had

Re: % is not an operator [was Re: Verbose and flexible args and kwargs syntax]

2011-12-16 Thread Gregory Ewing
Eelco wrote: the actual english usage of the phrase, which omits the negation completely :). (I could care less) No, that's the American usage. The English usage is "I couldn't care less", which has the advantage of actually making sense. -- Greg -- http://mail.python.org/mailman/listinfo/pyth

Re: AttributeError in "with" statement (3.2.2)

2011-12-16 Thread Ethan Furman
Terry Reedy wrote: On 12/16/2011 4:22 AM, Steven D'Aprano wrote: On Thu, 15 Dec 2011 19:39:17 -0500, Terry Reedy wrote: [...] After reading your post, I think I have worked out where our disagreement lies: you think that bound methods and instance methods are not the same thing, Do you agree

Re: % is not an operator [was Re: Verbose and flexible args and kwargs syntax]

2011-12-16 Thread Eelco
On Dec 17, 12:49 am, Gregory Ewing wrote: > Eelco wrote: > > the actual english usage of the phrase, which omits > > the negation completely :). (I could care less) > > No, that's the American usage. The English usage is > "I couldn't care less", which has the advantage of > actually making sense.

Re: % is not an operator [was Re: Verbose and flexible args and kwargs syntax]

2011-12-16 Thread Roy Smith
In article <2420abd7-7d91-4bc9-bb3b-d8ec1680e...@u32g2000yqe.googlegroups.com>, Eelco wrote: > And yes, I agree; 'I couldnt care less' makes much more sense. 'I > could care less' can only make sense if you interpret it > sarcastically, as if omitting an 'oh wait, I cant', but that does not > s

Re: AttributeError in "with" statement (3.2.2)

2011-12-16 Thread Ethan Furman
Ethan Furman wrote: Terry Reedy wrote: On 12/16/2011 4:22 AM, Steven D'Aprano wrote: On Thu, 15 Dec 2011 19:39:17 -0500, Terry Reedy wrote: [...] After reading your post, I think I have worked out where our disagreement lies: you think that bound methods and instance methods are not the same

Re: % is not an operator [was Re: Verbose and flexible args and kwargs syntax]

2011-12-16 Thread Steven D'Aprano
On Fri, 16 Dec 2011 11:40:11 -0800, Eelco wrote: > On 16 dec, 18:38, rusi wrote: >> On Dec 16, 3:25 pm, Eelco wrote: >> >> > Pseudo-backwards compatibility with other languages, I couldnt not >> > care less for. >> >> Double negations n Goedelian situations have interesting implications >> (tho

Re: AttributeError in "with" statement (3.2.2)

2011-12-16 Thread Steven D'Aprano
On Fri, 16 Dec 2011 17:05:57 -0500, Terry Reedy wrote: > On 12/16/2011 4:22 AM, Steven D'Aprano wrote: >> On Thu, 15 Dec 2011 19:39:17 -0500, Terry Reedy wrote: [...] >> >> After reading your post, I think I have worked out where our >> disagreement lines: you think that bound methods and instance

Re: % is not an operator [was Re: Verbose and flexible args and kwargs syntax]

2011-12-16 Thread David Robinow
On Fri, Dec 16, 2011 at 7:54 PM, Steven D'Aprano wrote: > On Fri, 16 Dec 2011 11:40:11 -0800, Eelco wrote: > >> On 16 dec, 18:38, rusi wrote: >>> On Dec 16, 3:25 pm, Eelco wrote: >>> >>> > Pseudo-backwards compatibility with other languages, I couldnt not >>> > care less for. >>> >>> Double nega

Re: Make a small function thread safe

2011-12-16 Thread John Nagle
On 12/16/2011 2:08 PM, Lie Ryan wrote: On 12/17/2011 01:30 AM, Brad Tilley wrote: Or perhaps run should look like this instead: def run(t): lock.acquire() shared_container.append(t.name ) lock.release() That seems a bit barbaric to me, not sure. change that to: def run(t): wi

root[:]=[root,root]

2011-12-16 Thread YAN HUA
Hi,all. Could anybody tell how this code works? >>> root = [None, None] >>> root[:] = [root, root] >>> root [[...], [...]] >>> root[0] [[...], [...]] >>> root[0][0][1][1][0][0][0][1][1] [[...], [...]] >>> Thanks. -- http://mail.python.org/mailman/listinfo/python-list

Re: AttributeError in "with" statement (3.2.2)

2011-12-16 Thread Steven D'Aprano
On Fri, 16 Dec 2011 15:26:30 -0800, Ethan Furman wrote: > Terry Reedy wrote: >> On 12/16/2011 4:22 AM, Steven D'Aprano wrote: [...] > I think you two are in violent agreement as far as how Python is > functioning, and the conflict is in the names given to the various > pieces... I think a glossar

Re: root[:]=[root,root]

2011-12-16 Thread Lie Ryan
On 12/17/2011 01:40 PM, YAN HUA wrote: Hi,all. Could anybody tell how this code works? >>> root = [None, None] First, you're creating a list of two None, let's say it's list-1. Then you bind the name 'root' to list-1. >>> root[:] = [root, root] Next, you assign list-1's first member wit