On Mon, Jul 29, 2013 at 5:49 AM, Joshua Landau wrote:
> Also, couldn't Counter just extend from defaultdict?
It could, but I expect the C helper function in 3.4 will be faster
since it doesn't even need to call __missing__ in the first place.
And the cost (both in terms of maintenance and run-tim
On Mon, Jul 29, 2013 at 11:04 AM, MRAB wrote:
> On 29/07/2013 17:40, Ian Kelly wrote:
>> At the point where the float is exactly equal to the value you get
>> from the floating-point division 1/3. If it's some other float then
>> the user didn't get there by
On Mon, Jul 29, 2013 at 12:16 PM, Rotwang wrote:
> On 29/07/2013 17:40, Ian Kelly wrote:
>> At the point where the float is exactly equal to the value you get
>> from the floating-point division 1/3.
>
>
> But the interpreter has no way of knowing that the value 1/3 tha
On Jul 29, 2013 1:37 PM, "Serhiy Storchaka" wrote:
>
> 29.07.13 19:09, MRAB написав(ла):
>
>> I'm surprised that Fraction(1/3) != Fraction(1, 3); after all, floats
>> are approximate anyway, and the float value 1/3 is more likely to be
>> Fraction(1, 3) than Fraction(6004799503160661, 180143985094
On Mon, Jul 29, 2013 at 4:04 PM, John Ladasky
wrote:
> pyglet-1.2alpha1/examples/programming_guide/hello_world.py runs fine.
>
> pyglet-1.2alpha1/examples/programming_guide/image_viewer.py also runs fine.
>
> pyglet-1.2alpha1/examples/programming_guide/animation.py produces an error.
> Here's th
On Jul 30, 2013 10:06 AM, "Chris Angelico" wrote:
>
> On Tue, Jul 30, 2013 at 3:06 PM, Devyn Collier Johnson
> wrote:
> > Aloha everyone!
> >
> >I attached a script that I thought I could share with everyone for
your
> > help. This Python3 script only works on Unix systems. It prints the
curr
On Tue, Jul 30, 2013 at 12:18 PM, Bas van der Wulp wrote:
> Replacing each occurrence of self._value with either self._value_ or
> self.value in the examples seems to make them work as expected.
>
> Are both examples incorrect, or not intended to work in Python 2.x?
The _value attribute was renam
On Tue, Jul 30, 2013 at 4:58 AM, Albert van der Horst
wrote:
> Notice that all values from i on are possibly present.
> So you are better off with a list indexed by forthcoming i's and
> each item containing a list of primes. What you do then, more or less,
> is keep track of all dividers of prime
On Wed, Jul 31, 2013 at 4:08 AM, wrote:
> OK thanks for your answers.
> So Python is not a daemon. Is it?
No.
> Does it have a config file?
Not as such. Arbitrary site-specific customization can be done by
creating a sitecustomize module, but this is not standard. There are
also some environ
On Wed, Jul 31, 2013 at 10:44 AM, Ian Kelly wrote:
> and then set the PYTHONHOME environment variable to /usr/lib.
Rather, just /usr.
--
http://mail.python.org/mailman/listinfo/python-list
On Wed, Jul 31, 2013 at 5:02 AM, Chris Angelico wrote:
> On Wed, Jul 31, 2013 at 11:53 AM, Gabor Urban wrote:
>> Hi,
>>
>> I am to start a new free-time project in the next couple of weeks. I am
>> ready to use open accessible Python modules not wanting to reinvent the weel
>> :-)
>> Is there any
On Wed, Jul 31, 2013 at 12:53 AM, Musical Notation
wrote:
> Is it possible to write a Turing-complete lambda function (which does not
> depend on named functions) in Python?
Yes, lambda functions are Turing-complete. You can get anonymous
recursion by defining the function to take a recursive f
On Jun 18, 2012 8:07 AM, "jmfauth" wrote:
> A string is a string, a "piece of text", period.
>
> I do not see why a unicode literal and an (well, I do not
> know how the call it) a "normal class " should behave
> differently in code source or as an answer to an input().
Strings are a data type th
f(x):
... return x + 1
...
>>> dis.dis(f)
2 0 LOAD_FAST0 (x)
3 LOAD_CONST 1 (1)
6 BINARY_ADD
7 RETURN_VALUE
Cheers,
Ian
--
http://mail.python.org/mailman/listinfo/python-list
On Wed, Jun 20, 2012 at 7:27 PM, Chris Angelico wrote:
> Java's bytecode and source code are two distinct languages, both well
> documented and separately usable (and with their own distinct
> limitations - there are things you can do in Java bytecode that you
> cannot do in Java source).
I can t
On Sat, Jun 23, 2012 at 8:23 PM, gmspro wrote:
> I'm trying to call this function,
> http://hg.python.org/cpython/file/3b7230997425/Modules/arraymodule.c#l657
>
> Is that possible to call that function?
>
> I know it's possible to do:
> >>>len(arr)
You call it just like that. array_length is th
On Jun 27, 2012 9:57 PM, wrote:
> [1] of course that is when using `filestr.count("print")` -- I assume
that the word "print" is not used excessively in comments or docstrings.
Someone else can do a less naive search if they like.
Or as part of a longer name, e.g. the traceback.print_* family of
east in Python) while the
second is false.
I will take ambiguity that is mostly unimportant over ambiguity that
is critical to the meaning of the expression any day of the week.
Cheers,
Ian
--
http://mail.python.org/mailman/listinfo/python-list
On Mon, Jul 2, 2012 at 1:35 PM, Rick Johnson
wrote:
> I am reminded of a story: A few years back a very nice old woman
> offered to give me her typewriter. She said: "i might need to type a
> letter one day and it would good to have around". It was a nice
> typewriter for 1956, but she had no idea
a maximum length to close off one DoS attack vector.
Without a limit, if a "user" presents a 1 GB password, then guess
what? Your system has to hash that GB of data before it can reject
it. And if you're serious about security then it will be a
cryptographic hash, and that means slow.
To prevent that, the system needs to reject outright password attempts
that are longer than some predetermined reasonable length, and if the
system won't authenticate those passwords, then it can't allow the
user to set them either.
Cheers,
Ian
--
http://mail.python.org/mailman/listinfo/python-list
On Tue, Jul 3, 2012 at 12:18 PM, John Gordon wrote:
> In Kushal Kumaran
> writes:
>
>> I haven't actually seen the rest of the code, but I would like to
>> point out that applications placing maximum length limits on passwords
>> are extremely annoying.
>
> As a practical matter, doesn't there
On Tue, Jul 3, 2012 at 2:40 PM, Dan Stromberg wrote:
>
> Why is it that so much 3rd party python code gets installed to
> site-packages?
Because that's what site-packages is for?
> Even for things that are almost certainly going to be used by a single
> application?
>
> Even for things you might
On Tue, Jul 3, 2012 at 3:34 PM, Dan Stromberg wrote:
> If it was intended to be reusable code, I'd think it -should- go in
> site-packages.
>
> But so much code in site-packages isn't intended to be reusable.
Can you give some examples? Looking through my site-packages
directory, everything in t
On Tue, Jul 3, 2012 at 4:38 PM, Dan Stromberg wrote:
>> Right now this all seems highly speculative to me. I think it might
>> be informative, either to you or to me, to do an actual timing test.
>> Why don't you try setting up two side-by-side installations of Python,
>> one with all the site-pa
On Tue, Jul 3, 2012 at 5:06 PM, Ian Kelly wrote:
> On Tue, Jul 3, 2012 at 4:38 PM, Dan Stromberg wrote:
>>> Right now this all seems highly speculative to me. I think it might
>>> be informative, either to you or to me, to do an actual timing test.
>>> Why don
lo
arithmetic, because unlike C, Python actually has well-defined
semantics regarding modulo division of negative numbers.
>>> (13382 + 86400 - 42597) % 86400
57185
>>> (13382 - 42597) % 86400
57185
Cheers,
Ian
--
http://mail.python.org/mailman/listinfo/python-list
thon are you using, and
on what platform?
I have one suggestion, though: you might try removing the __del__
method from the listener class, as the presence of that method can
interfere with garbage collection in some cases, and it is generally
contra-recommended. I'm not sure why that would affect the code you
posted, but it can't hurt to try it.
Cheers,
Ian
--
http://mail.python.org/mailman/listinfo/python-list
On Fri, Jul 6, 2012 at 11:04 AM, Ian Kelly wrote:
> On that, I'm really not sure. I tried to reproduce the problem
> locally and wasn't able to. What build of Python are you using, and
> on what platform?
I spoke too soon, I am able to reproduce it. I think what's go
On Fri, Jul 6, 2012 at 11:48 AM, Ian Kelly wrote:
> def del_b(self, b):
> for i, x in enumerate(self.array):
> if b is x:
> del self.array[i]
That should probably have an explicit break on the end:
def del_b(self, b):
for i, x
On Tue, Jul 10, 2012 at 4:26 PM, Dennis Lee Bieber
wrote:
> On Tue, 10 Jul 2012 09:05:50 -0700, Ethan Furman
> declaimed the following in gmane.comp.python.general:
>
>> As an example from today, if someone claimed to have 5+ years of Python
>> experience, but didn't know that 'with' was standard
On Wed, Jul 11, 2012 at 4:28 AM, Colin J. Williams wrote:
> I don't understand why you would expect 1, 2, 4.
Because:
funcs[0](2) == 2 ** 0 == 1
funcs[1](2) == 2 ** 1 == 2
funcs[2](2) == 2 ** 2 == 4
> Perhaps parentheses will help the order of evaluation:
>
> funcs = [(lambda x: x**i) for i in
cent call last):
File "", line 1, in
TypeError: f() got multiple values for keyword argument 'b'
It would be a bit clearer if it instead noted that 'c' were
keyword-only in the 'g' argspec.
Cheers,
Ian
--
http://mail.python.org/mailman/listinfo/python-list
27;m not sure how precise that is -- I believe that
terminology more accurately describes whether method and attribute
names are looked up at compile-time or at run-time, late binding being
the feature that makes duck typing possible.
Cheers,
Ian
--
http://mail.python.org/mailman/listinfo/python-list
Announcing Urwid 1.0.2
--
Urwid home page:
http://excess.org/urwid/
Manual:
http://excess.org/urwid/wiki/UrwidManual
Tarball:
http://excess.org/urwid/urwid-1.0.2.tar.gz
About this release:
===
This is a stable bug-fix-only release.
A number of bugs t
On Fri, Jul 13, 2012 at 5:09 PM, Terry Reedy wrote:
>
>> From now on, for each operator I would have to remember wether it
>> is a supposedly comparison operator or not.
>
>
> I believe the following rule is true: if a op b is True or False raises,
I don't follow. Raises what?
> then op is a po
On Sun, Jul 15, 2012 at 4:56 AM, Steven D'Aprano
wrote:
> (For the record, I can only think of one trap for the unwary: time
> objects are false at *exactly* midnight.)
Ugh, that's irritating. I can't think of any scenario where I would
ever want the semantics "if timeval (is not midnight):". T
d2):
return set(d1.items()).issubset(d2.items())
Finally, isempty(d) is basically equivalent to "not d", which is both
shorter and faster.
Cheers,
Ian
--
http://mail.python.org/mailman/listinfo/python-list
On Sun, Jul 15, 2012 at 11:16 AM, Andrew Berg wrote:
> On 7/15/2012 11:19 AM, Ian Kelly wrote:
>> Ugh, that's irritating. I can't think of any scenario where I would
>> ever want the semantics "if timeval (is not midnight):".
> It
On Sun, Jul 15, 2012 at 10:50 AM, Rick Johnson
wrote:
> I think this issue is not so much a "bool test" vs "type test", but more an
> ambiguous syntax issue. Consider this:
>
> ## EXAMPLE A ##
> py> if money:
> ... do_something()
>
> The syntax "if money" implies we are testing/measuring some
On Tue, Jul 17, 2012 at 6:23 AM, Michele Simionato
wrote:
> The standard is to use `cls`. In the __new__ method you can use `mcl` or
> `meta`.
I've also seen `mcs` a fair amount.
--
http://mail.python.org/mailman/listinfo/python-list
On Tue, Jul 17, 2012 at 12:10 AM, alex23 wrote:
> On Jul 17, 1:29 am, Steven D'Aprano +comp.lang.pyt...@pearwood.info> wrote:
>> Here's a style question for you: in a metaclass, what should I call the
>> instance parameter of methods, "cls" or "self"?
>
> Maybe portmanteu it as "clasself"? :)
Wh
On Tue, Jul 17, 2012 at 4:57 PM, Ethan Furman wrote:
> In Foxpro if you do a
>
> GOTO 7
>
> with deleted off and record 7 is deleted, the record pointer doesn't
> move (at least in version 6).
>
> I don't like that.
>
> I see four other options:
>
> 0) don't move the pointer (listed for completene
code. How can i import stack? Where is the code for it?
Google turns up this post, also from 1994:
https://groups.google.com/forum/?fromgroups#!topic/comp.lang.python/5qBmi7K-mo4
Cheers,
Ian
--
http://mail.python.org/mailman/listinfo/python-list
On Wed, Jul 18, 2012 at 8:40 AM, Grant Edwards wrote:
> On 2012-07-17, Ethan Furman wrote:
>
>> In Foxpro if you do a
>
> Foxpro?
http://en.wikipedia.org/wiki/Visual_FoxPro
--
http://mail.python.org/mailman/listinfo/python-list
On Thu, Jul 19, 2012 at 3:01 PM, John Gordon wrote:
> In Dennis Lee Bieber
> writes:
>
>> > Sure it terminates...If you don't run out of RAM to represent the
>> > number "i" in question, there's also this "heat death of the
>> > universe" limit I keep hearing about ;-)
>> >
>> Since the c
g the database from scratch took about a
minute; adding the index took about another minute. Incremental
updates would of course be much faster. Queries like "select * from
data where timestamp between 50 and 60" return instantly (from
a user perspective).
Cheers,
Ian
--
http:/
On Fri, Jul 20, 2012 at 5:38 PM, Chris Williams
wrote:
> Hello
>
> I hope this is the right newsgroup for this post.
>
> I am just starting to learn python programming and it seems very
> straightforward so far. It seems, however, geared toward doing the sort of
> programming for terminal output.
you might find it helpful to use slightly
more verbose names than l or t - its not immediately obvious to the
reader what these are intended to represent.
Regards,
Ian
--
http://mail.python.org/mailman/listinfo/python-list
tween map or a
comprehension based on whether I need to call a function or not (and
also based on how pretty or ugly the resulting code is). Anything
further would just be premature optimization. Also keep in mind that
in Python 3 map returns an iterator instead of a list, so for a fair
comparison
On Mon, Jul 23, 2012 at 11:19 AM, wrote:
> All,
>
> I am trying to figure out how to send a image in the body of a email when
> Making a Meeting Request.
You need to use html in the body with an tag that references the
attachment. See:
http://stackoverflow.com/questions/4312687/how-to-embed-
On Mon, Jul 23, 2012 at 12:33 PM, wrote:
> I tried something similar to the example at
> http://stackoverflow.com/questions/4312687/how-to-embed-images-in-email .
>
> Problem is, this line is not understood:
>mail.BodyFormat = OlBodyFormat.olFormatHTML
>
> Traceback (most recent call
On Mon, Jul 23, 2012 at 7:19 PM, Andrew Cooper wrote:
> Python is a statically scoped language, whereas the functionality you
> are expecting would be an example of dynamically scoped.
While it's true that Python is statically scoped, that has nothing at
all to do with the code from the OP's ques
On Tue, Jul 24, 2012 at 8:50 AM, Chris Angelico wrote:
> Americans celebrate March 14th as 3.14; some Europeans celebrate July
> 22nd as 22/7 (which is 3.142857, fairly close to 3.14159). We claim
> both, and also June 28th (aka Tau Day or Two Pi Day, 6.28).
Hey now, Tau Day is an American invent
On Jul 24, 2012 12:32 PM, wrote:
> after i need to calculate unique combination in pairs to count the
observations
> and obtain
> (4,3,2)
> (4,5,1)
> (5,4,1)
> (4,4,2)
I don't know about a numpy solution, but this could be achieved by
collections.Counter(zip(a, b)).items(). That gives you:
((4,3
On Tue, Jul 24, 2012 at 8:59 AM, Dieter Maurer wrote:
> "ivdn...@gmail.com" writes:
>
>> I have a daemon process that runs for a considerable amount of time (weeks
>> on end) without any problems. At some point I start getting the exception:
>>
>> Exception info: Traceback (most recent call last
On Tue, Jul 24, 2012 at 1:32 PM, Paul Rubin wrote:
> Dieter Maurer writes:
>> I have only one vague idea: should something try to terminate the
>> process, modules would start to lose their variables during shutdown.
>
> That happens all the time with multi-threaded programs, because the
> shutdo
On Tue, Jul 24, 2012 at 1:57 PM, Wanderer wrote:
> If I use the code
>
> assert False, "unhandled option"
>
> I get output like:
>
> option -q not recognized
> for help use --help
>
> What other expressions can I use other than "unhandled option"? Is there a
> list somewhere?
Are you using argpa
On Tue, Jul 24, 2012 at 2:44 PM, Wanderer wrote:
> I'm using getopt but not at that point. I really don't have a problem.
> I'm just curious. I've never seen anything else after
> assert False,
>
> Here is some code.
It doesn't matter what you put after the assert False, because that
line is not
On Jul 25, 2012 10:51 AM, "Devin Jeanpierre" wrote:
> True. But it might be nice to use pass both in lambdas and regular
> functions, or to use pass as a variable name.
You can already use pass (or the equivalent) in a lambda.
lambda: None
--
http://mail.python.org/mailman/listinfo/python-list
On Tue, Jul 24, 2012 at 9:07 PM, Ben Finney wrote:
> +1 on celebrating τ day! https://www.youtube.com/watch?v=jG7vhMMXagQ>
Also:
http://tauday.com/
--
http://mail.python.org/mailman/listinfo/python-list
On Thu, Jul 26, 2012 at 9:30 AM, Steven D'Aprano
wrote:
> What happens if you get a collision?
>
> That is, you have two different long identifiers:
>
> a.b.c.d...something
> a.b.c.d...anotherthing
>
> which by bad luck both hash to the same value:
>
> a.b.c.d.$AABB99
> a.b.c.d.$AABB99
>
> (or wha
On Thu, Jul 26, 2012 at 1:28 PM, Ian Kelly wrote:
> The odds of a given pair of identifiers having the same digest to 10
> hex digits are 1 in 16^10, or approximately 1 in a trillion. If you
> bought one lottery ticket a day at those odds, you would win
> approximately once every 3 b
On Thu, Jul 26, 2012 at 2:48 PM, John Ladasky
wrote:
> On Wednesday, July 25, 2012 1:40:45 AM UTC-7, Ulrich Eckhardt wrote:
>> Hi!
>>
>> I just had an idea, it occurred to me that the pass statement is pretty
>> similar to the print statement, and similarly to the print() function,
>> there could
On Fri, Jul 27, 2012 at 9:19 AM, Benoist Laurent wrote:
> That's the solution I came to.
> But I'm not very happy with this since I can definitively not make my
> program act as a standard unix tool.
> Any other solution?
I don't understand; that's pretty much the same way that standard unix
tool
On Fri, Jul 27, 2012 at 10:26 AM, Ian Kelly wrote:
> It may be a bit awkward having to type "-i" once per file in the
> command line, but it does clear up the ambiguity.
Or you could bite the bullet and make the input files argument part of
the subparser, which you may find ugl
On Mon, Jul 30, 2012 at 8:54 PM, Tim Chase
wrote:
> I've tried a similar experiment and am curious on your input device.
> Eye-tracking/dwell-clicking? A sip/puff joystick? Of the various
> input methods I tried, I found that Dasher[1] was the most
> intuitive, had a fairly high input rate and
On Tue, Jul 31, 2012 at 3:28 PM, Ifthikhan Nazeem wrote:
> as many as (about) 2*N - log2(N) parent child relationships
>
> I would like to know how did you come up with the above formula? Forgive my
> ignorance.
I come up with 2N - 2 myself. If there are N leaf nodes and N - 1
non-leaf nodes, th
this is clear,
Ian
On 06/08/12 16:52, Tom P wrote:
consider a nested loop algorithm -
for i in range(100):
for j in range(100):
do_something(i,j)
Now, suppose I don't want to use i = 0 and j = 0 as initial values,
but some other values i = N and j = M, and I want to iterate th
On Tue, Aug 14, 2012 at 9:18 PM, Chris Angelico wrote:
> On Wed, Aug 15, 2012 at 12:06 PM, Thomas 'PointedEars' Lahn
> wrote:
>> Please use `[...]' or `[…]' to indicate omission instead. I could have
>> written `politeness...' myself.
>
> Incidentally, how _do_ the square brackets help?
The squ
On Thu, Aug 16, 2012 at 6:47 AM, Hans Mulder wrote:
> On 8/08/12 04:14:01, Steven D'Aprano wrote:
>> NoneType raises an error if you try to create a second instance. bool
>> just returns one of the two singletons (doubletons?) again.
>>
>> py> type(None)()
>> Traceback (most recent call last):
>>
On Thu, Aug 16, 2012 at 12:00 PM, Aaron Brady wrote:
> The inconsistency is, if we remove an element from a set and add another
> during iteration, the new element might appear later in the iteration, and
> might not, depending on the hash code; therefore comparing the size of the
> set between
On Thu, Aug 16, 2012 at 4:55 PM, Ian Kelly wrote:
> On Thu, Aug 16, 2012 at 12:00 PM, Aaron Brady wrote:
>> The inconsistency is, if we remove an element from a set and add another
>> during iteration, the new element might appear later in the iteration, and
>> might not,
On Thu, Aug 16, 2012 at 5:11 PM, Dave Angel wrote:
> There's an enormous difference between type errors, which affect the low
> level dispatch, and checking for whether a dict has changed and may have
> invalidated the iterator. If we were really going to keep track of what
> iterators are tracki
On Aug 17, 2012 8:58 AM, "Dave Angel" wrote:
>
> Also, please tell us the versions involved, and in the case of
> ActiveSync, where you got it.
>
> http://sourceforge.net/apps/trac/unattended/wiki/ActiveSync
> seems to be perl related, not Python.
>
> Presumably you mean the Microsoft product
On Fri, Aug 17, 2012 at 6:46 AM, coldfire wrote:
> I would like to know that where can a python script be stored on-line from
> were it keep running and can be called any time when required using internet.
> I have used mechanize module which creates a webbroswer instance to open a
> website and
On Aug 17, 2012 2:58 PM, "Dave Angel" wrote:
>
> The internal coding described in PEP 393 has nothing to do with latin-1
> encoding.
It certainly does. PEP 393 provides for Unicode strings to be represented
internally as any of Latin-1, UCS-2, or UCS-4, whichever is smallest and
sufficient to con
(Resending this to the list because I previously sent it only to
Steven by mistake. Also showing off a case where top-posting is
reasonable, since this bit requires no context. :-)
On Sat, Aug 18, 2012 at 1:41 AM, Ian Kelly wrote:
>
> On Aug 17, 2012 10:17 PM, "Steven D'
On Sat, Aug 18, 2012 at 9:07 AM, wrote:
> Le samedi 18 août 2012 14:27:23 UTC+2, Steven D'Aprano a écrit :
>> [...]
>> The problem with UCS-4 is that every character requires four bytes.
>> [...]
>
> I'm aware of this (and all the blah blah blah you are
> explaining). This always the same song. M
On Sun, Aug 19, 2012 at 12:33 AM, Steven D'Aprano
wrote:
> On Sat, 18 Aug 2012 09:51:37 -0600, Ian Kelly wrote about PEP 393:
>> There is some additional benefit for Latin-1 users, but this has nothing
>> to do with Python. If Python is going to have the option of a 1-byte
&g
On Sun, Aug 19, 2012 at 12:20 PM, Paul Rubin wrote:
> Ian Kelly writes:
>>>>> sys.getsizeof(bytes(range(256)).decode('latin1'))
>> 329
>
> Please try:
>
>print (type(bytes(range(256)).decode('latin1')))
>
> to make sure that wha
On Sun, Aug 19, 2012 at 11:50 AM, Ian Kelly wrote:
> Note that this only describes the structure of "compact" string
> objects, which I have to admit I do not fully understand from the PEP.
> The wording suggests that it only uses the PyASCIIObject structure,
> not the d
On Mon, Aug 20, 2012 at 10:09 AM, Chris Angelico wrote:
> On Tue, Aug 21, 2012 at 2:01 AM, Paul Rubin wrote:
>> Analogy: how big a box is required to hold a pair of shoes? In a purely
>> theoretical sense we might say O(S) where S is the shoe size, treating
>> shoe size as an arbitrary independe
On Mon, Aug 20, 2012 at 11:29 AM, Dennis Lee Bieber
wrote:
> I think I typically have done this by going through a hex
> representation.
>
> H2B_Lookup = { "0" : "", "1" : "0001",
> "2" : "0010", "3" : "0011",
>
omplement representations are not specific to
binary. For example, with decimal numbers we could use "ten's
complement": individually subtract each digit from 9, and add 1 to the
result. A leading digit between 5 and 9 would be considered negative.
So, for example:
-(042) --> 958
-(958) --> 042
958 + 042 == 000
Cheers,
Ian
--
http://mail.python.org/mailman/listinfo/python-list
On Mon, Aug 20, 2012 at 12:01 PM, Massimo Di Pierro
wrote:
> I discovered I can do this:
>
> class A(object): pass
> class B(object):
> __class__ = A # magic
>
> b = B()
> isinstance(b,A) # returns True (as if B derived from A)
> isinstance(b,B) # also returns True
On Tue, Aug 21, 2012 at 10:44 AM, Miki Tebeka wrote:
> Greetings,
>
class A:
> ... '''a doc string'''
> ...
A.__doc__
> 'a doc string'
class B:
> ... '''a {} string'''.format('doc')
> ...
B.__doc__
>
> Is there's a reason for this?
>
> I know I can do:
class B
On Tue, Aug 21, 2012 at 11:09 AM, Ian Kelly wrote:
> On Tue, Aug 21, 2012 at 10:44 AM, Miki Tebeka wrote:
>> Greetings,
>>
>>>>> class A:
>> ... '''a doc string'''
>> ...
>>>>> A.__doc__
>>
substrings longer than one character, this
won't work. A solution then is to define a custom function:
def all_in(string, substrings):
for substring in substrings:
if substring not in string:
return False
return True
Ian
--
http://mail.python.org/mailman/listinfo/python-list
Oops, hopefully this with indent correctly:
def all_in(string, substrings):
for substring in substrings:
if substring not in string:
return False
return True
--
http://mail.python.org/mailman/listinfo/python-list
In addition to the excellent feedback that Dave gave you:
On Wed, Aug 22, 2012 at 9:25 AM, shaun wrote:
> def breakuparray(self):
> for row in self.array:
> mer = row[0].ljust(25, ' ')
> merc = row[1].ljust(13, ' ')
>
On Wed, Aug 22, 2012 at 11:29 AM, Dennis Jacobfeuerborn
wrote:
> Hi,
> I'm trying to implement a system for periodically checking URLs and I've run
> into problems with some of the implementation details. The URLs are supposed
> to be checked continuously until the config for an URL is explicitl
On Wed, Aug 22, 2012 at 11:46 AM, lipska the kat
wrote:
> If, in a language, I find I am able to say
>
> a = 1
>
> then later, in the same scope I can say
>
> a = "foo"
>
> then later again in the same scope I can say
>
> a = ([1,2,3], "xyz", True)
>
> then, and I may be missing something here, to
On Wed, Aug 22, 2012 at 1:40 PM, Dennis Jacobfeuerborn
wrote:
> I was thinking about something like that but the issue is that this really
> only works when you don't do any actual blocking work. I may be able to get
> around the sleep() but then I have to fetch the URL or do some other work
>
> class B: pass
...
>>> a = A()
>>> type(a)
>>> isinstance(a, B)
False
>>> a.__class__ = B
>>> type(a)
>>> isinstance(a, A)
False
>>> isinstance(a, B)
True
Cheers,
Ian
--
http://mail.python.org/mailman/listinfo/python-list
On Thu, Aug 23, 2012 at 9:11 AM, MRAB wrote:
> Perhaps the solution should've been to just switch between 2/4 bytes instead
> of 1/2/4 bytes. :-)
Why? You don't lose any complexity by doing that. I can see
arguments for 1/2/4 or for just 4, but I can't see any advantage of
2/4 over either of th
On Thu, Aug 23, 2012 at 12:02 PM, Jan Kuiken wrote:
> On 8/23/12 06:11 , Steven D'Aprano wrote:
>
>>> 2) Related to the above, you can infinitely nest scopes. There's nothing
>>> wrong with having six variables called 'q'; you always use the innermost
>>> one. Yes, this can hurt readability
>>
>>
On Thu, Aug 23, 2012 at 12:33 PM, wrote:
>> >>> sys.getsizeof('a' * 80 * 50)
>>
>> > 4025
>>
>> sys.getsizeof('a' * 80 * 50 + '•')
>>
>> > 8040
>>
>>
>>
>> This example is still benefiting from shrinking the number of bytes
>>
>> in half over using 32 bits per character as was the case w
On Sat, Aug 25, 2012 at 9:47 AM, wrote:
> For those you do not know, the go language has introduced
> the rune type. As far as I know, nobody is complaining, I
> have not even seen a discussion related to this subject.
Python has that also. We call it "int".
More seriously, strings in Go are n
On Sun, Aug 26, 2012 at 5:49 AM, Steven D'Aprano
wrote:
>> Sorry, you do not get it.
>>
>> The rune is an alias for int32. A sequence of runes is a sequence of
>> int32's.
>
> It certainly is not. Runes are variable-width. Here, for example, are a
> number of Go functions which return a single run
On Sun, Aug 26, 2012 at 12:59 AM, wrote:
> Sorry, you do not get it.
>
> The rune is an alias for int32. A sequence of runes is a
> sequence of int32's. Go do not spend its time in using a
> machinery to work with, to differentiate, to keep in memory
> this sequence according to the *characers* c
301 - 400 of 3945 matches
Mail list logo