On Mon, 06 May 2013 17:17:01 -0700, alex23 wrote:
> One of these days I'll work out why some programmers consider typing to
> be "effort".
An ironic comment from someone who goes by the moniker wu wei! ;-)
The effort, of course, comes in determining what to type, and often how to
type less.
--
On Wed, 08 May 2013 14:27:53 +, Duncan Booth wrote:
> Steven D'Aprano wrote:
>> I'm looking for some help in finding a term, it's not Python-specific
>> but does apply to some Python code.
>>
>> This is an anti-pattern to avoid. The idea is that creating a
>> resource ought to be the same a
On Wed, 08 May 2013 08:52:12 +, Steven D'Aprano wrote:
> This is an anti-pattern to avoid. The idea is that creating a resource
> ought to be the same as "turning it on", or enabling it, or similar. For
> example, we don't do this in Python:
>
> f = file("some_file.txt")
> f.open()
> data =
On Fri, 10 May 2013 05:03:10 +, Steven D'Aprano wrote:
There is no sensible use-case for creating a file OBJECT unless it
initially wraps an open file pointer.
> So far the only counter-examples given aren't counter-examples ...
Well, sure, if you discount operations like "create t
On Tue, 14 May 2013 04:12:53 +1000, Chris Angelico wrote:
> On Tue, May 14, 2013 at 4:02 AM, Skip Montanaro wrote:
>>> 8. A programming language is low level when its programs require
>>> attention to the irrelevant.
>> I think "irrelevant" in this context means stuff like memory
>> management.
On Sun, 26 May 2013 03:38:12 +, Steven D'Aprano wrote:
> ... adding a constant to a random variable still leaves it equally
> random. Adding, multiplying, dividing or subtracting a constant from a
> random variable X just shifts the possible values X can take ...
That's mathematically true, b
On Mon, 03 Jun 2013 03:20:52 +1000, Chris Angelico wrote:
> On Mon, Jun 3, 2013 at 3:04 AM, Rick Johnson
> wrote:
>> * Woefully inadequate because: Switching on or off the debug
>>messages is only valid in the current module that the function was
>>imported. What if you want to kill all
On Sun, 02 Jun 2013 18:12:33 -0700, Fdama wrote:
> I combined the int conversion and the input on the same line, rather
> than to have two different statements. But got an error message:
> Traceback (most recent call last):
> File "C:\Users\Faisal\Documents\python\pizza_slicer.py", line 23, in
On Sun, 02 Jun 2013 20:16:21 -0400, Jason Swails wrote:
> ... If you don't believe me, you've never hit a bug that 'magically'
> disappears when you add a debugging print statement ;-).
Ah, yes. The Heisenbug. ;-)
We used to run into those back in the days of C and assembly language.
They're m
On Sun, 02 Jun 2013 23:23:42 -0400, Jason Swails wrote:
> On Sun, Jun 2, 2013 at 11:10 PM, Dan Sommers
> wrote:
>> Ah, yes. The Heisenbug. ;-)
>
> Indeed. Being in the field of computational chemistry/physics, I was
> almost happy to have found one just to say I wa
On Mon, 03 Jun 2013 13:37:27 +1000, Tim Delaney wrote:
> With the increase in use of higher-level languages, these days
> Heisenbugs most often appear with multithreaded code that doesn't
> properly protect critical sections, but as you say, with lower-level
> languages uninitialised memory is a c
On Sat, 15 Jun 2013 15:29:27 +, Giorgos Tzampanakis wrote:
> Also, is working without connection to the server such big an issue?
> One would expect that losing access to the central server would
> indicate significant problems that would impact development anyway.
Everyone and every device i
)
formats that None into the string "None."
Finally, this:
print "%r" % (get_numbers(1, 2, 'minus'))
prints that string.
> Output:
>
> C:\code\python>ex19.py
> -1
This "-1" comes from get_numbers.
> None
This "None" comes f
On Fri, 29 Jun 2012 21:59:41 -0400
Dave Angel wrote:
> On 06/29/2012 06:59 PM, Dennis Lee Bieber wrote:
> > On Fri, 29 Jun 2012 21:13:09 +0100, Mark Lawrence
> > declaimed the following in
> > gmane.comp.python.general:
> >
> >> On 29/06/2012 16:26, Ethan Furman wrote:
> >>> Ben Finney wrote:
>
On 2012-07-30 at 00:44:04 +,
Steven D'Aprano wrote:
> I wish to extract the bit fields from a Python float, call it x. First I
> cast the float to 8-bytes:
>
> s = struct.pack('=d', x)
> i = struct.unpack('=q', s)[0]
>
> Then I extract the bit fields from the int, e.g. to grab the sign bit
On 2012-08-06 at 00:27:43 +,
Steven D'Aprano wrote:
> I frequently draw diagrams to understand the relationships between my
> classes and the problem I am trying to solve. I almost invariably use one
> type of box and one type of arrowhead. Sometimes if I'm bored I draw
> doodles on the di
On 2012-08-15 at 13:59:53 +,
Grant Edwards wrote:
> On 2012-08-15, Chris Angelico wrote:
> > Perhaps you said "Please use `m4-style quotes rather than matching
> > ASCII quotes' or `something else' to indicate omission instead".
When I've got these antlers on I am dictating and when I take
;charset=utf-8"
HTH,
Dan
--
Μὴ μοῦ τοὺς κύκλους τάραττε -- Αρχιμηδησ
Do not disturb my circles. -- Archimedes
Dan Sommers, http://www.tombstonezero.net/dan
--
http://mail.python.org/mailman/listinfo/python-list
On 2012-08-26 at 20:13:21 +,
Steven D'Aprano wrote:
> I note that not all 32-bit ints are valid code points. I suppose I can
> see sense in having rune be a 32-bit integer value limited to those
> valid code points. (But, dammit, why not call it a code point?) But if
> rune is merely an alias
On 2012-09-04 at 02:17:30 +,
Steven D'Aprano wrote:
> Besides, then somebody will say "Yes, but what about the cases where
> the prefix and the suffix are both equal, but the middle will be
> different?" and propose a third string-equality operator and
> then there will be bloodshed.
L
On Sat, 22 Dec 2012 23:11:00 +1100, Chris Angelico wrote:
> "This is a string" / 3 ==> ["This ", "is a ", "strin", "g"]
> and "This is a string" // 3 ==> ["This ", "is a ", "strin"]
> then "This is a string" % 3 ==> ["g"] or possibly "g"
>
> which is incompatible with current usage. But that's a
On Mon, 14 Jan 2013 00:31:59 -0500, Dave Angel wrote:
> On 01/13/2013 11:16 PM, Steven D'Aprano wrote:
>> A programmer had a problem, and thought Now he has "I know, I'll solve
>> two it with threads!" problems.
>
> ++10
It took me a moment to figure it out, but in the end I smiled and I
agree:
On Mon, 14 Jan 2013 18:56:08 +1100, Chris Angelico wrote:
> Awesome! Now, just one more step to make Python into the World's Most
> Awesome Language(tm): Replace those lengthy words with single symbols
> found in the Unicode set; compress everything down and enforce perfect
> Unicode handling. Als
On Mon, 14 Jan 2013 15:54:27 +0100, zoom wrote:
> Is there any "rules" regarding importing python modules within your own
> module? I mean, how does this affects the performance of the program?
"Even the initializers are optimized!" -- Mel, the real programmer
Unless you've profiled it, and the
On Mon, 14 Jan 2013 12:00:13 -0600, Tim Chase wrote:
> Clearly Python should use a keyword like "Kingdom" or "Phylum" instead.
> I guess "Kingdom" should be reserved for metaclasses (or would they be
> metaphylums? or metaphyla?)
Metaphyla, of course.
>kingdom Baz:
> pass
>
>phy
On Thu, 17 Jan 2013 15:21:08 +, Steven D'Aprano wrote:
> On Thu, 17 Jan 2013 06:35:29 -0800, Mark Carter wrote:
>
>> I thought it would be interesting to try to implement Scheme SRFI 39
>> (Parameter objects) in Python.
>>
>> The idea is that you define a function that returns a default valu
On Fri, 18 Jan 2013 09:10:34 +, Steven D'Aprano wrote:
> On Fri, 18 Jan 2013 03:38:08 +0000, Dan Sommers wrote:
>> This, or something like this, is very old:
>>
>> sentinel = object()
>> class Magic:
>> def __init__(self, value):
>>
On Sat, 28 Jan 2012 15:47:17 +0800, contro opinion wrote:
u'中国'.encode('utf-8')
> '\xe4\xb8\xad\xe5\x9b\xbd'
>
> so,'\xe4\xb8\xad\xe5\x9b\xbd' is the utf-8 of '中国'
Those bytes are the utf-8 encoding of those CJK ideograph (I won't even
pretend to know what those CJK ideographs are or
On Sun, 12 Feb 2012 17:08:24 +1100, Chris Angelico wrote:
> On Sun, Feb 12, 2012 at 4:51 PM, Steven D'Aprano
> wrote:
>> You can't say that it cost you £10 to courier your résumé to the head
>> office of Encyclopædia Britanica to apply for the position of Staff
>> Coördinator.
>
> True, but if i
On Sun, 26 Feb 2012 23:24:31 -0800, John Salerno wrote:
> Hi everyone. I created a custom class and had it inherit from the "dict"
> class, and then I have an __init__ method like this:
> I know I could do self.variable = create() and that works fine, but I
> thought it would be better (and clean
On Mon, 26 Mar 2012 22:26:11 +0200
Gelonida N wrote:
> As these modules are used by quite some projects and as I do not want
> to force everybody to rename immediately I just want to warn users,
> that they call functions, that have been renamed and that will be
> obsoleted.
You want a Deprecat
On Sat, 31 Mar 2012 07:20:39 +1100
Chris Angelico wrote:
> ... That's why we're all still programming in assembly language and
> doing our own memory management, because we would lose a lot of
> personal value if programming stopped being so difficult. If it
> weren't for all these silly new-fang
On 06 Apr 2012 01:03:45 GMT
Steven D'Aprano wrote:
> This is the 21st century, not 1960 ...
Now there's a slippery slope, indeed. ;-)
> ... and if the language designer is worried about the trivially small
> extra effort of parsing ' as well as " then he's almost certainly
> putting his effort
On Wed, 11 Apr 2012 13:20:29 -0700
John Nagle wrote:
> You don't need those books as much as you used to. You
> don't have to write collections, hash tables, and sorts much any
> more. Those are solved problems and there are good libraries.
> Most of the basics are built into Python.
"Nee
On Thu, 12 Apr 2012 09:28:03 -0700 (PDT)
tkp...@gmail.com wrote:
> I using Python 3.2 and have a dictionary
> >>> d = {0:[1,2], 1:[1,2,3], 2:[1,2,3,4]}
>
> whose values are lists I would like to zip into a list of tuples. If
> I explicitly write:
> >>> list(zip([1,2], [1,2,3], [1,2,3,4])
> [(1, 1
On Thu, 19 Apr 2012 09:31:05 +0800
contro opinion wrote:
> >>> import md5
> >>> f=open('c:\gpg4win-2.1.0.exe','r')
> >>> print md5.new(f.read()).hexdigest()
> 'd41d8cd98f00b204e9800998ecf8427e'
>
> it is not = f619313cb42241d6837d20d24a814b81a1fe7f6d
> gpg4win-2.1.0.exe please see :gpg4win-2
On Thu, 19 Apr 2012 09:31:05 +0800
contro opinion wrote:
> i have download file (gpg4win-2.1.0.exe from
> http://www.gpg4win.org/download.html)
> when i run :
>
> Type "help", "copyright", "credits" or "license" for
> >>> import md5
> >>> f=open('c:\gpg4win-2.1.0.exe','r')
> >>> print md5.new(
On Sun, 22 Apr 2012 17:37:42 +0800
contro opinion wrote:
> i want to know how many days in one year,
> import time
> import datetime
> d1= datetime.datetime(2003, 1, 1)
> d2=datetime.datetime(2003, 21, 31)
ITYM datetime.datetime(2003, 12, 31).
> print (d2-d1).days+1
>
> i can get there are 36
On Mon, 07 May 2012 20:15:36 -0700
Charles Hixson wrote:
> class Node:
>
> def__init__(self, nodeId, key, value, downRight, downLeft,
> parent): dirty=True
> dlu=utcnow()
> self.node=[nodeId, downLeft, [key], [value],
> [downRight], parent, dir
perator here
But PEP 8 (under Other Recommendations) indicates spaces around the
former but not the latter:
key = val
dict(key=val)
We all know that there should be one-- and preferably only one --obvious
way to do it. But what do we also know about foolish consistency?
Dan
--
D
On Wed, 10 Aug 2011 18:32:05 +1000, Steven D'Aprano wrote:
> Python is a programming language, not an ice cream shop.
+1 QOTW
How about a cheese shop?
In terms of easier to read, I find code easier to read when the operators
are at the beginnings of the lines (PEP 8 notwithstanding):
x =
On Thu, 01 Sep 2011 16:02:54 +1000, Steven D'Aprano wrote:
> On Thu, 1 Sep 2011 02:56 pm Sahil Tandon wrote:
>> # process input, line-by-line, and print responses after parsing input
>> while 1:
>> rval = parse(raw_input())
>> if rval == None:
>> print('foo')
>> else:
>> print('bar'
On Tue, 19 Sep 2017 01:56:29 +, Stefan Ram wrote:
> Steve D'Aprano writes:
>>It is true that binary floats have some unexpected properties. They
>>aren't the real numbers that we learn in maths. But most people who
>>have been to school have years of experience with calculators training
>>th
On Wed, 27 Sep 2017 12:41:24 -0400, leam hall wrote:
> The question is, what should a person "know" when hiring out as a
> programmer? What is 'know" and what should be "known"? Specifically
> with Python.
The longer I claim to be a programmer, the more I discover how wide a
net that is. Web sit
On Thu, 05 Oct 2017 19:14:33 -0600, Michael Torrie wrote:
> It all depends on what the command's purpose is for, and how it's
> designed to be chained with other commands (cat for example).
They're almost all designed to be chained with other commands. Even
diff and ed are designed to work toget
On Sat, 28 Oct 2017 16:20:54 -0700, Στέφανος Σωφρονίου wrote:
> I do believe though that if (!d) is a lot clearer than if (d == NULL)
> as it is safer than falsely assigning NULL in d, by pure mistake.
Having made my living writing C code for a very long time, I always
found if (!d) *harder* to r
On Fri, 22 Dec 2017 21:35:53 -0600, Peng Yu wrote:
> Hi, I see the following two lines are the same. But I'd like to find
> where ^ is documented via the help() function (I am not looking for
> the document in html)? Does anybody know? Thanks.
>
> s.symmetric_difference(t)
> s ^ t
It's sort of d
On Mon, 29 Jan 2018 00:27:07 +, Steven D'Aprano wrote:
> On Mon, 29 Jan 2018 08:55:54 +1100, Tim Delaney wrote:
>
>> I got back a Word document containing about 10 screenshots where they'd
>> apparently taken a screenshot, moved the horizontal scrollbar one
>> screen, taken another screenshot
On Mon, 14 Nov 2016 16:20:49 +1100, Steven D'Aprano wrote:
> import library
> SPAMIFY = False # only affects this module, no other modules
> result = library.make_spam(99)
I must be missing something, because it seems too obvious:
import library
# only affects this module, no other modu
On Thu, 17 Nov 2016 16:17:51 +1100, Steven D'Aprano wrote:
> ... factory functions are great. But I'm saying that as the writer of
> the library, not the user of the library. Can you imagine expecting
> users to do this?
> from math import trig
> sin = trig.build('sine')
> result = sin(0.1)
No,
On Wed, 04 Jan 2017 16:40:00 +1100, Steven D'Aprano wrote:
> On Wednesday 04 January 2017 15:46, Deborah Swanson wrote:
>
>> Steven D'Aprano wrote, on January 03, 2017 8:04 PM
> [...]
>>> Of course you have to put quotes around them to enter them in
>>> your source code.
>>> We don't expect this
On Wed, 04 Jan 2017 16:40:00 +1100, Steven D'Aprano wrote:
> On Wednesday 04 January 2017 15:46, Deborah Swanson wrote:
>
>> Steven D'Aprano wrote, on January 03, 2017 8:04 PM
> [...]
>>> Of course you have to put quotes around them to enter them in
>>> your source code.
>>> We don't expect this t
On Sat, 07 Jan 2017 00:03:37 +1100, Steve D'Aprano wrote:
> The *hardest* problem is naming things.
>
> Fiction
> ├─ Fantasy
> │ ├─ Terry Pratchett
> │ │ ├─ Discworld
> │ │ │ ├─ Wyrd Sisters
> │ │ │ └─ Carpe Jugulum
[...]
> what do we call the vertical and hori
On Wed, 25 Jan 2017 12:31:11 +1100, Steve D'Aprano wrote:
> But now I type something which cannot possibly be indented there:
>
> def func(a, b):
> if condition:
> spam()
> elif something: |
>
> and hit ENTER again. There's nothing ambiguous about this, and th
On Sat, 04 Feb 2017 12:56:58 -0600, Wildman wrote:
> On Sat, 04 Feb 2017 18:25:03 +, Grant Edwards wrote:
>> It allows a malicous user to put an evil executable someplace public
>> like /tmp and have it executed accidentally. For example, let's say
>> this executable file was named "sl" and
On Sat, 04 Feb 2017 21:19:06 +0200, Marko Rauhamaa wrote:
> Now, that's why the distros are careful to place $HOME/bin as the
> final entry of PATH; the system commands take precedence over the
> user's personal ones. However, the user is free to define the PATH any
> way they like.
I deliberatel
On Wed, 07 Mar 2018 16:57:51 -0500, C W wrote:
> Hello,
>
> I am new to OOP. I'm a bit confused about the following code.
>
> class Clock(object):
> def __init__(self, time):
> self.time = time
> def print_time(self):
> time = '6:30'
> print(self.time)
>
> clock
On Wed, 07 Mar 2018 16:57:51 -0500, C W wrote:
> class Clock(object):
> def __init__(self, time):
> self.time = time
> def print_time(self):
> time = '6:30'
> print(self.time)
>
> clock = Clock('5:30')
> clock.print_time()
> 5:30
>
> I set time to 6:30, but it's c
On Wed, 14 Mar 2018 04:08:30 +, Steven D'Aprano wrote:
> Explain the difference between these two triple-quoted strings:
> But remove the spaces, and two of the quotation marks disappear:
>
> py> """\""
> '"'
That's (a) a triple quoted string containing a single escaped quote,
followed
On Mon, 16 Jul 2018 10:39:49 +, Steven D'Aprano wrote:
> ... people who think that if ISO-8859-7 was good enough for Jesus ...
It may have been good enough for his disciples, but Jesus spoke Aramaic.
Also, ISO-8859-7 doesn't cover ancient polytonic Greek; it only covers
modern monotonic Gree
On Tue, 17 Jul 2018 08:48:55 +1000, Chris Angelico wrote:
> That said, though, the fact that indexing a byte string yields an int
> instead of a one-byte string is basically unable to be changed now ...
Agreed.
> ... and IMO it'd be better to be consistent with text strings than
> with bytearray
On Sat, 21 Jul 2018 17:37:00 +0100, MRAB wrote:
> On 2018-07-21 15:20, aldi.kr...@gmail.com wrote:
>> Hi,
>> I have a long text, which tells me which files from a database were
>> downloaded and which ones failed. The pattern is as follows (at the end of
>> this post). Wrote a tiny program, but
On Fri, 17 Aug 2018 09:46:01 +0200, Frank Millman wrote:
> It is just a slight annoyance (to me) that pylint complains about the
> subclass methods when they are called from the Field class. I don't
> mind adding 10 stub methods to the Field class to keep it happy, but I
> do not get the feeling t
On Mon, 20 Aug 2018 14:39:38 +, Steven D'Aprano wrote:
> If a class' methods don't use self, it probably shouldn't be a class.
Agreed.
> I have often wished Python had proper namespaces, so I didn't have to
> abuse classes as containers in this way :-(
>
> (Not that I do this using "inner c
On Mon, 20 Aug 2018 22:55:26 +0300, Marko Rauhamaa wrote:
> Dan Sommers :
>
>> On Mon, 20 Aug 2018 14:39:38 +, Steven D'Aprano wrote:
>>> I have often wished Python had proper namespaces, so I didn't have to
>>> abuse classes as containers in this wa
On 9/1/18 1:11 PM, moha...@gmail.com wrote:
All,
I m trying to run this small script to find the lowest of the given array of
numbers. The script works fine for various combination of inputs but fails in a
weird way for a particular set of inputs, can anyone point the mistake in the
script an
On 9/11/18 6:24 PM, Gilmeh Serda wrote:
I think this is no different than RegEx matching, so the routine really
shouldn't be called glob() but the_regex_variations_opus_five().
Maybe your version should be called crippled_glob.
Globbing has a long history, longer than many of the people who u
On 9/28/18 2:00 PM, Chris Green wrote:
I have a list created by:-
fld = shlex.split(ln)
It may contain 3, 4 or 5 entries according to data read into ln.
What's the neatest way of setting the fourth and fifth entries to an
empty string if they don't (yet) exist? Using 'if len(fld) < 4:' fee
On Sun, 03 Apr 2016 07:30:47 -0700, Rustom Mody wrote:
> So here are some examples to illustrate what I am saying:
[A vs a, A vs A, flag vs flag, etc.]
Are identifiers text or bytes? or something else entirely that takes
natural language rules and the appearance of the glyphs into account?
I, fo
On Sun, 03 Apr 2016 08:46:59 -0700, Rustom Mody wrote:
> On Sunday, April 3, 2016 at 8:58:59 PM UTC+5:30, Dan Sommers wrote:
>> Yes, it's marginally annoying, and a security hole waiting to happen,
>> that A and A often look very much alike.
>
> "A security hole w
On Sun, 03 Apr 2016 08:39:02 -0700, Rustom Mody wrote:
> On Sunday, April 3, 2016 at 8:58:59 PM UTC+5:30, Dan Sommers wrote:
>> On Sun, 03 Apr 2016 07:30:47 -0700, Rustom Mody wrote:
>>
>> > So here are some examples to illustrate what I am saying:
>>
>&g
On Sun, 03 Apr 2016 10:18:45 -0700, Rustom Mody wrote:
> On Sunday, April 3, 2016 at 9:56:24 PM UTC+5:30, Dan Sommers wrote:
>> On Sun, 03 Apr 2016 08:39:02 -0700, Rustom Mody wrote:
>>
>> > On Sunday, April 3, 2016 at 8:58:59 PM UTC+5:30, Dan Sommers wrote:
>> &
On Sun, 03 Apr 2016 09:49:03 -0700, Rustom Mody wrote:
> On Sunday, April 3, 2016 at 9:41:11 PM UTC+5:30, Dan Sommers wrote:
>> On Sun, 03 Apr 2016 08:46:59 -0700, Rustom Mody wrote:
>>
>> > On Sunday, April 3, 2016 at 8:58:59 PM UTC+5:30, Dan Sommers wrote:
>> &g
On Mon, 11 Apr 2016 01:33:10 +0100, MRAB wrote:
> There _is_ one exception though: (). It's the empty tuple (a 0-element
> tuple). It doesn't have a comma and the parentheses are mandatory.
> There's no other way to write it.
The other way to write it is:
tuple()
--
https://mail.python.org/
On Thu, 14 Apr 2016 13:25:14 +1000, Ben Finney wrote:
> How can my Python program convert the user's keyboard input to upper
> case, as though the user has CAPS LOCK enabled?
I don't know which OS you're using, but if I run "stty olcuc" in my
Linux shell, then the input driver does that for me.
On Sat, 16 Apr 2016 16:44:30 -0400, Random832 wrote:
> On Sat, Apr 16, 2016, at 16:21, Ben Finney wrote:
>> * Oh, come on, no-one would use U+000C FORM FEED in source code.
>
> Some text editors have shortcuts to navigate to the previous/next line
> that begins with a form feed.
Add these to the
On Sun, 17 Apr 2016 07:34:20 +1000, Chris Angelico wrote:
> On Sun, Apr 17, 2016 at 7:22 AM, Dan Sommers wrote:
>> On Sat, 16 Apr 2016 16:44:30 -0400, Random832 wrote:
>>
>>> On Sat, Apr 16, 2016, at 16:21, Ben Finney wrote:
>>>> * Oh, come on, no-one would
On Sun, 17 Apr 2016 11:48:11 +1000, Steven D'Aprano wrote:
> On Sun, 17 Apr 2016 09:35 am, Dan Sommers wrote:
>
>> We (this mailing list, or maybe it was the python-ideas mailing list)
>> just had a thread about non-ASCII characters in identifiers. One of
>> the
On Tue, 26 Apr 2016 11:51:23 +1000, Steven D'Aprano wrote:
> ... (Possible a few very old operating systems on supercomputers from
> the 1970s or 80s may have supported inserting... I seem to recall that
> VMS may have allowed that... but don't quote me.)
Some [non-supercomputer] OSes/filesystems
On Thu, 05 May 2016 18:37:11 -0700, Stephen Hansen wrote:
> ''.join(x for x in string if x.isupper())
> The difference is, both filter and your list comprehension *build a
> list* which is not needed, and wasteful. The above skips building a
> list, instead returning a generator ...
filter u
On Fri, 06 May 2016 02:46:22 +, Dan Sommers wrote:
> Python 2.7.11+ (default, Apr 17 2016, 14:00:29)
> [GCC 5.3.1 20160409] on linux2
> Type "help", "copyright", "credits" or "license" for more information.
> >
On Sun, 08 May 2016 23:01:55 +1000, Chris Angelico wrote:
> ... I like to recommend a little thing called "IIDPIO debugging" - If
> In Doubt, Print It Out. That means: If you have no idea what a piece
> of code is doing, slap in a print() call somewhere. It'll tell you
> that (a) the code is actu
On Mon, 09 May 2016 00:22:46 -0400, DFS wrote:
> python 2.7.11 docs: "The returned list is truncated in length to the
> length of the shortest argument sequence."
>
>
> a = ['who','let','the']
> b = ['dogs','out?']
> c = zip(a,b)
>
> print c
> [('who', 'dogs'), ('let', 'out?')]
>
>
> Wouldn'
On Wed, 18 May 2016 20:59:55 -0400, DFS wrote:
> Have aList = [
> ('x','Name1', 1, 85),
> ('x','Name2', 3, 219),
> ('x','Name2', 1, 21),
> ('x','Name3', 6, 169)
> ]
>
> want
>
> aList = [
> ('Name1', 1, 85),
> ('Name2', 4, 240),
> ('Name3', 6, 169)
> ]
[snip]
> Is there something shorter and
On Sat, 21 May 2016 03:19:49 +, Dan Sommers wrote:
>> Is there something shorter and sweeter for the summation?
>
> from itertools import groupby
> from operator import itemgetter
>
> result = [(k,
>sum(map(itemgetter(2), v)),
>
On Mon, 06 Jun 2016 17:51:24 -0700, Lawrence D’Oliveiro wrote:
> It is nice to have a common, versatile looping form which can be
> arranged in different ways to suit the problem at hand. That’s why I
> like the C-style for-statement.
[example snipped]
I used to write a lot of assembly code, for
On Tue, 07 Jun 2016 00:53:31 -0700, Lawrence D’Oliveiro wrote:
> On Tuesday, June 7, 2016 at 3:34:39 PM UTC+12, Dan Sommers wrote:
>
>> I used to write a lot of assembly code, for a lot of different CPUs, and
>> they all had a common, versatile looping form which co
On Wed, 22 Jun 2016 12:57:55 +1000, Chris Angelico wrote:
> On Wed, Jun 22, 2016 at 12:48 PM, Steven D'Aprano wrote:
>> I'm doing some arithmetic on complex numbers involving INFs, and getting
>> unexpected NANs.
>>
>> py> INF = float('inf')
>> py> z = INF + 3j
>> py> z
>> (inf+3j)
[...]
>> Is
On Wed, 22 Jun 2016 16:30:49 +1000, Chris Angelico wrote:
> On Wed, Jun 22, 2016 at 4:17 PM, Steven D'Aprano
> wrote:
>> On Wednesday 22 June 2016 13:54, Dan Sommers wrote:
>>
>>> By the time Python returns a result for inf+3j, you're already in
>>
On Thu, 23 Jun 2016 13:59:46 +1000, Steven D'Aprano wrote:
> Given:
>
> x = INF
> y = INF
> assert x == y
>
> there is a reason to pick atan2(y, x) = pi/4:
>
> Since x == y, the answer should be the same as for any other pair of x == y.
When x == y == 0, then atan2(y, x) is 0.
--
https://mail
On 11/18/18 1:21 PM, MRAB wrote:> On 2018-11-18 17:50, Adam Funk wrote:
>> Hi,
>>
>> I'm using bottledaemon to run a little REST service on a Pi that takes
>> input from other machines on the LAN and stores stuff in a database.
>> I have a cron job to call 'stop' and 'start' on it daily, just in c
On 11/19/18 6:49 PM, Robert Girault wrote:
> I think I disagree with your take here. With mt19937, given ANY seed,
> I can eventually predict all the sequence without having to query the
> oracle any further.
Even if that's true, and I use mt19937 inside my program, you don't
[usually|necessari
On 11/21/18 11:45 AM, Iwo Herka wrote:
Hello,
Let's say I want to implement immutability for user-defined class.
More precisely, a class that can be modified only in its (or its
super-class') __init__ method. My initial idea was to do it the
following fashion:
def __setattr__(self, *args,
On 11/21/18 6:45 PM, Ian Kelly wrote:
> On Wed, Nov 21, 2018 at 2:53 PM Serhiy Storchaka
wrote:
>>
>> 21.11.18 22:17, Cameron Simpson пише:
>>> Can someone show me a real world, or failing that - sane looking,
>>> chained comparison using "in"?
>>
>> s[0] == s[-1] in '\'"'
>>
>> Tests tha
On 11/21/18 7:09 PM, Chris Angelico wrote:
> On Thu, Nov 22, 2018 at 11:04 AM Dan Sommers
> <2qdxy4rzwzuui...@potatochowder.com> wrote:
>> But the second one has to do an expensive subset operation. If I think
>> "is elem in both sets," then I'd never writ
On 11/30/18 7:35 AM, Morten W. Petersen wrote:
... but isn't it logical that the
string is parsed and split, and then later the unpacking operation fails
with an IndexError?
With slightly simpler code and the full text of the exception,
the details becomes more apparent:
>>> x, y = [4]
Traceb
On 11/30/18 10:57 AM, Morten W. Petersen wrote:
> On Fri, Nov 30, 2018 at 4:25 PM Dan Sommers
<2qdxy4rzwzuui...@potatochowder.com> wrote:
>> Python validates that the right hand side contains exactly the right
>> number of elements before beginning to unpack, p
On 11/30/18 12:00 PM, Morten W. Petersen wrote:
> I guess syntax could be added, so that
>
> a, b, @c = some sequence
>
> would initialize a and b, and leave anything remaining in c. We could
> then call this @ syntax "teh snek".
Close. ;-) Try this:
a, b, *c = [4, 5, 6, 7]
--
https://ma
On 1/8/19 2:31 PM, Tobiah wrote:> On 1/8/19 9:20 AM, Alister wrote:
>> On Tue, 08 Jan 2019 17:15:17 +, Alister wrote:
>>
>>> On Tue, 08 Jan 2019 16:48:58 +0200, Serhiy Storchaka wrote:
>>>
08.01.19 11:07, Peter Otten пише:
> Bob van der Poel wrote:
>
>> I need to see if all th
On 1/29/19 9:27 AM, Jack Dangler wrote:
wow. Seems like a lot going on. You have 3 ints and need to determine
the max? Doesn't this work?
N1, N2, N3
if N1>N2
if N1>N3
MaxNum = N1
elif N2>N3
MaxNum = N2
elif N1
No. Assuing that you meant to include colons where I think
you did, wh
1 - 100 of 456 matches
Mail list logo