« first day (2348 days earlier)      last day (2609 days later) » 

8:03 PM
Equality comparisons are allowed, ordering comparisons are not
 
8:13 PM
Python 2.7.13 (default, Jan 19 2017, 14:48:08)
>>> 1 > None
True
>>> None > 1
False
>>> None > None
False
♫♪ I can't get no FutureWarnings
 
You have to turn it on. Run it with python -3
 
wtf I thought you were joking:D
thanks
 
@DSM -W all and however you filter warnings
 
it would help the migration to 3 if python -3 was the default
 
DSM
@KevinMGranger: I award you one thousand quatloos. Please use them responsibly.
 
8:19 PM
Migration problems aren't because of knowing where things will break, it's because of architectures that depended upon old behavior, and a non-zero cost to do it at all
 
My notion was that constant nagging by the interpreter drives up the cost of using 2, to the point where it's more profitable to port them to 3 :P
 
8:38 PM
The problem is not just the non-zero cost. The cost to upgrade has to be worth something. Python 2.7 is a fine language. The decision to make Python 3 source incompatible was a mistake.
I mean, if you upgrade all your code to Python 3, you get nothing for the effort. You will introduce more bugs, and nothing will be better. So you have spent work for no reason.
 
any IntelliJ/PyCharm users here have any solutions for ensuring their PATH is always consistent between their real terminal and whatever happens inside the IDE?
I'm dealing with too many inconsistencies and the work around of manually adding PATH-things to my config gets tiring
 
I'd just not fiddle with the PATH inside the IDE, and then make sure it's all set at the OS level
 
that's my take on it as well. But my IDE is the only area where these commands are inconsistent. My local env, the VMs I spin up to run the tests and even Travis all run perfectly fine
can it still be something not set right OS-level that is causing the IDE to not grab what it needs?
 
launch the IDE in the background from your prompt? Maybe it's the IDE just ignoring the system settings :P
 
Yeah, running expandvars("$PATH") I get:
/Users/xxx/dev/app/.tox/py35/bin:/usr/bin:/bin:/usr/sbin:/sbin
which is clearly not what is happening in the real world
 
8:51 PM
Weirdness.
 
Agreed.
it's just annoying because this is a non-problem for how this will run int its intended environment
 
Path isn't in your ignored variables is it?
 
oh god....hold on
I've been bitten by this before
ok no. Nothing ignored path-wise
 
wow after almost 6 years I just now discovered <> is a legal python operator..
 
Got syntax error.
 
8:58 PM
Weird that it still survived as it means there "isn't one, and preferably only one, obvious inequality operator"
 
yeah python 2 has that
no no in real py version of 3
▶ python3.5
Python 3.5.1 (v3.5.1:37a07cee5969, Dec  5 2015, 21:12:44)
>>> 1 <> 1
  File "<stdin>", line 1
    1 <> 1
       ^
SyntaxError: invalid syntax

▶ python
Python 2.7.10 (default, Jul 30 2016, 19:40:32)
>>> 1 <> 1
False
>>>
 
Ah didn't actually test it, good to see it's gone.
 
cbg Bobert
 
cbg
 
