Erik :
> On 01/04/16 15:34, Marko Rauhamaa wrote:
>> Chris Angelico :
>>
>>> *A range object is not an iterator.*
>>
>> We now have learned as much.
>>
>> However, doesn't that extra level of indirection seem like an odd
>> choice?
>
Rob Gaddi :
> Marko Rauhamaa wrote:
>> There's a bit of a cognitive dissonance between iterables and iterators.
>> On the one hand, they behave identically in many contexts. On the other
>> hand, the distinction is crucial in some special cases.
>
> You're mi
Steven D'Aprano :
> On Sat, 2 Apr 2016 07:14 am, Marko Rauhamaa wrote:
>> (Somehow, the difference between iterables and iterators is analogous
>> with the difference between C's arrays and pointers.)
>
> I don't understand this analogy. Can you explain plea
Chris Angelico :
> Yep! And the letters (thorn and eth) survive in a very few languages
> (Icelandic, notably). Fortunately, Python 3 lets you use it in
> identifiers.
While it is fine for Python to support Unicode to its fullest, I don't
think it's a good idea for a programmer to use non-English
Steven D'Aprano :
> I'd rather read:
>
> for oppilas in luokka:
> if oppilas.hylätty():
> oppilas.ilmoita(oppilas.koetulokset)
>
> [...]
>
> Google translate suggests Marko's code means:
>
> for pupil in class:
> if pupil.abandoned():
> pupil.please(
Rustom Mody :
> When python went to full unicode identifers it should have also added
> pragmas for which blocks the programmer intended to use -- something
> like a charset declaration of html.
You are being silly.
Marko
--
https://mail.python.org/mailman/listinfo/python-list
Terry Reedy :
> On 4/2/2016 12:44 PM, Marko Rauhamaa wrote:
>
>> Nowadays software companies and communities are international.
>
> Grade school classrooms, especially pre-high school, are not.
Parenthetically, English teachers in Finland have been happy with how
teenage bo
Ned Batchelder :
> This analogy illuminates an important point: a single iterable can have
> a number of active iterators working over it at once, just as a book can
> have a number of bookmarks in it at once.
>
> nums = [1, 2, 3]
> for i in nums:
> for j in nums:
> pri
Chris Angelico :
> On Sun, Apr 3, 2016 at 6:44 AM, Marko Rauhamaa wrote:
>> I don't have a problem with a list being a "reiterable." I only was
>> surprised about range(), which I had thought to be a plain,
>> down-to-earth iterator. There's barely
Stephen Hansen :
> On Sat, Apr 2, 2016, at 02:40 PM, Marko Rauhamaa wrote:
>> That's why I was looking for counterexamples in the standard library
>
> This entire bent of an argument seems flawed to me.
>
> The standard library has never been a beacon for best practi
Dennis Lee Bieber :
> For the OP: Very few languages have built-in graphics commands;
> which is why porting BASIC programs was so difficult. This means you
> have to import some graphical framework and use ITS command functions.
The Racket dialect of the Scheme programming language has an i
Joaquin Alzola :
> Python is like shell scripting but with Steroids. For a SysAdmin is a must.
> This email is confidential and may be subject to privilege. If you are
> not the intended recipient, please do not copy or disclose its content
> but contact the sender immediately upon receipt.
Oh, I
Gregory Ewing :
> Another option for graphical stuff is pygame:
Thanks!
> http://pygame.org/news.html
Especially for this:
No need to mess with installing it outside of your operating systems
package manager.
However:
Does Pygame work with Python 3?
Yes. Pygame 1.9.2 supports Py
BartC :
> But you don't have to use classes, exceptions, decorators, generators,
> iterators, closures, comprehensions, meta classes, ... the list of
> meaningless buzzwords just goes on.
Also, you don't have to use the letter "e" in your identifiers or the
number 2 anywhere in your programs.
Re
BartC :
> But you're right in that little is actually essential. Basic has shown
> that.
>
> You need expressions, IF, GOTO, variables and assignments, and some
> means of doing I/O.
>
> Pretty much every language has (had) those, although it's fashionable
> now to do away with GOTO, and some are
Michael Selik :
> On Wed, Apr 6, 2016, 12:51 PM Marko Rauhamaa wrote:
>
>> Really, there's only one high-level construct you can't live without:
>> the "while" statement. Virtually every Python program has at least
>> one "while" statement, a
Chris Angelico :
> Plus, anyone could implement a Python interpreter with TCE.
Tricky in practice because None is the default return value.
If the programmer were careful to return the value of the tail call, it
can be eliminated.
Marko
--
https://mail.python.org/mailman/listinfo/python-list
Random832 :
> On Wed, Apr 6, 2016, at 14:23, Marko Rauhamaa wrote:
>> Chris Angelico :
>> > Plus, anyone could implement a Python interpreter with TCE.
>>
>> Tricky in practice because None is the default return value.
>>
>> If the programmer were ca
Ian Kelly :
> On Wed, Apr 6, 2016 at 8:14 AM, Marko Rauhamaa wrote:
>> Now, if Python had an unlimited range() iterator/iterable, you could use
>> a "for" statement to emulate "while".
>
> You can already do this.
>
>>>> class While:
>
Chris Angelico :
> This is the exact sort of shenanigans that it takes to convert
> recursion into tail recursion - and in MOST cases, it's very little
> effort to go from there to explicit while loops. That's why TCE is so
> infrequently important that it's just not worth the cost - which in
> th
Ian Kelly :
> On Wed, Apr 6, 2016 at 1:22 PM, Marko Rauhamaa wrote:
>> Why is a SimpleNamespace object not an iterator even though it
>> provides __iter__ and __next__?
>
> Because Python expects those methods to be defined in the class dict,
> not the instance dict.
Terry Reedy :
> On 4/6/2016 10:14 AM, Marko Rauhamaa wrote:
>
>> Seriously, Python wouldn't be, couldn't be Turing-complete without
>> "while" (mainly because it doesn't support tail-recursion
>> elimination).
>>
>> Now, if Python h
Ian Kelly :
> On Wed, Apr 6, 2016 at 1:59 PM, Marko Rauhamaa wrote:
>> It seems to me CPython is being a bit too picky here. Why should it
>> care if the method is a class method or an object method?
>
> Because the purpose of a class is to define the behavior of its
&g
Ian Kelly :
> On Wed, Apr 6, 2016 at 2:39 PM, Marko Rauhamaa wrote:
>> Not convinced. Probably just an oversight.
>
> It's documented here:
> https://docs.python.org/3/reference/datamodel.html#special-method-lookup
Ok, not an oversight but some inherent trouble with the
Rolf Camps :
> Op 07-04-16 om 00:03 schreef Marko Rauhamaa:
>> IOW, if I have this class:
>>
>> class A:
>> def f(self):
>> print("f")
>>
>> and this object:
>>
>> a = A()
>>
>> t
Steven D'Aprano :
> So even in English, capitalisation can make a semantic difference.
It can even make a pronunciation difference: polish vs Polish.
Marko
--
https://mail.python.org/mailman/listinfo/python-list
Ian Kelly :
> Let's take a different example.
>
> class Dialog(Window):
>
> def __init__(self, parent, title, ok_callback):
> super().__init__(parent, title)
> self._ok_callback = ok_callback
> self._ok_button = Button(self, 'Ok')
> self._ok_button.bind(self._ok
Paul Rubin :
> Chris Angelico writes:
>> First off, what does it actually *mean* to have a tree with numbers
>> and keys as strings? Are they ever equal? Are all integers deemed
>> lower than all strings? Something else?
>
> If the AVL tree's purpose is to be an alternative lookup structure to
>
Ian Kelly :
> On Thu, Apr 7, 2016 at 1:32 PM, Marko Rauhamaa wrote:
>> I use AVL trees to implement timers. You need to be able to insert
>> elements in a sorted order and remove them quickly.
>
> Why would AVL trees implementing timers ever need non-numeric keys
> th
Paul Rubin :
> Marko Rauhamaa writes:
>> Guido chose a different method to implement timers for asyncio. He
>> decided to never remove canceled timers.
>
> Oh my, that might not end well. There are other approaches that don't
> need AVL trees and can remove cancell
Ian Kelly :
> On Apr 7, 2016 10:22 PM, "Marko Rauhamaa" wrote:
>> The keys are expiry times. You could use numbers or you could use
>> datetime objects.
>
> Yes, but why would you want to use both?
I was never talking about mixing key types. I was simply
Terry Reedy :
> On 4/8/2016 12:22 AM, Marko Rauhamaa wrote:
>> The issue is known. It has been tackled with a kind of a "garbage
>> collection" scheme:
>>
>> https://bugs.python.org/issue22448>
>
> and fixed 1 1/2 years ago.
On the surface, th
Paul Rubin :
> Marko Rauhamaa writes:
>> On the surface, the garbage collection scheme looks dubious, but
>> maybe it works perfect in practice.
>
> It looked suspicious at first glance but I think it is ok. Basically
> on at most every timeout event (scheduling, expir
Antoon Pardon :
> In python2 descending the tree would only involve at most one
> expensive comparison, because using cmp would codify that comparison
> into an integer which would then be cheap to compare with 0. Now in
> python3, I may need to do two expensive comparisons, because there is
> no
Steven D'Aprano :
> I would be stunned if tuple comparisons with only a handful of values
> were slow enough that its worth caching their results with an
> lru_cache. But try it, and see how you go.
There are two ways your Python program can be slow:
* You are doing something stupid like an O(e
Antoon Pardon :
> Well having a list of 1000 Sequence like object. Each sequence
> containing between 1 and 100 numbers. Comparing each sequence
> to each other a 100 times. I get the following results.
>
> Doing it as follows:
> seq1 < seq2
> seq2 < seq1
>
> takes about 110 seconds.
>
> D
Ian Kelly :
> That's fine for those operations and probably insert, but how do you
> search an AVL tree for a specific key without also using __eq__?
Not needed:
if key < node.key:
look_right()
elif node.key < key:
Ian Kelly :
> On Fri, Apr 8, 2016 at 10:33 AM, Marko Rauhamaa wrote:
>> Ian Kelly :
>>
>>> That's fine for those operations and probably insert, but how do you
>>> search an AVL tree for a specific key witho
Peter Pearson :
> On Fri, 08 Apr 2016 16:00:10 +1000, Steven D'Aprano
> wrote:
>> They are not, and never have been, in the typesetting business.
>> Perhaps characters are not the only things easily confused *wink*
>
> Defining codepoints that deal with appearance but not with meaning is
> going
Steven D'Aprano :
> But when you get down to fundamentals, character sets and alphabets have
> always blurred the line between presentation and meaning. W ("double-u")
> was, once upon a time, UU
But as every Finnish-speaker now knows, "w" is only an old-fashioned
typographic variant of the glyph
Antoon Pardon :
> Now this probably is not a problem most of the times, but when you
> work with tree's this kind of comparison to make a three way decision
> happens often and the lower you descend in the tree, the close your
> argument will be with the keys of the nodes you visit, making it more
Antoon Pardon :
> And when I need some personal object as a key, I can avoid the
> duplication by using some kind of cmp cache when I implement __lt__
> and family.
Yes, that's what you can do in rare, extreme cases where key comparison
takes a long time. For caching, you will simply need to requ
Terry Reedy :
> On 4/10/2016 8:17 PM, Fillmore wrote:
>
>> apparently my 'discontinuity' is mappable to the fact that there's no
>> such thing as one-element tuples in Python, and attempts to create
>> one will result in a string (i.e. an object of a different kind!)...
>
> Please work through the
BartC :
> Of course this doesn't help you parsing typical input which uses
> commas as separators, not terminators!
That's a red herring. You mustn't parse with eval(). You shouldn't event
think of parsing non-Python data with eval(). Why should Python's syntax
resemble a CSV file?
Try compiling
martin.spic...@gmail.com:
> there may be a serious error in python's int() function:
>
> print int(float(2.8/0.1))
>
> yields
>
> 27
>
> instead of 28!!
It is not an error but a normal artifact of decimal-to-binary
conversion.
Marko
--
https://mail.python.org/mailman/listinfo/python-list
Rustom Mody :
> Given the eg in the docs:
> from enum import Enum
> class Color(Enum):
> red = 1
> blue = 2
> green = 3
>
Color(Color.red.value+1)
>
But:
>>> class Color(enum.Enum):
... red = 0xff
... green = 0x00ff00
... blue = 0xff
...
>>> Colo
Grant Edwards :
> On 2016-04-13, Michael Selik wrote:
>> An Enum corresponds to "nominal" data that is coded as a number
>> simply for storage rather than meaning.
>
> FWIW, as an old Pascal programmer, I too would have been surprised
> that an "enum" is not ordinal and doesn't support a next/pre
Chris Angelico :
> Let's just guess that you want to xor with the byte value 0xAA. We can
> do that fairly simply, using integer operations.
>
data = b'$//W?\xc0\x829\xa2\xb9\x13\x8c\xd5{\\'
bytes(b ^ 0xAA for b in data)
> b'\x8e\x85\x85\xfd\x95j(\x93\x08\x13\xb9&\x7f\xd1\xf6'
>
> Well,
durgadevi1 :
>>>>> bytes(c ^ k for c, k in zip(code, key)).decode()
>
> [...]
> UnicodeDecodeError: 'utf-8' codec can't decode byte 0x85 in position 0:
> invalid start byte
>
> [...]
>
> However, I get no errors when using values 0 to 127 to XOR with CODE.
> But I get errors when using values
Ben Finney :
> I had been hoping that I could simply wrap some stream in a simple
> “convert what they actually type so it's upper case” text codec,
> without fiddling at such a low operating-system specific level. This
> is rather more esoteric than I had hoped.
If you run your program in a Linu
Bob Martin :
> in 758117 20160416 053809 Steven D'Aprano wrote:
>>Until now, PEP 8 has recommended that multi-line expressions should
>>break *after* infix operators:
>>
>>
>>result = (this_value *
>>some_value +
>>another_value -
>>excess_value or
>>default_value
>>)
>>
>>
>>After a mercifully s
Chris Angelico :
> On Sat, Apr 16, 2016 at 6:06 PM, Marko Rauhamaa wrote:
>> It doesn't really matter one way or another. The true WTF is that it's
>> been changed.
>
> Why? Was PEP 8 inscribed on stone tablets carried down from a mountain?
In a way, yes.
Larry Martell :
> I have worked for many companies where you are required to get a clean
> run of pep8 on your code before your pull request will even be
> considered for approval. I don't agree with this at all, as I think it
> makes the code very ugly, especially enforcing the max line length.
Terry Reedy :
> On 4/16/2016 12:58 PM, Larry Martell wrote:
>> if we still had 1970's 80 character TTYs that would matter but on my
>> 29" 1920x1080 screen it doesn't.
>
> It depends on whether one prefers to use the extra width to have long
> lines or side-by-side windows. I prefer the latter.
Tim Delaney :
> Personally, I've given up on 80 characters (or even 120 in rare cases)
> for Java code (esp method declarations), where just specifying the
> generics can often take almost that much.
Java generics ruined a perfectly good language. I mean:
Map> customersOfAccountManager =
Rustom Mody :
> On Saturday, April 16, 2016 at 10:22:10 PM UTC+5:30, Marko Rauhamaa wrote:
>> A max line length of 79 characters is among the *only* rigorous
>> principles I judge coding style on.
>>
>> It comes with the maxim that one function must be visible at once
Chris Angelico :
> On Sun, Apr 17, 2016 at 9:01 PM, Marko Rauhamaa wrote:
>> In fact, if you find yourself introducing coding "paragraphs" with
>> comments:
>>
>> def f(...):
>> # I'll start by doing this
>>
Steven D'Aprano :
> On Mon, 18 Apr 2016 10:27 am, Random832 wrote:
>
>> As an alternative, when you send them through can you put a note on
>> the bottom saying they're not subscribed, to remind people to CC them
>> in responses?
>
> That doesn't work so well from Usenet. I can reply via news (whi
Steven D'Aprano :
> One technique which is common in Pascal, but less so in Python, is to get
> the best of both worlds by using nested functions. In Python syntax:
>
> def Do_The_Thing():
> def internal_subpart_start(): ...
> def internal_subpart_middle(): ...
> def internal_subpart_e
Gregory Ewing :
> It's understandable that Java didn't originally have a typedef,
> because all types had short enough names anyway. But generics changed
> that in a big way, and it baffles me that some form of typedef wasn't
> added soon afterwards.
Java's opposition to typedef seems to be somet
Gregory Ewing :
> Marko Rauhamaa wrote:
>> Steven D'Aprano :
>>
>>>def Do_The_Thing():
>>>def internal_subpart_start(): ...
>>>def internal_subpart_middle(): ...
>>>def internal_subpart_end(): ...
>>>...
>>
Pete Forman :
> I like that Nick separates out the concept of alignment with implicit
> semantics from the n spaces v tabs arguments. My question asks why
> monospace is used for the text.
Because the so-called "plain text" is the age-old lowest common
denominator for formal syntax. Python is esp
Paul Rudin :
> Pete Forman writes:
>> Why is it that Python continues to use a fixed width font and
>> therefore specifies the maximum line width as a character count?
>
> Python doesn't require the use of any particular font for editing your
> code.
>
> However programmers tend to use fixed widt
Rustom Mody :
> In the same way and like colorforth, it would be better to distinguish
> identifier from
> identifier rather than the current status of
> distinguishing identifier from Identifier But then we have a slippery
> slope: Should be same/distinct from ?
In a past life of mine, a devel
Steven D'Aprano :
> On Mon, 18 Apr 2016 03:32 pm, Marko Rauhamaa wrote:
>> Did you get the CC, Steven.
>
> Yes I did. I frequently have people CCing me. But that's not the
> problem for me -- as I said above, it's a pain for me to SEND (not
> receive) via bot
Chris Angelico :
> On Wed, Apr 20, 2016 at 6:50 AM, Ben Finney
> wrote:
>>> > On Tue, 19 Apr 2016 01:04 pm, Rustom Mody wrote:
>>> > > And more generally that programmers sticking to text when rest
>>> > > of world has moved on is rather backward:
>>
>> You haven't supported that claim at all, an
Steven D'Aprano :
> On Sun, 24 Apr 2016 12:03 pm, Christopher Reimer wrote:
>
>> On 4/23/2016 2:33 PM, Matt Wheeler wrote:
>>> This is still backwards to me. It prevents your classes from being
>>> suitable for restoring a stored game state, not just custom starting
>>> positions (which I think is
Ben Finney :
> Gary Herron writes:
>
>>The __init__ method is the constructor for instances of a class.
>>It is not required, but the situations in which a constructor is
>>not needed are few and unusual.
>
> That's needlessly confusing: ‘__init__’ is not a constructor because
> it do
Steven D'Aprano :
> On Tue, 26 Apr 2016 06:25 pm, Marko Rauhamaa wrote:
>> Check out some of the stdlib source code for example:
>>
>>
>> class ThreadPoolExecutor(_base.Executor):
>&
MRAB :
> 'pythonic-ness'? Surely it's 'pythonicity'! :-)
Doubt it:
Full Definition of generic
[...]
—generically \-i-k(ə-)lē\ adverb
—genericness noun
http://www.merriam-webster.com/dictionary/generic>
Marko
--
https://mail.python.org/mailman/listinfo/python-list
Irmen de Jong :
> An idea: Use just one help option, then
>
> if sys.stdout.isatty():
> #use a pager to display help text
> else:
> #print all help text normally
I've seen that used, but I find it annoying:
Grant Edwards :
> On 2016-04-28, Random832 wrote:
>> One disadvantage is that you have to compose two forms of
>> documentation.
>
> Only if you want two forms of documentation.
>
> If you add an option to run the help info through a pager, I don't see
> how that requires you to compose two forms
alister :
> I don't see my posts appearing, posting to news group using Pan on
> Linux. posts to other news groups are fine
Take yourself out of your killfile.
Marko
--
https://mail.python.org/mailman/listinfo/python-list
Grant Edwards :
> On 2016-05-01, Chris Angelico wrote:
>> Okay. How is an app supposed to know whether or not to use a pager?
> Command line option.
>
>> How do you expect them to mindread?
> Nope, just recognize '-p' or somesuch.
In discussions like these, it would be important to draw from
pre
BartC :
> On 02/05/2016 04:39, DFS wrote:
>> 2. urllib.urlretrieve("http://econpy.pythonanywhere.com
>> /ex/001.html","D:\file.html")
> [...]
>
> It seems Python provides a higher level solution compared with VBS.
> Python presumably also has to do those Opens and Sends, but they are
> hidden
Terry Reedy :
> In case you like minecraft, I just discovered this today
> https://www.nostarch.com/programwithminecraft "Learn to Program with
> Minecraft"
>
> It uses a socket client written in 3.5 to interface to a minecraft 1.8
> socket server written in java 7. One can at least do simple thin
Gregory Ewing :
> Suppose there are 100 people wanting to ask questions, and there is
> only time to answer 10 questions. If the 1 in 20 ratio holds, then 5
> of those people are women and the other 95 are men.
>
> Alternating between men and women means that all of the women get
> their questions
Steven D'Aprano :
> On Sat, 7 May 2016 06:50 pm, Marko Rauhamaa wrote:
>> Indian and Chinese H1B holders are getting screwed, which is of course
>> the whole objective of the country limits.
>
> The *whole* objective? You don't think that *part* of the objective
&
Chris Angelico :
> But immigration laws are a pretty terrible mess the world over, from
> what I've seen, and I wish countries could drop the whole "but we have
> to protect ourselves from foreigners" thing. At some point, those
> "foreigners" become "citizens", and just as worthy of your protecti
Christopher Reimer :
> Never know when an asshat hiring manager would reject my resume out of
> hand because my code fell short with pylint.
Remember that it's not only the company checking you out but also you
checking the company out.
Would you want to work for an asshat hiring manager?
Of cou
Chris Angelico :
> So the question is: Do we care about country equality or individual
> equality? You can't have both.
That's why there's been a long-standing initiative to split California
into multiple states:
https://en.wikipedia.org/wiki/Six_Californias>
Each state gets two senate seats,
Random832 :
> But that's not what it is. You would have, say, 1,000 tickets labeled
> "green card" and 100,000 tickets labeled "no green card", and (say)
> 12,000 Indian people and 50 Finnish people each get their turn drawing
> from that same bucket. In your version, the Finnish people draw from a
Dirk Bächle :
> I'm one of the SCons (http://www.scons.org) developers
I take the opportunity to thank you and your colleagues for the
wonderful building tool that I have used professionally to great success
since 2003.
> We're a build system and all the code is written in Python. Even more
> so
Dirk Bächle :
>> For example, why do you need a key? Couldn't you simply pass the task
>> master class as an argument?
>
> The idea behind this is, to be able to select classes by giving a
> parameter on the command-line. So at some point a translation from a
> given "key" to its actual class has
Steven D'Aprano :
> Personally, I think that advertising a job position without saying who
> you are, what you do, and offering at least an indicative salary
> range, are *astonishingly* rude
I don't believe they care.
> (to say nothing of counter-productive).
Maybe, maybe not.
I bet the zebra
Gregory Ewing :
> Is there some way you can get more stuff into a single
> html page? For example, use inline css and image data
> instead of delivering them as separate files.
Better yet, is there some way you could send less stuff?
There are two points of note here.
1. The top ten sit
Steven D'Aprano :
> On Tuesday 17 May 2016 16:18, Marko Rauhamaa wrote:
>
>> Steven D'Aprano :
>>> Personally, I think that advertising a job position without saying who
>>> you are, what you do, and offering at least an indicative salary
>>> r
Radek Holý :
> 2016-05-17 9:50 GMT+02:00 Steven D'Aprano <
> steve+comp.lang.pyt...@pearwood.info>:
>
>> Overhead in the office today:
>>
>> "I don't have time to learn an existing library - much faster to make
>> my own mistakes!"
>
> *THUMBS UP* At least they are aware of that "own mistakes" par
Paul Rudin :
> Marko Rauhamaa writes:
>> The feeling of powerlessness can be crushing when you depend on a
>> third-party component that is broken with no fix in sight.
>
> Presumably it depends on whether you have the source for the third
> party component...
Just h
Michael Torrie :
> On 05/17/2016 08:27 AM, Paul Rudin wrote:
>> Marko Rauhamaa writes:
>>> That's a long time to be without a product to sell.
>>
>> But you do have the option of building a kernel incorporating your fix
>> and using that.
>
> Sure
theh...@gmail.com:
> This is exactly what I'm referencing. We can do mental gymnastics for
> it to make sense,
Programming languages are not English. Any resemblance is purely
coincidental.
Marko
--
https://mail.python.org/mailman/listinfo/python-list
theh...@gmail.com:
> You seem to have missed the point. Nobody is suggesting, I don't
> believe, that all of a language should be intuitive. Rather that if
> any part of it is unnecessarily counter-intuitive, it may be worth
> looking for a better solution. Python is a very well designed language
Erik :
> On 20/05/16 01:06, Steven D'Aprano wrote:
>> In my experience, some people (including me) misunderstand
>> "for...else" to mean that the else block runs if the for block
>> *doesn't*. It took me the longest time to understand why this didn't
>> work as I expected:
>>
>> for x in seq:
>>
Christopher Reimer :
> Under various proposals in the U.S., everyone will soon learn how to
> program and/or become a computer scientist. Won't be long before some
> snotty-nosed brat graduates from preschool, takes a look at your code,
> and poops in his diapers. He will then dips his finger into
Jon Ribbens :
> On 2016-05-21, Chris Angelico wrote:
>> The trouble is, what SHOULD 2/3 return?
>
> [...]
>
> Yes, it should return an integer - and not because I think Python
> should behave like C on principle, but because:
>
> Explicit is better than implicit.
> Simple is bette
Chris Angelico :
> On Mon, May 23, 2016 at 1:19 AM, Steven D'Aprano wrote:
>> Okay, now I'm confused. How is 1/2 returning 0.5 the language not doing what
>> you've told it to do?
>
> That isn't the problem. With binary floats, 1/2 can be perfectly
> represented, so you have no trouble anywhere.
Rustom Mody :
> Haskell has (almost) what I learnt at school:
>
> Prelude> let (q,r) = 7 `divMod` 3
> Prelude> (q,r)
> (2,1)
Python:
>>> divmod(7, 3)
(2, 1)
> Replace the strange `divMod` with / and we are back to the behavior I
> first learnt at school
Christopher Reimer :
> Back in the early 1980's, I grew up on 8-bit processors and latin-1 was
> all we had for ASCII.
You really were very advanced. According to https://en.wikipedia.org/wiki/ISO/IEC_8859-1#History>, ISO 8859-1 was
standardized in 1985. "Eight-bit-cleanness" became a thing in th
Steven D'Aprano :
> I have a timedelta object, and I want to display it in a nice
> human-readable format like 03:45:17 for "three hours, forty five
> minutes, 17 seconds".
>
> Is there a standard way to do this?
>>> import datetime
>>> td = datetime.timedelta(hours=3, minutes=45, seconds=1
Rustom Mody :
> On Wednesday, May 25, 2016 at 4:18:02 PM UTC+5:30, Marko Rauhamaa wrote:
>> Christopher Reimer:
>>
>> > Back in the early 1980's, I grew up on 8-bit processors and latin-1 was
>> > all we had for ASCII.
>>
>> You really were very
501 - 600 of 2184 matches
Mail list logo