On Fri, Feb 22, 2013 at 12:00 PM, Christian Heimes wrote:
> Am 22.02.2013 10:35, schrieb Wolfgang Maier:
>> Also: can you use introspection to find out whether a type is valid as a
>> base type?
>
> I don't think so. For CPython the information is stored in the type's
> structure. When type->tp_fl
On Thu, Oct 18, 2012 at 8:42 PM, Demian Brecht wrote:
>> str, bytes, bytearrays, arrays, sets, frozensets, dicts, dictviews, and
>> ranges should all return len in O(1) time. That includes the possibility
>> of a subtraction as indicated above.
>
> Awesome. Pretty much what I figured. Of course, I
On Fri, Jun 8, 2012 at 6:10 PM, Julio Sergio wrote:
> >From a sequence of numbers, I'm trying to get a list that does something to
> >even
> numbers but leaves untouched the odd ones, say:
>
> [0,1,2,3,4,...] ==> [100,1,102,3,104,...]
>
> I know that this can be done with an auxiliary function, a
On Sat, Jun 11, 2011 at 21:39, Terry Reedy wrote:
> What may not be obvious from the docs is that the metaclass calculation
> described in the doc section on class statements is carried out within
> type.__new__ (or after a possible patch, called from within that), so that
> type calls are really
> Do you know any open source python3 projects that use function
> annotations? I would like to see some real use, so maybe I find them
> useful to use in my own project.
threecheck uses them for type checking: http://pypi.python.org/pypi/threecheck
Daniel
--
http://mail.python.org/mailman/list
On Sat, Feb 5, 2011 at 15:38, Steven D'Aprano
wrote:
> On Sat, 05 Feb 2011 14:38:29 +0100, Daniel Urban wrote:
>
>> On Sat, Feb 5, 2011 at 14:08, Lisa Fritz Barry Griffin
>> wrote:
>>> Hi there,
>>>
>>> How can I do this in a one
On Sat, Feb 5, 2011 at 14:08, Lisa Fritz Barry Griffin
wrote:
> Hi there,
>
> How can I do this in a one liner:
>
> maxCountPerPhraseWordLength = {}
> for i in range(1,MAX_PHRASES_LENGTH+1):
> maxCountPerPhraseWordLength[i] = 0
maxCountPerPhraseWordLength = {0 for i in ra
On Fri, Jan 28, 2011 at 20:02, Alan wrote:
> Can the below example be fixed to work?
> Thanks,
> Alan Isaac
>
> import multiprocessing as mp
>
> class Test(object):
> pass
>
> def class_factory(x):
> class ConcreteTest(Test):
> _x = x
> return ConcreteTest
>
> def f(cls):
> prin
On Fri, Jan 28, 2011 at 11:32, Alan Franzoni wrote:
> On Thu, Jan 27, 2011 at 11:41 PM, Daniel Urban wrote:
>
>> Actually it can. You don't have to modify the object, just check for
>> the desired methods/signature/whatever. See for example the
>> implement
On Thu, Jan 27, 2011 at 20:05, Alan Franzoni wrote:
> On Thu, Jan 27, 2011 at 8:03 PM, Alan Franzoni wrote:
>> Yes, __instancecheck__ could be used as an alternative hook with
>> respect to maybe_implemented_by(), but there's no such logic for
>> signature checking. That's a minor detail, I think
> That's just what I'd like and I suppose can't be currently done with
> current ABC, PyProtocols or zope.interface implementations, right?
It can. With __instancecheck__ you can override isinstance. It is
possible (for example) to write a subclass of abc.ABCMeta, which
extends __instancecheck__ t
On Thu, Jan 20, 2011 at 01:51, Chris Kaynor wrote:
> I am implemented a custom set-like type which interacts with some
> third-party software when retrieving and mutating the set, and have derived
> my custom type off of collections.MutableSet, however I have noticed that
> some of the magic metho
On Fri, Dec 24, 2010 at 17:24, kj wrote:
> (BTW, I don't understand why inspect doesn't provide something as
> basic as the *class* that the method belongs to, whenever applicable.
> I imagine there's a good reason for this coyness, but I can't figure
> it out.)
One function object can "belong to
> So far, the only situation I can find where method names necessarily
> overlap is for the basics like __init__(), close(), flush(), and
> save() where multiple parents need to have their own initialization
> and finalization.
One other possibility is subclasses of the JSONEncoder class. For
exam
b = list(a)
or
b = a[:]
--
http://mail.python.org/mailman/listinfo/python-list
> However, what exactly does ^ do?
Bitwise XOR:
http://docs.python.org/py3k/reference/expressions.html#binary-bitwise-operations
--
http://mail.python.org/mailman/listinfo/python-list
> f = open("myfile.txt")
> for line in f:
> print line
> f.close() # This is what the "with" statement guarantees; so now just do
> it yourself
Not exactly. More like:
f = open("myfile.txt")
try:
for line in f:
print line
finally:
f.close()
Daniel
--
http://mail.python.org/
> a = "{'a':'1','b':'2'}"
> how to change a into a dictionary ,says, a = {'a':'1','b':'2'}
See also the ast.literal_eval function:
http://docs.python.org/py3k/library/ast.html#ast.literal_eval
Daniel
--
http://mail.python.org/mailman/listinfo/python-list
> I'm building an elevator simulator for a class assignment. I recently ran
> into a roadblock and don't know how to fix it. For some reason, in my
> checkQueue function below, the call to self.goUp() is never executed. It is
> on the last line of code I pasted in. I can put print statements before
19 matches
Mail list logo