9:02 PM
Python 3.6.0 (v3.6.0:41df79263a11, Dec 22 2016, 17:23:13)
[GCC 4.2.1 (Apple Inc. build 5666) (dot 3)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>> from __future__ import barry_as_FLUFL
>>> 1 <> 1
False
@idjaw FTFY
 
what is that?
 
47
A: So what exactly does “from __future__ import barry_as_FLUFL” do?

Lie RyanIt's related to PEP 0401: BDFL Retirement Barry refers to Barry Warsaw, a well-known Python developer. The from __future__ import barry_as_FLUFL basically replaces the != operator with <>.

 
-.-
 
DSM
Is there a word for "object which is iterable and len()-able but need not provide a __getitem__"? Sequence would work but for the __getitem__.
 
Oh hey - that's interesting...
Oh, also, to clarify: even if you use -i, the script that is executed before you get to the REPL must follow normal Python 3 syntax, or you will get a syntax error. And if you get a syntax error in the script, then the REPL will behave as though you never did the import. (You just have to do it again at the REPL, but that defeats the point of putting it in your script in the first place.) It's OK if the script raises (most?) other kinds of exceptions though; the import will still be in effect when you get dumped to the REPL in that case. — John Y Feb 24 at 22:16
 
9:06 PM
@WayneWerner :P hehe
 
@DSM C# uses "collection" for that
 
I've only used it in the REPL, so I didn't know that it only works in the REPL, hehe
 
DSM
@paul23: Hmm, we may too.
I hadn't really thought about __contains__ one way or another, so I guess it's within my original sense of things.
 
I'd expect what you need to have __contains__
 
Well iterable implies` __contains__`
 
9:09 PM
my mental image after your inquiry is a set
 
As, for python, if you can iterate it - python provides a default in operator....
Funny, for the longest time I didn't understand the difference between an "iterable" and an "iterator". Mainly cause both words I couldn't translate directly to my native language.
 
that's interesting
 
DSM
"implies" in a pretty weak sense. You can have an object you can iterate over but which doesn't support in.
 
iterator was really easy for me - I picked that up in C++
 
OK...I found a different way to do this. Travis will set something to say it is running in the CI to know whether it should talk to docker...my test will look for this var...if it is not set, it will run the app locally to run the black box tests
I don't got time for this intellij path shenanigan tom foolery
 
9:16 PM
@WayneWerner Well me too: but I just kept thinking other languages meant "iterators" when they called something an "iterable".
 
ah
I can see how that would be confusing, especially if you weren't familiar with the -er/-able suffixes
 
@DSM uh isn't that a feature of the language: "if an object has __contains__ it uses that method, if not and it has an __iter__() it uses the iteration over all elements, and if that isn't there it uses getitem()"
I am looking for a source of above but seem to be unable to find it.
 
DSM
@paul23: I think you're right that __contains__ falls back to iteration, but there's nothing to prevent you from preventing that by raising an exception. That's unnatural in the Python context, and so probably Collection is the closest word to use, but it's a little stronger than what I was originally imagining.
 
wim
10:01 PM
so much for "one obvious way to do it" ... there are 5 wildly different suggestions here, and FOUR of them are good
@DSM That's a set, or possibly a "bag"
 
> Context managers are just syntactic sugar for try/finally:
it's a bit more than just syntactic sugar, unless our notion of syntactic sugar is different
 
wim
...
show me something you can do in a with statement that you can't do using try/finally, and i'll show you a surprised man
 
10:17 PM
but doesn't it do something else, like call some cleanup methods or whatnots?
I might just be being pedantic again :P
 
I think <> survives today just in BASIC (Excel, VBA) and SQL.
"One obvious way to do things" is only obvious to one.
 
my point is that when someone says "X is syntactic sugar for Y", I imagine that the two are the exact same. Such as "@decorator \n def function(...) is syntactic sugar for function = decorator(function)"
 
wim
I call syntax sugar is something that's not strictly necessary for any new feature in the language, but makes it nicer for developers
arguably everything is syntax sugar, we could all write in machine code instructions ;)
 
Considering how bad for you sugar is, can we come up with a different name for constructs that are better than the alternative but are still technically just a shortcut?
 
hmm what would be the correct type annotation for a "callable" of the form fun(x:str, y:int, *args, **kwargs) - where args and kwargs can by Any - Callable[[str, int, Sequence[Any], Mapping[str, Any]], None]?
 
10:30 PM
syntax honey
 
@KevinMGranger syntax stevia?
 
as long as it's not xylitol
 
Isn't all of every high level language technically syntactic sugar?
 
Hi o/
 
10:36 PM
Python is just syntactic sygar for Python bytecodes, etc. C is just syntactic sugar for assembly language, etc.
 
@Bálint hey:)
 
May I ask a question?
 
if it's python-related, sure ;)
 
Ok.
So, if someone (me) asked you about what's the main use of Python, what would you say (aside from the pretty obvious server stuff)? What do you use it for on a daily basis?
 
@Brandin A language has nothing to do with the way the code is executed. - I can write completely valid python code without there EXISTING even C/assembly language...
 
10:40 PM
It's a generic high-level language with a vast collection of standard and third-party libraries that make it applicable to almost anything :P
 
I want to lecture programming next year, and I lean heavily towards Python as an example language due to it's simplicity and the forced indentation.
 
I use it for post-processing scientific data
 
Python is a mostly good way to start teaching people to program. Just make sure to use 3 and emphasize that they have to look at 3 resources.
 
yes, python == python3
 
@Andras Are you Hungarian BTW? Your name make it seem like you are.
 
10:41 PM
((and indentation == 4 spaces ;) ))
@Bálint I happen to be, yes :D
 
@AndrasDeak That's basic. Good to see a someone with the same nationality.
 
Well if you wish to lecture programming just state: "we use python for learning". I myself use it daily during education: it is completely outclassing matlab, with only "legacy" stuff still being in matlab.
 
there's a few of us around
 
Python 2.7 is just fine. Most important is to use whatever your colleagues are using. If you are programming in a team of one, use Python 3. Otherwise use what your team is using.
 
it's not "just fine" when the language ends its life in 3 years
 
10:44 PM
@AndrasDeak how would a programming language die lol?
 
It means its stable. Python 3 keeps adding new features. YAGNI.
 
Bálint is trying to inform himself of his options
Of course it won't die because some people will never be arsed to migrate to 3 and some people will teach newbies that python 3 is shit
 
