On 07/26/11 12:00 AM, Archard Lias wrote:
Hi,
Still I dont get how I am supposed to understand the pipe and its task/
idea/influece on control flow, of:
return |
??
It's simply a bitwise OR.
--
Ian Collins
--
http://mail.python.org/mailman/listinfo/python-list
On Tue, Jul 26, 2011 at 4:16 PM, azrael wrote:
> Is there a support in the XRC for building advaced graphics widgets (AGW).
Yes, create an "unknown" control in the XRC and then use the
xrc.AttachUnknownControl method at runtime to swap in whatever widget
you want.
> also another thing. Is ther s
On Thu, Jul 28, 2011 at 9:39 AM, Ethan Furman wrote:
> Why is NoneType unable to produce a None instance? I realise that None is a
> singleton, but so are True and False, and bool is able to handle returning
> them:
The bool constructor works (actually just returns one of the existing
singletons
On Thu, Jul 28, 2011 at 7:22 AM, mark ferguson wrote:
> I've not really got the hang of decorators yet, so I was wondering why one
> might use your approach rather than just using Karim's original method?
The advantage of Thomas's decorator here is that it lets you place the
denotation of whether
On Thu, Jul 28, 2011 at 2:18 PM, gry wrote:
> [python 2.7] I have a (linux) pathname that I'd like to split
> completely into a list of components, e.g.:
> '/home/gyoung/hacks/pathhack/foo.py' --> ['home', 'gyoung',
> 'hacks', 'pathhack', 'foo.py']
>
> os.path.split gives me a tuple of dirname
On Thu, Jul 28, 2011 at 2:44 PM, Ian Kelly wrote:
> path = '/home/gyoung/hacks/pathhack/foo.py'
> parts = [part for path, part in iter(lambda: os.path.split(path), ('/', ''))]
> parts.reverse()
> print parts
>
> But that's horrendously
On Thu, Jul 28, 2011 at 2:47 PM, Ian Kelly wrote:
> On Thu, Jul 28, 2011 at 2:44 PM, Ian Kelly wrote:
>> path = '/home/gyoung/hacks/pathhack/foo.py'
>> parts = [part for path, part in iter(lambda: os.path.split(path), ('/', ''))]
>> parts.rev
On Thu, Jul 28, 2011 at 3:15 PM, Emile van Sebille wrote:
> On 7/28/2011 1:18 PM gry said...
>>
>> [python 2.7] I have a (linux) pathname that I'd like to split
>> completely into a list of components, e.g.:
>> '/home/gyoung/hacks/pathhack/foo.py' --> ['home', 'gyoung',
>> 'hacks', 'pathhack
On Mon, Jul 25, 2011 at 11:46 AM, Jack Bates wrote:
> How can you get a descriptor to return an identical value, each time
> it's called with the same "instance" - without leaking memory?
class MyDescriptor(object):
def __get__(self, instance, owner):
try:
return instance.
On Fri, Jul 29, 2011 at 5:01 PM, Ian Kelly wrote:
> On Mon, Jul 25, 2011 at 11:46 AM, Jack Bates wrote:
>> How can you get a descriptor to return an identical value, each time
>> it's called with the same "instance" - without leaking memory?
Oops, that should
> So far so good. The problem is that a CubeGrid instance is also a wx.Grid
instance. However, different naming conventions apply there. All method
names in wxPython are coming from C++. They use CamelCase method names.
There is a naming conflict. What should I do?
>
> Solution #1: Mix CamelCase an
http://mail.python.org/pipermail/python-list/2011-January/1264955.html
Cheers,
Ian
--
http://mail.python.org/mailman/listinfo/python-list
On Wed, Aug 10, 2011 at 8:37 AM, Steven D'Aprano
wrote:
>> Without the parentheses, this is legal but (probably) useless; it
>> applies the unary + operator to the return value of those functions.
>> Putting the + at the end of the previous line at least prevents that,
>> since most unary operator
On Wed, Aug 10, 2011 at 8:48 AM, Fuzzyman wrote:
> __name__ can be a descriptor, so you just need to write a descriptor
> that can be fetched from classes as well as instances.
>
> Here's an example with a property (instance only):
>
class Foo(object):
> ... @property
> ... def __name__(s
', 'b2']
>
> Is there a handy and efficient function to do this, especially when li1 and
> li2 are long lists.
> I found zip() but it only gives [('a', '1'), ('b', '2')], not exactly what I
> am looking for.
Use the "roundrobin" recipe from the itertools documentation.
Cheers,
Ian
--
http://mail.python.org/mailman/listinfo/python-list
How many of these codes do you need, and do they only need to be decrypted
at a central server? You might be able to just create random strings of
whatever form you want and associate them with the tokens in a database.
Then they will be completely opaque.
--
http://mail.python.org/mailman/listinf
On Aug 21, 2011 1:34 PM, "Max" wrote:
> > a[0:11][::-1]
> > # Instead of a[10:-1:-1], which looks like it should work, but doesn't.
>
> It works nicely, but it is 1.3 times slower in my code (I am surprised
> the interpreter doesn't optimize this).
Have you tried reverse()? I haven't timed it, bu
On Thu, Aug 25, 2011 at 3:29 AM, Thomas 'PointedEars' Lahn
wrote:
> Both variants work (even in Py3) if you only define
>
> class Data(object):
> def merge_with(self, bar, overwrite_duplicates):
> pass
>
> data1 = Data()
> data2 = Data()
>
> You have to define
>
> class Data(object):
> def me
ion here is to use virtualenv to set up your
development environment without having to modify the installed version
in the system site-packages at all.
HTH,
Ian
--
http://mail.python.org/mailman/listinfo/python-list
r unit testing of library modules, so
that the module can be tested just by running it.
# define library classes and functions here
if __name__ == '__main__':
# perform unit tests
Cheers,
Ian
--
http://mail.python.org/mailman/listinfo/python-list
On Sun, Aug 28, 2011 at 12:56 PM, woooee wrote:
> Two main routines, __main__ and main(), is not the usual or the common
> way to do it. It is confusing and anyone looking at the end of the
> program for statements executed when the program is called will find
> an isolated call to main(), and th
l still come from the "any" function and will look
basically the same as the stack traces you'll get from raising the
exceptions by hand.
HTH,
Ian
--
http://mail.python.org/mailman/listinfo/python-list
raise ValueError("iterable was empty")
squares = (x * x for x in range(0, 1000))
first(x for x in squares if x % 14 == 0)
It does a bit too much to comfortably be a one-liner no matter which
way you write it, so I split it into two.
Cheers,
Ian
--
http://mail.python.org/mailman/listinfo/python-list
tudied the docs but I'm certain that such an implementation
> would break a lot of code.
For example:
a = 42
exec "a += 1729"
print(a)
...since print would no longer be available in the global namespace.
Cheers,
Ian
--
http://mail.python.org/mailman/listinfo/python-list
return keyfunc(self) == keyfunc(other)
return Key
KeyTypeAlpha = Key(lambda x: x % 7)
items = set(KeyTypeAlpha(value) for value in sourceIterable)
Cheers,
Ian
--
http://mail.python.org/mailman/listinfo/python-list
string to operate on as an
argument. Subclassing built-in types tends to be tricky as you can
see, and this doesn't seem like a good reason to attempt it.
Cheers,
Ian
--
http://mail.python.org/mailman/listinfo/python-list
On Wed, Aug 31, 2011 at 12:02 PM, Travis Parks wrote:
> Am I doing something wrong, here? nonlocal isn't registering. Which
> version did this get incorporated?
3.0
--
http://mail.python.org/mailman/listinfo/python-list
it from being
wrapped into an ordinary method when it's accessed.
Cheers,
Ian
--
http://mail.python.org/mailman/listinfo/python-list
2011/8/31 Yaşar Arabacı :
> @Ian: Thanks for you comments. I indeed didn't need the _sozcuk attribute at
> all, so I deleted it. My class's addition and multiplication works without
> overwriting __add__ and __mul__ because, this class uses unicode's __add__
> and __mul_
On Thu, Sep 1, 2011 at 3:04 AM, Michiel Overtoom wrote:
>
> On Sep 1, 2011, at 10:24, Hegedüs Ervin wrote:
>
>> On Thu, Sep 01, 2011 at 10:00:27AM +0200, Michiel Overtoom wrote:
>>> Derive your class from object,
>>
>> why's that better than just create a simple class, without
>> derive?
>
> Among
h
instance is bound to the method being called?
Cheers,
Ian
--
http://mail.python.org/mailman/listinfo/python-list
On Thu, Sep 1, 2011 at 9:46 AM, mukesh tiwari
wrote:
> dbus.exceptions.DBusException:
> org.freedesktop.DBus.Error.ServiceUnknown: The name
> org.freedesktop.Hal was not provided by any .service files
>
> Kindly some one please tell me why i am getting this error .
> Thank you
It looks like you d
7;
>>>>
>
> Any futher item in the option won't make any better.
You're trying to call the method from the OptionParser class -- you
need to instantiate it first.
from optparse import OptionParser
parser = OptionParser()
parser.add_option('-n', '--new', dest='new')
...
Cheers,
Ian
--
http://mail.python.org/mailman/listinfo/python-list
second)
Lookup: is inconsistent. The overridden __iter__ method returns an
iterator over the values of the groups, but all the inherited methods
are going to iterate over the keys. Probably you want to pass
groups.values() to the superclass __init__ method.
Cheers,
Ian
--
http://mail.python.org/mailman/listinfo/python-list
s_flagged:
>> methods[obj.user_id] = obj.do_work
>> else:
>> methods[obj.user_id] = obj.do_other_work
>> # ...
>> methods[some_user_id]()
>>
>> Without method wrappers, how does the interpreter figure out which
>> instance is bound to the method
atabase, it "successfully" updates 0 rows. I would guess
that's what happened here. You should check cursor.rowcount after
running the update query to make sure it actually did something.
Cheers,
Ian
--
http://mail.python.org/mailman/listinfo/python-list
al OOP
model of objects passing messages to other objects, which generally
implies statefulness.
Cheers,
Ian
--
http://mail.python.org/mailman/listinfo/python-list
es I noticed that people write 'import os.path' in
> this case. Which is better practice?
"import os.path" is better practice. There is no guarantee in general
that the os module will automatically import os.path, and in future
versions or different implementations it might not.
Cheers,
Ian
--
http://mail.python.org/mailman/listinfo/python-list
On Thu, Feb 24, 2011 at 9:41 AM, Jeremy wrote:
> I recently found the wiki page on sorting
> (http://wiki.python.org/moin/HowTo/Sorting/). This page describes the new
> key parameter to the sort and sorted functions.
>
> What about custom objects? Can I just write __lt__, __gt__, etc. function
On Sun, Feb 27, 2011 at 7:15 AM, n00m wrote:
> http://www.spoj.pl/problems/TMUL/
>
> Python's "print a * b" gets Time Limit Exceeded.
If speed is the only thing you care about, then you can forget about
fretting over whether 2.5 or 3.1 is faster. You're using the wrong
language to begin with.
--
On Fri, Mar 4, 2011 at 5:26 PM, MRAB wrote:
>> UnsupportedOperation: can't do non-zero end-relative seeks
>>
>> But offset is initialized to -10. Does anyone have any thoughts on
>> what the error might be caused by?
>>
> I think it's because the file has been opened in text mode, so there's
> the
On Mon, Mar 7, 2011 at 6:30 AM, n00m wrote:
> Remind me this piece of humor:
>
> One man entered a lift cabin at the 1st floor,
> lift goes to the3rd floor, opens and ... it's empty!
> Physicist, Chemist and Mathematician were asked:
> what happened to the man?
>
> Physicist: he was squashed to th
On Wed, Mar 9, 2011 at 2:01 PM, Victor Subervi wrote:
> Maya 2012: Transform At the Source
Yow. You're designing a Maya 2012 website to help some travel company
bilk gullible people out of thousands of dollars? I would be ashamed
to have anything to do with this.
--
http://mail.python.org/mail
On Fri, Mar 11, 2011 at 10:40 AM, Victor Subervi
wrote:
> Um...just for the record, these guys have ben featured on the FRONT PAGES
> OF:
> [SNIPPED]
I don't care if the company was founded by the second coming of Jesus
Christ; I just call it like I see it.
> They're ligit :)
Oh, I have no doub
On Mon, Mar 14, 2011 at 1:39 PM, Paul Rubin wrote:
> Finally I concocted an "infinite" example which we agreed is artificial:
> you are given a list of generators denoting real numbers, for example
> pi generates the infinite sequence 3,1,4,1,5,9... while e generates
> 2,7,1,8,... You can sort th
On Tue, Mar 15, 2011 at 2:00 AM, Paul Rubin wrote:
> Ian Kelly writes:
>> I would think that you can sort them with key as long as none of the
>> sequences are equal (which would result in an infinite loop using
>> either method). Why not this?
>
> Yes you can do so
On Thu, Mar 17, 2011 at 10:46 AM, kracekumar ramaraju
wrote:
> I tried the following
22/7.0
> 3.1428571428571428
import math
math.pi
> 3.1415926535897931
>
>
> Why is the difference is so much ?is pi =22/7 or something ?
Pi is not 22/7. That is just a commonly-used approximat
On Thu, Mar 17, 2011 at 10:57 AM, Ian Kelly wrote:
> On Thu, Mar 17, 2011 at 10:46 AM, kracekumar ramaraju
> wrote:
>> I tried the following
>>>>> 22/7.0
>> 3.1428571428571428
>>>>> import math
>>>>> math.pi
>> 3.14159265358
On Thu, Mar 17, 2011 at 11:36 AM, Jeffrey Gaynor wrote:
> There are fun math questions, for instance, is there a run of a million 1's
> someplace in the decimal expansion of pi? Maybe so, but we just don't know,
> since we've only computed the first trillion or so digits.
Since pi is irrational
On Mon, Mar 21, 2011 at 7:31 PM, Benjamin Kaplan
wrote:
> On Mon, Mar 21, 2011 at 8:59 PM, Mike Patterson
> wrote:
>> In my Python class the other day, the professor was going over
>> decorators and he briefly mentioned that there had been this huge
>> debate about the syntax and using the @ sign
On Wed, Mar 23, 2011 at 9:14 AM, Antoon Pardon
wrote:
> Which isn't helpfull if where you decide how they have to be sorted is
> not the place where they are actually sorted.
>
> I have a class that is a priority queue. Elements are added at random but
> are removed highest priority first. The pri
On Thu, Mar 24, 2011 at 3:23 AM, Antoon Pardon
wrote:
> Sure I can do that. I can do lots of things like writing a CMP class
> that I will use as a key and where I can implement the logic for
> comparing the original objects, which I otherwise would have put in a
> cmp function. I thought this was
On Thu, Mar 24, 2011 at 10:47 AM, Antoon Pardon
wrote:
>> That's not what you wrote before. You wrote "I can't do the sort in
>> multiple steps." I was just responding to what you wrote.
>
> That is because I tend to assume some intelligence with those I
> communicate with, so that I don't need
On Fri, Mar 25, 2011 at 12:30 AM, Paddy wrote:
def fs(f, s): return [f(value) for value in s]
Note that your "fs" is basically equivalent to the "map" builtin,
minus some of the features.
fsf1 = partial(fs, f=f1)
fsf1(s)
> Traceback (most recent call last):
> File "", line 1, in
On Fri, Mar 25, 2011 at 1:03 AM, Ian Kelly wrote:
> Moral of the story: if you pass in an argument by keyword, then the
> following arguments must be passed by keyword as well (or not at all),
> regardless of whether you're using partial or not.
To be clear, you can also jus
On Sun, Mar 27, 2011 at 10:17 PM, alex23 wrote:
> Civ 4 used it for most of the gameplay and interface, I believe,
> wrapping more performant libraries for the graphics & audio.
For Civ 5, however, they have switched to Lua -- I think primarily for
speed reasons.
--
http://mail.python.org/mailma
On Mon, Mar 28, 2011 at 4:55 AM, Dave Angel wrote:
> I'd expect it to be very slow. I presume it not only has to visit and
> duplicate every bit of the data structure, but also has to detect loops, and
> avoid infinite loops recreating them.
>
> This loop detection is probably an n-squared algori
On Mon, Mar 28, 2011 at 3:38 PM, John Parker wrote:
> error:
> Traceback (most recent call last):
> File "Score_8.py", line 38, in
> tokens = lines.split(",")
> AttributeError: 'list' object has no attribute 'split'
>
> So, what am I doing wrong?
'lines' is a list of strings.
'split' is a st
On Tue, Mar 29, 2011 at 1:08 PM, Chris Angelico wrote:
> On Wed, Mar 30, 2011 at 5:57 AM, MRAB wrote:
>> You would have to do more than that.
>>
>> For example, "" < "A", but if you "negate" both strings you get "" <
>> "\xBE", not "" > "\xBE".
>
> Strings effectively have an implicit character a
On Tue, Mar 29, 2011 at 5:06 PM, MRAB wrote:
> I think I've found a solution:
>
> class NegStr:
> def __init__(self, value):
> self._value = value
> def __lt__(self, other):
> return self._value > other._value
IOW:
cmp_to_key(lambda x, y: -cmp(x, y))
This
On Thu, Mar 31, 2011 at 3:14 PM, Wehe, Marco wrote:
> Hi,
>
>
>
> I am doing a search through a list of files but the text the casing doesn't
> match. My list is all upper case but the real files are all different. Is
> there a smooth way of searching through the list without going full on
> reg
you really want the indexes rather than the values, do:
for j in xrange(len(bList)):
# do something
Note that in Python 3 you should use range instead of xrange. If you
want both the indexes and the values, then do this:
for j, value in enumerate(bList):
# do something
Cheers,
Ian
--
http://mail.python.org/mailman/listinfo/python-list
gt;> c = re.compile(regexp, re.IGNORECASE | re.DOTALL)
>>> c.findall(text)
But note that this is computationally expensive. The regex that you
posted is probably more efficient if you use a collections.Counter
object instead of z.count.
Cheers,
Ian
--
http://mail.python.org/mailman/listinfo/python-list
ems
and the values are the numbers of modifications. Your return value
would either be the dict itself or the result of dict.items().
If you're using a recent enough version of Python, you might also have
a look at the collections.Counter class, which is a dict subclass that
is specialized for counting things.
Cheers,
Ian
--
http://mail.python.org/mailman/listinfo/python-list
ards that play a role in the pattern-matching but don't establish any
> binding. Can that be done in Python?
No, unfortunately.
Cheers,
Ian
--
http://mail.python.org/mailman/listinfo/python-list
On Wed, Apr 6, 2011 at 1:51 PM, Paul Rubin wrote:
> In Haskell or ML, you can use patterns that contain wild
> cards that play a role in the pattern-matching but don't establish any
> binding. Can that be done in Python?
>
> Not as much. You could say something like
>
> sorted(en
tor-generator(stream-of-parsed-expressions, errors)
def evaluator-generator(stream-of-tokens, errors):
for token in stream-of-tokens:
try:
yield token.evaluate() # evaluate() returns a Result
except Exception as exception:
errors.append(exception)
# or:
# errors.append(EvaluatorExceptionContext(exception, ...))
Cheers,
Ian
--
http://mail.python.org/mailman/listinfo/python-list
On Fri, Apr 8, 2011 at 10:26 AM, candide wrote:
x=42
bool(x=5)
> True
>
>
> but _expression_ :
>
> x=42
>
>
> has no value.
"x=42" is an assignment statement, not an expression.
In "bool(x=5)", "x=5" is also not an expression. It's passing the
expression "5" in as the parameter x,
browser. To say "IE is dead" is either prevarication or
unsubstantiated wishful thinking.
Cheers,
Ian
--
http://mail.python.org/mailman/listinfo/python-list
On Tue, Apr 12, 2011 at 12:00 PM, Teemu Likonen wrote:
> I'm a simple Lisp guy who wonders if it is be possible to add some kind
> of macros to the language. Then features like this could be added by
> anybody. Lisp people do this all the time and there is no need for
> feature requests or any dis
On Tue, Apr 12, 2011 at 12:25 PM, Ian Kelly wrote:
> On Tue, Apr 12, 2011 at 12:00 PM, Teemu Likonen wrote:
>> I'm a simple Lisp guy who wonders if it is be possible to add some kind
>> of macros to the language. Then features like this could be added by
>> anybody. L
stment from me for installation,
configuration, and maintenance. I would not and do not use it for
everything, but I am able to appreciate the convenience. So now you
can say that you know one person.
Cheers,
Ian
--
http://mail.python.org/mailman/listinfo/python-list
On Tue, Apr 12, 2011 at 2:51 PM, Dan Stromberg wrote:
> This data is of course skewed a bit toward computers that people are
> using web browsers on.
Right, Linux servers are most likely underrepresented. At best the
data indicates what the population at large is using on their
desktops.
> Also
is also a rather tech-savvy thing to do.
I sincerely doubt that more than a couple percent of the population
actually does this. The rest would either grumble about it and start
up IE, or just leave the site without looking back.
Cheers,
Ian
--
http://mail.python.org/mailman/listinfo/python-list
app I'm looking for: http://i52.tinypic.com/2uojswz.png
>
> Which would you recommend?
Komodo has all of those features and might be worth a look. However,
I don't think the free version includes the embedded interpreter, and
I doubt whether the licensed version can be run fr
n function(*args, **kwargs)
return wrapper
call_counter = CallCounter()
@call_counter.call_counts
def f1_with_shared_counts():
pass
@call_counter.call_counts
def f2_with_shared_counts():
pass
Cheers,
Ian
--
http://mail.python.org/mailman/listinfo/python-list
On Tue, Apr 19, 2011 at 1:12 AM, Timo Schmiade wrote:
> Just one question remains now: What is a "Borg" in this context?
http://code.activestate.com/recipes/66531/
--
http://mail.python.org/mailman/listinfo/python-list
On Tue, Apr 19, 2011 at 10:31 AM, Ethan Furman wrote:
> Gerald Britton wrote:
>>
>> I now understand the Python does
>> not consider a class definition as a separate namespace as it does for
>> function definitions. That is a helpful understanding.
>
> That is not correct. Classes are separate n
? If this is part of a class
definition, that could explain why the lambda is not seeing the type /
posttype closure: because there isn't one.
Cheers,
Ian
--
http://mail.python.org/mailman/listinfo/python-list
> def f():
... t = 42
... print filter(lambda x: x == t, [42])
...
>>> f()
[42]
>>> t = 43
>>> print filter(lambda x: x == t, [43])
[43]
So, the question for the OP: Is this file being run with execfile?
Cheers,
Ian
--
http://mail.python.org/mailman/listinfo/python-list
On Wed, Apr 20, 2011 at 12:03 PM, Chris Angelico wrote:
> On Thu, Apr 21, 2011 at 12:44 AM, Ian Kelly wrote:
>> So, the question for the OP: Is this file being run with execfile?
>>
>
> Not execfile per se; the code is fetched from the database and then
> execut
On Thu, Apr 21, 2011 at 12:28 AM, harrismh777 wrote:
> I don't like SPAM with my eggs and ham...
Nor do the rest of us, so please don't help it circumvent our spam
filters by reposting it.
--
http://mail.python.org/mailman/listinfo/python-list
On Fri, Apr 22, 2011 at 7:49 AM, Kyle T. Jones
wrote:
>> You don't need to create an instance of BaseHandler. You have the
>> class, Python knows you have the class -- Python will look there if the
>> subclasses lack an attribute.
>>
>> ~Ethan~
>>
>
> Really? That's not at all how I thought it w
def __call__(self):
> return self.target()
>
> in order to do
>
> actions.append(Job(function, val))
> actions.append(Job(function, x=val))
from functools import partial
actions.append(partial(function, val))
actions.append(partial(function, x=val))
Cheers,
Ian
--
http://mail.python.org/mailman/listinfo/python-list
iple-inherit/
>
> Comments welcome!
On line 14, is it intentional that attributes whose values happen to
be false are not considered as conflicts?
On line 31, this code:
thing = getattr(thing, '__func__', None) or thing
could be simplified to this:
thing = getattr(thing,
wargs.
Theoretically this would break if you had two mixins accepting the
same argument, but I can't think of an actual case where that might
happen.
Cheers,
Ian
--
http://mail.python.org/mailman/listinfo/python-list
we later decide to add mixin_arg3, then we have to
also add it to the Derived1.__init__ signature and then add a line to
set the attribute. In the latter case, adding mixin_arg3 has no
effect on the Derived2 initializer at all, because it passes through
transparently in the kwargs.
Cheers,
Ian
--
http://mail.python.org/mailman/listinfo/python-list
On Fri, Apr 29, 2011 at 9:57 PM, Jason Friedman wrote:
> The first call to fib() recursively calls fib() twice. Each of those
> will call fib() twice. Each of those will call fib() twice. Pretty
> soon, you've got a lot of calls.
Which is hell for the running time, but doesn't answer the quest
On Mon, May 2, 2011 at 11:23 AM, Jack Bates wrote:
> Hi, anyone know why these two statements aren't equivalent?
>
> raise (type, value, traceback)
>
> raise type, value, traceback
The latter is the syntax of the raise statement: up to 3 expressions,
separated by commas.
The former has a single
On Mon, May 2, 2011 at 2:48 PM, David Monaghan
wrote:
> On Mon, 2 May 2011 10:33:31 -0700 (PDT), Raymond Hettinger
> wrote:
>
>>I think it is time to give some visibility to some of the instructive
>>and very cool recipes in ActiveState's python cookbook.
>>
>>My vote for the coolest recipe of al
On Mon, May 2, 2011 at 3:50 PM, harrismh777 wrote:
> Thomas Rachel wrote:
>>>
>>> ... because each recursion level 'return' calls fib() twice, and each of
>>> those calls fib() twice, and you get the point...
>>
>> yes - but they are called one after the other, so the "twice" call
>> counts only f
On Mon, May 2, 2011 at 11:04 PM, Stefan Behnel wrote:
> The bad thing about this recipe is that it requires quite a bit of
> background knowledge in order to infer that the code the developer is
> looking at is actually correct. At first sight, it looks like an evil hack,
> and the lack of documen
On Mon, May 2, 2011 at 11:27 PM, Dan Stromberg wrote:
> But the recursive solution has time complexity of O(logn). The iterative
> solution has time complexity of O(n). That's a significant difference for
> large n - a significant benefit of the recursive version.
It's linear as written. I th
On Tue, May 3, 2011 at 3:54 PM, Chris Angelico wrote:
> On Wed, May 4, 2011 at 2:43 AM, Raymond Hettinger wrote:
>> We should have a separate thread for the most practical, best
>> documented, least surprising, and most boring recipe ;-)
>
> a += b # Adds b to a in-place. Polymorphic - works on
On Tue, May 3, 2011 at 3:41 PM, Chris Angelico wrote:
> On Wed, May 4, 2011 at 3:10 AM, harrismh777 wrote:
>> If your point is that the infinite process is the problem, I agree. But my
>> point is that the cpu crunch and the rate at which the call stack is filled
>> has to do with the double call
On Wed, May 4, 2011 at 10:52 AM, Grant Edwards wrote:
> On 2011-05-04, Matty Sarro wrote:
>> On Wed, May 4, 2011 at 12:34 PM, ETP wrote:
>>> I have a dos program (run in a window) that I would like to control
>>> with a script.
>
>> Look into the pexpect library, it'll make this easy as punch.
>
On Wed, May 4, 2011 at 3:09 PM, Wojtek Mamrak wrote:
> Hello,
>
> I spent a lot of time googling for a solution of this problem, with no
> result.
>
> I have a C++ application, in which I would like to embed Python interpreter.
> I don't want to rely on an interpreter being installed on user machi
On Wed, May 4, 2011 at 3:35 PM, harrismh777 wrote:
> Grant Edwards wrote:
>>>
>>> We do not consider passing a pointer as*by value* because its an
>>> > address; by definition, that is pass-by-reference.
>>
>> No, it isn't. It's pass by value. The fact that you are passing a
>> value that is a
On Thu, May 5, 2011 at 4:55 AM, Wojtek Mamrak wrote:
> Thanks for the reply!
>
>> Can you import from zip files when running the Python.exe interpreter?
> When I zip the folder "Lib" into Python27.zip and later rename it and
> try to run the python.exe, I receive an error:
> "Import error: no modu
On Thu, May 5, 2011 at 9:41 AM, John Nagle wrote:
> On 5/5/2011 3:06 AM, Gregory Ewing wrote:
>>
>> John Nagle wrote:
>>
>>> A reasonable compromise would be that "is" is treated as "==" on
>>> immutable objects.
>>
>> That wouldn't work for tuples, which can contain references
>> to other objects
1001 - 1100 of 3945 matches
Mail list logo