On Fri, Mar 27, 2015 at 2:24 PM, Jamie Willis
wrote:
> I would like to propose a new piece of syntax for the python language; .=
>
> In short, the operator is form of syntactic sugar, for instance consider the
> following code:
>
> hello = "hello world "
> hello = hello.strip()
>
> Th
On Fri, Mar 27, 2015 at 6:33 PM, Mario Figueiredo wrote:
> On Sat, 28 Mar 2015 10:39:04 +1100, Ben Finney
> wrote:
>
>>Jamie Willis writes:
>>
>>> This could be written as:
>>>
>>> hello = "hello world "
>>> hello .= strip()
>>
>>?1, “.=” is visually too similar to “=”.
>
> can't be
On Fri, Mar 27, 2015 at 6:31 PM, Jinghui Niu wrote:
> On Wednesday, March 25, 2015 at 2:17:03 PM UTC-7, Jinghui Niu wrote:
>> I am learning python programming. One thing that gives me a lot of confusion
>> is the division of labours between the time module and the datetime module.
>>
>> As it tur
On Fri, Mar 27, 2015 at 7:40 PM, Steven D'Aprano
wrote:
> Excluding that, the consensus seems to be that Perl's regexes are stronger
> than Chomsky regular expressions, but nobody quite knows how much stronger.
> It's likely that they are at least as powerful as context-free grammars,
> but not as
On Sat, Mar 28, 2015 at 1:50 AM, Marko Rauhamaa wrote:
> Larry Hudson :
>
>> Highlight the selection you want copied, move the mouse cursor to the
>> location you want it copied to and middle-click with the mouse. Works
>> between programs as well as within a single program. And it copies
>> direc
On Sat, Mar 28, 2015 at 9:05 AM, Mario Figueiredo wrote:
> Neiter the language. The dot symbol is a delimiter in the python
> grammar. Not an operator. And also defined as a delimiter in the
> official documentation, right after operators.
What does it matter? How '.' is lexed when it appears on
On Sat, Mar 28, 2015 at 12:20 PM, Thomas 'PointedEars' Lahn
wrote:
> Ian Kelly wrote:
>
>> […] Thomas 'PointedEars' Lahn […] wrote:
>>> Ian Kelly wrote:
>>>> What I mean is that if you construct a parse tree of "foo" "b
On Sun, Mar 29, 2015 at 2:11 AM, Thorsten Kampe
wrote:
> Hi,
>
> I'd like to run two processes concurrently (either through a builtin
> module or a third-party). One is a "background" task and the other is
> displaying a spinner (for which I already found good packages).
>
> The two processes do n
On Sun, Mar 29, 2015 at 12:03 PM, Marko Rauhamaa wrote:
> BartC :
>
>> As Chris mentioned, when I say 'faster than C', I mean X running my
>> algorithm was faster then C running Marko's algoritim (on Ian's data).
>> This was just an illustration of algorithm being more important than
>> language.
On Mon, Mar 30, 2015 at 1:13 AM, Christian Gollwitzer wrote:
> Am 30.03.15 um 08:50 schrieb Ian Kelly:
>>
>> On Sun, Mar 29, 2015 at 12:03 PM, Marko Rauhamaa wrote:
>>>
>>> Be careful with the benchmark comparisons. Ian's example can be solved
>>>
On Mon, Mar 30, 2015 at 2:16 AM, Dave Angel wrote:
> The relationship between row, column and box can be rearranged. Some of
> these are already covered by the rotations proposed earlier, where for a 90
> degree rotate, row becomes column and column becomes row. But in a similar
> way each box c
On Mon, Mar 30, 2015 at 2:43 AM, bobbdeep wrote:
> Also, when once client is connected to the server, the other cannot connect
> to the server. Any ideas on how to do this ?
While one client is connected, the server can't accept new connections
because it's tied up in a blocking call to recv, wa
On Mon, Mar 30, 2015 at 3:22 PM, wrote:
> rotimg = img.rotate(270) # rotation is counterclockwise
>
> # i can almost make it work by resizing rotimg here, but the aspect ratio is
> then screwed
> #rotimg = rotimg.resize((1024, 1280))
>
> rotimg.show()
> imagedata = list(rotimg.getdata())
>
> But
On Sun, Mar 29, 2015 at 4:41 AM, Thomas 'PointedEars' Lahn
wrote:
> Ian Kelly wrote:
>
>> […] Thomas 'PointedEars' Lahn […] wrote:
>>> Ian Kelly wrote:
>> Why should the burden of proof be on me in the first place?
>
> Because *you* made the
On Tue, Mar 31, 2015 at 12:58 PM, Christian Gollwitzer wrote:
> Am 31.03.15 um 16:50 schrieb Ervin Hegedüs:
>>
>> there is an app, written in Python, which stores few bytes of
>> datas in a single file. The application uses threads. Every
>> thread can modify the file, but only one at a time. I'm
On Tue, Mar 31, 2015 at 1:59 PM, Christian Gollwitzer wrote:
> Am 31.03.15 um 21:17 schrieb Ian Kelly:
>> flock locks are per-process; they won't help for synchronizing access
>> between competing threads in the same process.
>>
>
> Ok. But if it is really all
On Mar 31, 2015 5:16 PM, wrote:
> Holy hell, dude, you've been arguing about this for nearly two weeks now.
>
> Let it go.
That's rather an exaggeration. I've made seven posts to this thread up
until now, the first of which was six days ago, not two weeks. I don't
think that's excessive.
I sugge
On Wed, Apr 1, 2015 at 9:46 AM, wrote:
> When I am trying to import requests library in python shell, I get this
> error: ImportError: No module named 'requests.packages.urllib3'
> I have tried searching online and followed a few probable solutions but yet
> no luck.
> Does anyone know how I ca
On Thu, Apr 2, 2015 at 3:31 PM, Thomas 'PointedEars' Lahn
wrote:
> Ian Kelly wrote:
>
>> […] Thomas 'PointedEars' Lahn […] wrote:
>>> Ian Kelly wrote:
>>>> Within a grammar, the question of "is an X a Y" is nonsensical in
>
On Thu, Apr 2, 2015 at 11:40 PM, Steven D'Aprano
wrote:
> This sterile, pointless arguing about the minutia of pedantic definitions is
> not even close to useful. Honestly Thomas, Ian, nobody cares any more. If I
> were a betting man, I'd bet that neither of you can describe, in one
> sentence, wh
On Fri, Apr 3, 2015 at 1:13 AM, Marko Rauhamaa wrote:
> 2. The counterexample "abc" "def" *does* demonstrate that expressions
> can at times follow each other immediately. It is a nice point even
> if not all that consequential.
>
> Somewhat analogously:
> * ord is an expression
On Sat, Apr 4, 2015 at 9:21 AM, Dennis Lee Bieber wrote:
> On Sat, 4 Apr 2015 06:07:12 -0700 (PDT), zljubisic...@gmail.com declaimed
> the following:
> >From requests module, I would like to log from error level above.
>>
>
> Unless the requests module documents that is uses a logger named
On Mon, Apr 6, 2015 at 5:52 AM, Steven D'Aprano
wrote:
> To the rest of the list... didn't somebody write up a wiki post on how to
> convince Gmail to be less unreasonable about top posting, quoting, etc?
> Does anyone still have the link?
There is https://wiki.python.org/moin/GoogleGroupsPython
On Apr 6, 2015 9:31 PM, "Sepi Gh" wrote:
>
> On Monday, 6 April 2015 23:27:54 UTC-4, Sepi Gh wrote:
> > On Monday, 6 April 2015 22:54:26 UTC-4, Sepi wrote:
> > > Hi,
> > >
> > > I installed wxpython through command line but when I want to use it,
python gives me an error: File "/Users//Desktop/
On Tue, Apr 7, 2015 at 3:44 AM, wrote:
>
>
> I want todo faster baseconversion for very big bases like base 1 000 000, so
> instead of adding up digits i search it.
>
> I need the fastest algorithm to find the relation to a decimal number.
> Digmult is an instance of base at a digitplace (base^x
On Tue, Apr 7, 2015 at 8:36 AM, wrote:
> Den tisdag 7 april 2015 kl. 16:30:15 UTC+2 skrev Denis McMahon:
>> On Tue, 07 Apr 2015 09:29:59 -0400, Dave Angel wrote:
>>
>> > On 04/07/2015 05:44 AM, jonas.thornv...@gmail.com wrote:
>>
>> >> I want todo faster baseconversion for very big bases like bas
On Apr 7, 2015 9:43 AM, "Hugo Caldas" wrote:
>
> Hi.
>
> I want to connect to a serial port, read and write the port values with
multi threading and save them in random variables in python 3.4.
> Where can I found information to do that?
You can use the pyserial third-party module to do the seria
On Tue, Apr 7, 2015 at 11:07 AM, wrote:
> Den tisdag 7 april 2015 kl. 18:34:32 UTC+2 skrev Dave Angel:
>> Once again, there's no point in doing a search, when a simple integer
>> divide can give you the exact answer. And there's probably no point in
>> going left to right when right to left woul
On Tue, Apr 7, 2015 at 12:55 PM, Terry Reedy wrote:
> On 4/7/2015 1:44 PM, Ian Kelly wrote:
>
>>>>> def to_base(number, base):
>>
>> ... digits = []
>> ... while number > 0:
>> ... digits.append(number % base)
>> ...
On Tue, Apr 7, 2015 at 1:19 PM, Ian Kelly wrote:
> On Tue, Apr 7, 2015 at 12:55 PM, Terry Reedy wrote:
>> On 4/7/2015 1:44 PM, Ian Kelly wrote:
>>
>>>>>> def to_base(number, base):
>>>
>>> ... digits = []
>>> ... w
On Tue, Apr 7, 2015 at 9:40 AM, wrote:
> Well of course you use same principles like a binary search setting min and
> max, closing in on the digit. In this case the searched numbers > base^exp
> and number< base^exp+1.
>
> But since the search is within large bases upto 32-bit space, so base
On Tue, Apr 7, 2015 at 4:06 PM, Cameron Simpson wrote:
> On 07Apr2015 20:38, Chris Angelico wrote:
>>
>> On Tue, Apr 7, 2015 at 3:48 PM, Cameron Simpson wrote:
>>>
>>> The operating system arranges the commection of the shell to the
>>> terminal.
>>> Your usual program has by default a stdin, st
On Tue, Apr 7, 2015 at 4:43 PM, wrote:
> def RenderByte(draw, byte, x, y):
Python function and method names customarily use the
lowercase_with_underscores style.
> blist = list(bin(byte).lstrip('0b')) # turn byte into list with 8
> elements,
There's no guarantee that the resulting list wi
On Tue, Apr 7, 2015 at 4:55 PM, Steven D'Aprano
wrote:
> On Wed, 8 Apr 2015 12:32 am, Ian Kelly wrote:
>
>> On average, a random Oracle with a search space of 100 will need
>> 100 guesses.
>
> Surely on average it will only take 50 guesses?
>
>
On Tue, Apr 7, 2015 at 4:35 PM, wrote:
> I am not sure you guys realised, that althoug the size of the factors to
> muliply expands according to base^(exp+1) for each digitplace the number of
> comparissons needed to reach the digit place (multiple of base^exp+1) is
> constant with my approach
On Wed, Apr 8, 2015 at 1:28 AM, wrote:
> Den onsdag 8 april 2015 kl. 09:16:24 UTC+2 skrev Ian:
>> On Tue, Apr 7, 2015 at 4:35 PM, wrote:
>> > I am not sure you guys realised, that althoug the size of the factors to
>> > muliply expands according to base^(exp+1) for each digitplace the number
On Tue, Apr 7, 2015 at 7:18 PM, Steven D'Aprano
wrote:
> On Wed, 8 Apr 2015 10:38 am, Steven D'Aprano wrote:
>
>> On Wed, 8 Apr 2015 03:44 am, Ian Kelly wrote:
>>
>>>>>>
>>
> to_base(293290359436843838432832583298329483248325
On Wed, Apr 8, 2015 at 9:07 AM, Shiyao Ma wrote:
> Hi.
>
> While reading the rich_compare of PyLongObject, I noticed this line:
>
> https://hg.python.org/cpython/file/a49737bd6086/Objects/longobject.c#l2785
>
> It increments the ob_ref of the builtin True/False object.
>
> Initializing the ob_ref
On Thu, Apr 9, 2015 at 8:54 AM, wrote:
> Aside from the base changer i've written a bignumb anybase generic
> multiplication, addition and subtraction routine. My goal is to make the
> arithmetic in the base of choice whatever size.
>
> And i think i can do it, i already have mult, add , subt w
On Thu, Apr 9, 2015 at 9:21 AM, wrote:
> And i know for a fact
What do you know for a fact?
> (i've factored RSA in the 200 digit range on a 486 in a couple of hours 98-)
Bullshit. RSA-200 wasn't factored until 2005, and the group that did
it required three months on a cluster of 80 2.2-GHz Op
On Apr 11, 2015 5:06 AM, "Steven D'Aprano" <
steve+comp.lang.pyt...@pearwood.info> wrote:
>
> Yes, I agree that Python's behaviour here is better than the alternative.
> Having "except ()" catch nothing is consistent with the behaviour with
> other tuples, so I'm okay with that. But it still surpri
On Tue, Apr 14, 2015 at 8:37 PM, Paul Rubin wrote:
> Steven D'Aprano writes:
>> def turner():
>> nums = itertools.count(2)
>> while True:
>> prime = next(nums)
>> yield prime
>> nums = filter(lambda v, p=prime: (v % p) != 0, nums)
>
> This is nice, though it will s
On Wed, Apr 15, 2015 at 1:48 PM, IronManMark20 wrote:
> I am using ctypes to call a few windll funcions. One of them returns a c_long
> object. I want to know what number the function returns.
>
> Problem is, when I try foo.value , it gives me this:
>
> AttributeError: LP_c_long object has no att
On Fri, Apr 17, 2015 at 5:29 PM, Terry Reedy wrote:
> On 4/17/2015 4:31 PM, Marko Rauhamaa wrote:
>> * You might think it's for children only.
>
>
> I would not.
It was my first impression that it was targeted for children. There
are a lot of STEM programs these days oriented toward girl childr
On Fri, Apr 17, 2015 at 7:19 PM, Paddy wrote:
> Having just seen Raymond's talk on Beyond PEP-8 here:
> https://www.youtube.com/watch?v=wf-BqAjZb8M, it reminded me of my own recent
> post where I am soliciting opinions from non-newbies on the relative
> Pythonicity of different versions of a ro
On Tue, Apr 21, 2015 at 11:03 AM, wrote:
> We are building an app that can help people to chat with the ones connected
> over LAN. No internet connection is required.For GUI we are using wxpython.
> Problem is in the Launching of a frame. In the beginning when a particular
> client say c1 rece
On Tue, Apr 21, 2015 at 1:02 PM, Rob Clewley wrote:
> I don't think the built-in logger is sophisticated enough for this,
> being a flat record of freeform text AFAIU, but the API looks
> appealing.
It doesn't have to be a flat record. You can write a custom a Handler
that does anything you want
On Tue, Apr 21, 2015 at 12:59 AM, Chris Angelico wrote:
> plus, docstringargs
> basically implies that all the function parameters are strings, so the
> annotations are going to be rather less useful.
Why is that? argparse supports non-string args, so why couldn't
docstringargs as well?
--
https
On Wed, Apr 22, 2015 at 7:07 AM, Michael Torrie wrote:
> I have a hunch you're mistakenly thinking that Python is only running
> through ten iterations of your for i in range(100) loop. This is
> not the case. The entire thing is running (all 100 iterations of
> your loop), but is run te
On Wed, Apr 22, 2015 at 7:07 AM, Mark Lawrence wrote:
> Please don't feed the RUE, you're wasting everybody's time.
If there's a problem with the installer, that's worth knowing about,
isn't it? At least one of jmf's past complaints has led to an actual
bug fix.
--
https://mail.python.org/mailma
On Thu, Apr 23, 2015 at 9:51 AM, brokolists wrote:
> my problem is i m working with very long float numbers and i use
> numberx =float(( input( 'enter the number\n ')))
> after i use this command when i enter something more than 10 or 11 digits it
> uses like 1e+10 or something like that
> but i
On Apr 24, 2015 7:45 AM, "Vincent Davis" wrote:
>
> How does one get the date given the day of a year.
>
> >>> dt.datetime.now().timetuple().tm_yday
>
> 114
>
> How would I get the Date of the 114 day of 2014?
You could use a timedelta:
>>> dt.date(2014, 1, 1) + dt.timedelta(114 - 1)
datetime.da
On Fri, Apr 24, 2015 at 8:50 AM, wrote:
> Dear Group,
>
> I am trying to understand the use of Boolean operator in Python. I am trying
> to
> write small piece of script, as follows,
>
> def input_test():
> str1=raw_input("PRINT QUERY:")
> if "AND" or "OR" or "NOT" in str1:
This
On Wed, Apr 29, 2015 at 12:06 AM, Cecil Westerhof wrote:
> Op Monday 27 Apr 2015 22:35 CEST schreef Albert-Jan Roskam:
>> def some_func(arg, _memoize={}):
>> try:
>> return _memoize[arg]
>> except KeyError:
>> result = some_expensive_operation(arg)
>> _memoize[arg] = result
>> return result
>
> Th
On Wed, Apr 29, 2015 at 1:03 PM, Peter Otten <__pete...@web.de> wrote:
> I was judging from the look of your MovingAverage.
>
> I don't like the interface, it really should take an iterable so that you
> can write
>
list(moving_average([1,2,3], 2))
> [1.5, 2.5]
The problem with this is that m
On Wed, Apr 29, 2015 at 12:24 PM, Cecil Westerhof wrote:
> I was wondering if there is a way to do this:
> for del_index in range((sieve_len // skip_count) * skip_count - 1,
> skip_count - 2, -skip_count):
> del sieve[del_index]
> in a
On Wed, Apr 29, 2015 at 3:45 PM, Cecil Westerhof wrote:
> Op Wednesday 29 Apr 2015 21:57 CEST schreef Ian Kelly:
>> And although it's not clear to me what this is supposed to be doing,
>> you probably no longer need the middle term if the intention is to
>> continue d
On Wed, Apr 29, 2015 at 6:01 PM, Cecil Westerhof wrote:
> Op Thursday 30 Apr 2015 00:38 CEST schreef Ian Kelly:
>> In that case you can definitely omit the middle term of the slice,
>> which will be both more concise and clearer in intent, though
>> probably not significan
On Wed, Apr 29, 2015 at 6:11 PM, Steven D'Aprano
wrote:
> On Thu, 30 Apr 2015 05:57 am, Ian Kelly wrote:
>
>> On Wed, Apr 29, 2015 at 12:24 PM, Cecil Westerhof
>> wrote:
>>> I was wondering if there is a way to do this:
>>> for de
On Thu, Apr 30, 2015 at 10:07 AM, Tim wrote:
> I noticed this today, using Python2.7 or 3.4, and wondered if it is
> implementation dependent:
>
> You can use 'extend' to add set elements to a list and use 'update' to add
> list elements to a set.
It's not implementation dependent. Both methods
On Thu, Apr 30, 2015 at 9:59 AM, Cecil Westerhof wrote:
> I implemented happy_number function:
> _happy_set = { '1' }
> _unhappy_set= set()
>
> def happy_number(n):
> """
> Check if a number is a happy number
> https://en.wikipedia.org/wiki/Happy_number
On Fri, May 1, 2015 at 2:27 AM, Steven D'Aprano
wrote:
> Rather than 10**7, how about trying (10**500 + 2). Is it happy?
>
> Using the Python code from Wikipedia:
> https://en.wikipedia.org/wiki/Happy_number
>
> SQUARE = dict([(c, int(c)**2) for c in "0123456789"])
> def is_happy(n):
> while (n
On Sat, May 2, 2015 at 4:35 AM, Dave Angel wrote:
> I can't see how that is worth doing. The recursive version is already a
> distortion of the definition of factorial that I learned. And to force it
> to be recursive and also contort it so it does the operations in the same
> order as the iterat
On Sat, May 2, 2015 at 5:42 AM, Marko Rauhamaa wrote:
> Christian Gollwitzer :
>
>> That's why I still think it is a microoptimization, which helps only
>> in some specific cases.
>
> It isn't done for performance. It's done to avoid a stack overflow
> exception.
If your tree is balanced, then th
On Sat, May 2, 2015 at 9:55 AM, Chris Angelico wrote:
> On Sun, May 3, 2015 at 1:45 AM, Ian Kelly wrote:
>> On Sat, May 2, 2015 at 5:42 AM, Marko Rauhamaa wrote:
>>> Christian Gollwitzer :
>>>
>>>> That's why I still think it is a microoptimization,
On Sat, May 2, 2015 at 9:53 AM, Joonas Liik wrote:
Top-posting is heavily frowned at on this list, so please don't do it.
> Balancing of trees is kind of irrelevant when "tree" means "search space"
> no?
I think it's relatively rare that DFS is truly the best algorithm for
such a search. For on
On Sat, May 2, 2015 at 1:51 PM, BartC wrote:
> On 02/05/2015 20:15, Mark Lawrence wrote:
>>
>> On 02/05/2015 19:34, BartC wrote:
>
>
>>> OK, so it's the programmer's fault if as fundamental a concept as a
>>> for-loop ranging over integers is implemented inefficiently. He has to
>>> transform it i
On Sat, May 2, 2015 at 3:28 PM, Tony the Tiger wrote:
> On Fri, 01 May 2015 14:42:04 +1000, Steven D'Aprano wrote:
>
>> use "l" as a variable name, as it looks too much like 1
>
> If you use a better font, they are very different. Besides, a variable
> name cannot start with a digit (nor can it be
On Sat, May 2, 2015 at 7:57 PM, Tim Chase wrote:
> So it sounds like you have to request such a mark-and-sweep from
> the gc module.
You *can* request it. But as long as it hasn't been explicitly
disabled (by calling gc.disable()), the mark-and-sweep garbage
collection will also run automatically
On Sat, May 2, 2015 at 2:17 PM, Tim Chase wrote:
> If you know that you're creating such cyclical structures, it's best
> to manually unlink them before freeing them:
>
> lst = []
> lst.append(lst) # create the cycle
> lst[:] = [] # break the cycle
> # or lst.remove(lst) # though this ta
On Sat, May 2, 2015 at 5:51 PM, Terry Reedy wrote:
> On 5/2/2015 5:31 PM, Ian Kelly wrote:
>
>> Would it have been better if range() had been implemented as xrange()
>> from the beginning? Sure, that would have been great. Except for one
>> small detail: the iterator pr
On Mon, May 4, 2015 at 9:17 AM, Peter Otten <__pete...@web.de> wrote:
> OK, you convinced me. Then I tried:
>
with open("tmp.txt", "wb") as f: f.write("0\r\n3\r5\n7")
> ...
assert len(open("tmp.txt", "rb").read()) == 8
f = open("tmp.txt", "rU")
f.readline()
> '0\n'
f.newlin
On Mon, May 4, 2015 at 9:20 AM, Cecil Westerhof wrote:
> Potential dangerous bug introduced by programming in Python as if it
> was C/Java. :-(
> I used:
> ++tries
> that has to be:
> tries += 1
>
> Are there other things I have to be careful on? That does not work as
> in C/Java, but is c
On Mon, May 4, 2015 at 11:59 AM, Mark Lawrence wrote:
> On 04/05/2015 16:20, Cecil Westerhof wrote:
>>
>> Potential dangerous bug introduced by programming in Python as if it
>> was C/Java. :-(
>> I used:
>> ++tries
>> that has to be:
>> tries += 1
>>
>> Are there other things I have to
On Mon, May 4, 2015 at 12:59 PM, Cecil Westerhof wrote:
> I want to change an old Bash script to Python. When I look at:
> https://docs.python.org/2/library/email-examples.html
>
> Then from and to have to be used two times? Why is that?
Once to construct the message headers, and once to inst
On May 5, 2015 5:46 AM, "Cecil Westerhof" wrote:
>
> Op Tuesday 5 May 2015 12:41 CEST schreef Steven D'Aprano:
>
> > # Untested.
> > def get_message_slice(message_filename, start=0, end=None, step=1):
> > real_file = expanduser(message_filename)
> > messages = []
> > # FIXME: I assume this is expe
On Tue, May 5, 2015 at 9:22 AM, Paul Moore wrote:
> I'm working my way through the asyncio documentation. I have got to the
> "Tasks and coroutines" section, but I'm frankly confused as to the difference
> between the various things described in that section: coroutines, tasks, and
> futures.
On Tue, May 5, 2015 at 12:45 PM, Dave Angel wrote:
> When the "simple" is True, the function takes noticeably and consistently
> longer. For example, it might take 116 instead of 109 seconds. For the
> same counts, your code took 111.
I can't replicate this. What version of Python is it, and wh
On Tue, May 5, 2015 at 3:00 PM, Dave Angel wrote:
> def loop(func, funcname, arg):
> start = time.time()
> for i in range(repeats):
> func(arg, True)
> print("{0}({1}) took {2:7.4}".format(funcname, arg, time.time()-start))
>
> start = time.time()
> for i in range(repea
On Tue, May 5, 2015 at 3:23 PM, Ian Kelly wrote:
> On Tue, May 5, 2015 at 3:00 PM, Dave Angel wrote:
>> def loop(func, funcname, arg):
>> start = time.time()
>> for i in range(repeats):
>> func(arg, True)
>> print("{0}({1}) took {2
On Tue, May 5, 2015 at 7:27 PM, Steven D'Aprano
wrote:
> Only the minimum is statistically useful.
I disagree. The minimum tells you how fast the code *can* run, under
optimal circumstances. The mean tells you how fast it *realistically*
runs, under typical load. Both can be useful to measure.
--
On Wed, May 6, 2015 at 9:12 AM, Paul Rubin wrote:
> Steven D'Aprano writes:
>> Multiplying upwards seems to be more expensive than multiplying
>> downwards... I can only guess that it has something to do with the way
>> multiplication is implemented, or perhaps the memory management
>> involved,
On Wed, May 6, 2015 at 1:08 AM, Steven D'Aprano
wrote:
> On Wednesday 06 May 2015 15:58, Ian Kelly wrote:
>
>> On Tue, May 5, 2015 at 7:27 PM, Steven D'Aprano
>> wrote:
>>> Only the minimum is statistically useful.
>>
>> I disagree. The min
On Wed, May 6, 2015 at 12:22 PM, Tim Chase
wrote:
> On 2015-05-06 19:08, MRAB wrote:
>> You could tell it to quote any value that's not a number:
>>
>> w = csv.DictWriter(f, pol_keys,
>> quoting=csv.QUOTE_NONNUMERIC)
>>
>> It looks like all of the values you have are strings, so they'll
>> a
On Thu, May 7, 2015 at 8:03 AM, Chris Angelico wrote:
> On Thu, May 7, 2015 at 11:44 PM, Marko Rauhamaa wrote:
>> Whole programming cultures, idioms and "right ways" differ between
>> platforms. What's the right way to write a service (daemon)? That's
>> probably completely different between Wind
On May 8, 2015 9:26 AM, "Steven D'Aprano" <
steve+comp.lang.pyt...@pearwood.info> wrote:
>
> Do you think that Python will re-compile the body of the function every
time
> you call it? Setting the default is part of the process of compiling the
> function.
To be a bit pedantic, that's not accurate
On May 8, 2015 9:46 AM, "Tommy C" wrote:
>
> I'm trying to apply OOP in this bouncing ball code in order to have
multiple balls bouncing around the screen. The objective of this code is to
create a method called settings, which controls all the settings for the
screen and the bouncing behaviour of
On Fri, May 8, 2015 at 9:50 AM, Michael Welle wrote:
>
> Steven D'Aprano writes:
>>
>> If your language uses late binding, it is very inconvenient to get early
>> binding when you want it. But if your language uses early binding, it is
>> very simple to get late binding when you want it: just put
On Sat, May 9, 2015 at 12:30 PM, Antranig Vartanian
wrote:
> Hay,
>
> I learned the basics of python using the book "Think Python"
> (http://www.greenteapress.com/thinkpython/) which was good (IMHO), and it
> teaches in Python 2.7. Now I'm trying to write my first python+gtk program.
>
> anyways,
On Sun, May 10, 2015 at 10:14 AM, Peter Otten <__pete...@web.de> wrote:
> When there was an actual speed-up I also had a look at
> PyEval_GetGlobals/Locals() which in turn call
>
> PyEval_GetFrame()
>
> and
>
> PyEvalPyFrame_FastToLocalsWithError()
>
> whatever these do. (The first function reminde
On Sun, May 10, 2015 at 10:34 AM, Mark Rosenblitt-Janssen
wrote:
> Here's something that might be wrong in Python (tried on v2.7):
>
class int(str): pass
This defines a new class named "int" that is a subclass of str. It has
no relation to the builtin class int.
int(3)
> '3'
This crea
On Sun, May 10, 2015 at 3:16 PM, Marko Rauhamaa wrote:
> Scheme is my favorite language. I think, however, it is a pretty
> advanced language and requires a pretty solid basis in programming and
> computer science.
>
> Python, in contrast, is a great introductory programming language. Sure,
> you
On Sun, May 10, 2015 at 7:39 PM, zipher wrote:
> Similarly, you'd want:
>
encode(codestr)
>
> to instantiate all objects in the codestr. You can't do this with eval,
> because it doesn't allow assignment (eval(n=2) returns "InvalidSyntax").
Is exec what you're looking for?
>>> exec('n = 2
On Sun, May 10, 2015 at 9:31 PM, Ian Kelly wrote:
> On Sun, May 10, 2015 at 7:39 PM, zipher wrote:
>> Similarly, you'd want:
>>
>>>>> encode(codestr)
>>
>> to instantiate all objects in the codestr. You can't do this with eval,
>&
On Tue, May 12, 2015 at 9:34 AM, zipher wrote:
>> * when it comes to built-in functions (e.g. sum, map, pow)
>> and types (e.g. int, str, list) there are significant and
>> important use-cases for allowing shadowing;
>
> Name one "significant and important" use case for shadowing built-in type
On Tue, May 12, 2015 at 1:29 PM, Chris Angelico wrote:
> On Wed, May 13, 2015 at 5:13 AM, wrote:
>> If I find an error in command line parameters section I cannot call function
>> usage() because it is not defined yet.
>>
>> I have few options here:
>> 1. Put definition of usage function b
On Tue, May 12, 2015 at 9:11 PM, zipher wrote:
> I know. That's because most people have fallen off the path
> (http://c2.com/cgi/wiki?OneTruePath).
You wrote that, didn't you? I recognize that combination of delusional
narcissism and curious obsession with Turing machines.
> You haven't done
On Wed, May 13, 2015 at 8:42 AM, andrew cooke wrote:
> On Wednesday, 13 May 2015 11:36:12 UTC-3, Thomas Rachel wrote:
>> Am 13.05.2015 um 15:25 schrieb andrew cooke:
>>
>> class Foo:
>> > ... def __new__(cls, *args, **kargs):
>> > ... print('new', args, kargs)
>> > ... su
On Wed, May 13, 2015 at 8:45 AM, andrew cooke wrote:
class Foo:
> ... def __new__(cls, *args, **kargs):
> ... print('new', args, kargs)
> ... super().__new__(cls)
> ...
class Bar(Foo):
> ... def __init__(self, a):
> ... print('init', a)
> ...
Bar(1)
>
I don't know why I'm replying to this...
On Wed, May 13, 2015 at 8:44 AM, zipher wrote:
> On Tuesday, May 12, 2015 at 10:35:29 PM UTC-5, Rustom Mody wrote:
>> How history U-turns!!
>> Lisp actually got every major/fundamental thing wrong
>> - variables scopes were dynamic by mistake
>> - lambdas
2301 - 2400 of 3471 matches
Mail list logo