When I started learning Python I looked at some online materials, just to get a grasp of it. The first one was the learnpythonthehardway.something online book. I quickly realised that it isn't great after the third time he wrote "Don't listen to others, it's fine"
 
@Bálint oh yeah, no no no no on learn python the hard way:/
the official python tutorial is great if you already know (C/Java-type) programming
 
Well I'm forced to use python 2.7 for anything official; since "python 3.x doesn't support backwards compatibility, and hence updating might mean software taught is outdated during examns"
 
10:47 PM
I luckily have both, and I'm pretty confident in Python now
 
wim
@paul23 pffffff
 
No, Python 3 is certainly not "shit". But I honestly don't see what's so bad about Python 2. It still is maintained and bug fixed. To me that is pretty awesome. If it is still used in 3 years, then with all likelihood it will still be maintained.
 
> It still is maintained and bug fixed.
for 3 more years
then it's up to cultists to continue
 
I really don't want to teach stuff like Java or C# because of the forced OO, and C++ is out of the question obvioisly
 
wim
updating might mean software taught is outdated during examns and the alternative is that the software taught is already outdated when you learning it
 
10:48 PM
software taught is often like that, is it not?
 
Hey our university even finds "python 3 better, it's just the lack of backwards compatibility that prevents us from updating without having enormous costs each time".
 
That's not true. When I took my first course in Fortran 90--... oh.
 
JavaScript would require me to teach them some HTML they don't understand or use Node for the same reasons.
 
"Each time"? What? You update once.
 
@Bálint python is great, although if it's a first language for the students, it might leave them ill-equipped when they later meet more mainstream languages such as C++
 
wim
10:49 PM
what enormous costs could a university possibly have for updating the language version
 
I was just about to mention-- if they're going to move on to lower-level stuff, introduce them to __slots__
 
@Bálint What kind of program is this for?
 
wim
it's not like you have millions of users and an SLA
 
@KevinMGranger And then comes even a newer version of python, 3.7 that might once again not have backwards compatiblity...
 
That would be python 4. And they've said there will not be a python 4.
 
10:50 PM
@wim where I'm from it all depends on the lecturers, and academics are...academical
@paul23 that's the worst kind of FUD
 
@Andras I want to teach them programming (aka. CS), not a particular language, but it's required to learn a language too, or else you get the "learning to swim from books" problem
 
@KevinMGranger It's not my opinion that matters - it's what our university decided after 3.0 release, and we'd have to go through the board (takes about a year of pressing onwards) to change this stance.
 
@paul23 it's fine if you keep using python2 for valid practical reasons, but this smoke-and-mirrors thing is not a valid reason
 
I just teach them 3, it seems more consistent to me.
 
@Bálint if you teach python, teach 3 :)
that's the language that will be maintained
 
10:53 PM
Ok, I think I got my answer. I should probably go now, but I definitely come back some day, this chat seems nice.
 
btw to be frank: if you wish to teach them "how languages work internally - together with the computer" that really shouldn't be done "in" python.
 
@Bálint see you later, then!
 
I think C is actually the best way to explain memory (pointers) etc.
 
my impression of CS is graphs and O(N log N)
is it computational science or computer science?
 
@paul23 I want to teach them the type of logical thinking you need to program.
@Andra latter
 
10:54 PM
hmm
 
Then, bye! o/
 
I see, thanks
\o
 
But in the end picking a high level language doesn't matter too much. It's like picking a model of car to drive. It's all the same nonsense over and over with slight variations.
 
might as well choose C++ :P
 
The most common reason to pick a language usually is basically "Some dudes wrote some shit in language X that I wanna use. So I'm gonna use X so I can use that shit to make my own shit." It's almost never language features or "Expressiveness" or something like that. Second most common reason is tools. "Some dudes wrote some shitty IDE that works well with language X, so I'm gonna use language X so I can use that IDE to its fullest, even though it is actually shit."
 
10:59 PM
the first reason is why "majority of people still use python 2"
 
"Humans benefit from the redundancy." It's true. Every morning I wake up and think "how can I make my code more redundant?". Because of the benefits. — ahoffer Apr 28 '15 at 19:23
heh
 
:D
I ruined the 42 upvotes
 
Java 8 lambdas basically gets around that issue unless you need to throw a checked exception.
 
#checkyourexceptions
 
#beforeyouwreckyourexceptions
 
11:07 PM
I can honestly say that python allows me to write much faster code than C++ or even C#.
 
that's what it was meant for
so that you can spend your time writing code instead of boilerplate
 
Write code faster, or write faster code? There is a difference.
 
hence "The *productive* programming cabbage"
@Brandin right, I read that as "write code faster" (obviously)
 
@Brandin Which costs more, people time or computer time?
 
Writing faster code takes more time. Usually you want to write code faster.
I don't care about costs. Answering question is a job for the bean counters, as they are sometimes lovingly called.
 
11:10 PM
and it often takes another language, or better computers
 
Sometimes I write something and just want to optimize it for some reason. Even if it doesn't matter at all. That's why we have useless things like %timeit in IPython to play around with code.
 
optimizing things that don't matter is the worst kind of waste of time :P
 
Sometimes its fun. Like getting a high score in Tetris or something. Just a number, but getting is still fun.
 
then it does matter
 
No, I mean it doesn't matter to the final product. If you ship the product without that optimization, the customer will never notice. => doesn't matter. Optimized just for fun.
 
11:17 PM
yeah, I guess that depends on how much time you waste on how much non-improvement
 
Maybe its just fun. Like plaing Tetris. You don't actually improve anything by playing that game. It is just for fun activity.
 
I can pack more efficiently thanks to Tetris
 
Still, I've heard that Python productivity starts to taper off when you get many people working on it. With just a few people doing something, it's fine. But with 15+ people at different locations...
 
The downside of expressiveness is that there's less area to spread out to work on, indeed.
 
Hmm is there anyway to force python to "throw if type annotation isn't corresponding to the given type during runtime"?
 
11:27 PM
I think there are 3rd-party libraries that try to do that.
 
something something then use a language where there are variables and not names ;)
 
Not during runtime, no. If you're looking for something to easily generate classes that do type checking on instantiation, there's attrs
 
Well it would make validation & testing a lot easier.
 
DSM
There's one point of my code where I decorate to enforce the type annotations at runtime, mostly because it's around some ctypes interfacing with a C++ library and otherwise it's possible to cause segfaults.
 
Heck I think going the route of: if a variable/member/parameter has a specified type annotation, it should become "static for that annotation", would improve python. - It would still be optional as you can just selectively use annotations - but using annotations and then violating it should be "badly written code that halts".
Why else would you use annotations if you don't adhere to it? (and you could always go: typing.Union[PreferedType, Any]
 
DSM
11:37 PM
Given the trajectory of Python over the last few years, I fully expect runtime type enforcement to become a Thing.
 
Errybody adding static typing!
 
Well to be frank: that single thing has been a long time annoyance in python. (That so little code is annotated, and hence for non obvious debugging I first ALWAYS add print(type(X))
 
DSM
We're adding static typing; other languages are adding variant; we're all becoming One. Except for Lisp, which will look still down and laugh.
I teach beginners that print(type(x), repr(x)) should be the first step and sometimes refuse to look at code until I see the output..
 
and if it prints a tuple then they failed
 
DSM
Heh.
 
11:44 PM
there was a funny bug in matplotlib up to version 1.5.1 wherein some segmented colormaps would have their .name and .colors were swapped (among other errors)
so cm.colors was actually a string with the colormap's name in it and cm.name was the color array
now that's one of the cases where type checking would've helped
 
Well the biggest "drawback" that enforcing runtime type checking could create is that you get "peer pressure" (cough stackoverflow, cough) to always add type annotations. - And this will slow you down, no denying there.
 
yeah, I don't use python so that I can write final static void magical fancy unicorn function(something something something oh here's the variable name one)
 
DSM
Oct 11 '16 at 17:26, by DSM
I'm on record as being willing to take good odds on the fact that the "we don't intend to make putting type declarations everywhere the new default" promise isn't worth the paper it's not printed on.
 
but I'm lucky that whatever I use python for, I don't need anything like this
 
There's so many negatives there that's hard to parse
 
11:52 PM
Though at a certain point when an application gets more and more complex interactions adding the type-annotations would keep complexity low(er).
 
whenever the BDFL agrees to force type declarations, it'll be time to stage a coup and start a democracy
and hire Barry the FLUFL in the interim
 
DSM
I don't think it'll ever be forced. But first it'll be best practice, and then it'll become conventional.
 
best practices are the worst
 
pep8!
 
so don't type declarations conflict with duck typing?
I'd have to tell whether my input is bool or numpy.bool_ which are apparently unrelated, right?
 
11:54 PM
Sort of. I wish there was an easier way to define an "interface"
 
@AndrasDeak Type annotations are more like "contracts" in python: you annotate a type is an iterable.
 
But if your old requirement was "this argument just needs to support these 4 methods and also __bool__", there's no way to express that with annotations.
 
Yeah, the typing-module could do with something to "extend" the types better with things like "type needs to have __bool__"
 
@paul23 ah, right, you can be broad about it
so we need duck type declarations
 
I find adding types to old classes also a good way to review code and spot errors :P.
 
DSM
11:59 PM
To be fair, I have caught errors in programs by cythonizing them, which is kind of similar in spirit.
 
you can spare all this work by writing code that just works
#themoreyouknow
 

« first day (2348 days earlier)      last day (2609 days later) »