« first day (3301 days earlier)      last day (1872 days later) » 

 
1 hour later…
wim
wim
05:57
I wonder why jpp suddenly stopped answering in Feb 2019? This user was an extremely active answerer in before that.
06:48
Hey guys, general development question here, should you commit your sqldump files to version control? For recreation of databases? Or is that a bad idea? Where should you keep your sqldumps and how should you distribute them?
07:11
October 23:
> Dear GitLab User,

We have launched important updates to our Terms of Service surrounding our use of telemetry services. Starting with GitLab 12.4, existing customers who use our proprietary products (that is, GitLab.com and the Enterprise Edition of our self-managed offerings) may notice additional Javascript snippets that will interact with GitLab and/or third-party SaaS telemetry service (such as Pendo).
October 30:
> Dear GitLab users and customers,

On October 23, we sent an email entitled “Important Updates to our Terms of Service and Telemetry Services” announcing upcoming changes. Based on considerable feedback from our customers, users, and the broader community, we reversed course the next day and removed those changes before they went into effect. Further, GitLab will commit to not implementing telemetry in our products that sends usage data to a third-party product analytics service. This clearly struck a nerve with our community and I apologize for this mistake.
that's not something I'm used to seeing here :P
> So, what happened? In an effort to improve our user experience, we decided to implement user behavior tracking with both first and third-party technology. Clearly, our evaluation and communication processes for rolling out a change like this were lacking and we need to improve those processes. But that’s not the main thing we did wrong.

Our main mistake was that we did not live up to our own core value of collaboration by including our users, contributors, and customers in the strategy discussion and, for that, I am truly sorry. It shouldn’t have surprised us that you have strong feeling
it's almost as if companies were able to listen to their users
@wim woa, that is one salty comment section twitter for sure. go 🐍!
Nov 16 '18 at 0:41, by jpp
When I get to 100k i don't plan to FGITW, will just wait for questions that either interest me or haven't been answered. We all need goals :)
07:27
@wim no swag after 100k
then again, I heard they've stopped handing out 100k swag these days
"Hey, could you invest literal hours of your expertise every single day over a couple of years into this one website here?" "What do I get?" "A cool cup and a shirt." "Deal!"
programmers are strange
*looks at the 4 PRs I made this month just to get the hacktober shirt*
You're forgetting the part where you have more expertise at 100k than you did at 1 :P
whether that's thanks to all the time you sank into the site or not is up to you
that's just a bonus
cbg guys o/
@Arne why do people contribute to open source projects? Same principle :P Except here you get free internet points as a bonus
07:37
@AndrasDeak oh, and the apology is signed by "co-founder and CEO". Go figure.
Finally I wrote that pojo in Python blog
Any feedback is welcome
Not quite sure what you're referring to there.
Are you asking me?
@cs95 to be fair you haven't been around
yes, a link for out of touch folks like me would be helpful :-)
07:40
@Arne @cs95 Check my website instead: igaurav.xyz
not yet, just the regex one
Yes this one
I respect people who write helpful blogs like these. Unlike stack overflow, there is no visible gratification system (i.e., no points) and you're just doing it out of goodwill. A lot of times, blog posts tell you what crappy/nonexistent documentation doesn't
I learned more of Angular through blogs than the actual docs
Thank you :)
I wrote few more on other topics..
One thing that might be a good idea to include in that blog might be python dataclasses. did you consider it already?
07:47
Oh so python terminology is dataclasses?
not really terminology, it's just a module name docs.python.org/3.7/library/dataclasses.html
I'll brb after lunch
@Arne Thanks, will check that
New close reasons are disorienting...
looks like an improvement to me tbh
in what way? :P
just softer wording
07:54
I think phrasing it less like a fact ("unclear") and more like something actionable ("needs clarity") will hopefully make more OPs actually edit their questions
Are these the same closure reasons displayed to the OP? In that case I agree
Not sure (I'm in the wrong A/B group), but I assume so
@cs95 Pretty much. If you have constructive criticism you can post it to meta.stackexchange.com/q/337013/334566
Yesterday, I noted that "typo" had been removed from the "typo / no repro" close reason. Andras complained about it, and the devs have put "typo" back in.
is there some way to define install requirements conditionally with pyproject.toml/flit? So far we've had black installed as part of our test suite and skipped the run for PyPy3, but the newest version won't even install.
oh, there's a PEP for that...
08:13
came to mind
@wim Sure, the OP can see the names, but it means the casual visitors & askers with <3k don't keep seeing the same names over & over again on every closed post. I remember when I was still new being resentful of those guys who kept closing questions I wanted to answer... It turned out that many of them were Python room regulars, and were quite nice guys doing a necessary task. But I didn't really understand that when I had <1k.
@PM2Ring oh, cool! thanks =)
@cs95 At least they warned us it would be happening, and gave us the opportunity to provide feedback, both before the rollout and now.
@cs95 I can't reproduce the new close vote reasons
they're still in A/B testing. You're in the wrong group
08:19
Oh
You're too then:
21 mins ago, by Aran-Fey
Not sure (I'm in the wrong A/B group), but I assume so
@Kevin Have you ever worked with Epub files? They're a zip of XML + (X)HTML files. The format is fairly flexible, but the 1st file in the zip must be the mimetype file, and it must not be compressed. That way, readers can detect Epub files without decompressing them. Maybe your file format has similar restrictions.
@PM2Ring Sure. The dumpster fire is in reference to everything that's been going on over the last few weeks, particularly with the CoC changes and Monica's firing.
@cs95 Ah, right. "Let's just pretend everything's normal, and roll out a minor facelift for the site".
Bruh. i just told someone to provide a min-reprex and he said something like "stop write s**t, please answer my question!", anyway, i flagged it and got removed in a sec...
08:40
@U10-Forward This one stackoverflow.com/q/58621127/4014959 ? I don't know Windows, but my guess is that the OP needs to install Tcl.
@PM2Ring You're a mod so you know :p yeah it's that one
Yeah
I am not going to answer it since he said "s**t" to me
@U10-Forward I'm not a mod, just an owner of this room.
@U10-Forward Fair enough. I don't like to help disrespectful people either.
@PM2Ring Uh you resigned?
OTOH, that question doesn't need a MCVE.
Or you were never a mod.
@PM2Ring i sent it before he revised
08:44
@U10-Forward No. I've never been a mod. I've never wanted to be a mod.
Oh, than i mixing up with someone else than...
That guy got an up-vote as well....
Ugh
user10984358
09:07
Is there a difference in using “ substring in string” and “substring==string” if string and substring are the same?
Uh, no? Both evaluate to True
user10984358
Performance wise? I was wondering if “in” used some substring algorithm to check and == had something different ?
Not sure, but == is probably faster
user10984358
Thanks
If performance matters, just use True
user10984358
09:13
True?
@U10-Forward Ok. You should probably delete those comments now, since they're no longer needed.
Yes, if both strings are the same then the result is True. So just use True.
And if the strings aren't the same, then both snippets do different things. So use the one that does what you want.
user10984358
I still have to see if the strings are same don’t I?
If you want to see if they're the same then you can't use in.
>>> 'a' in 'ab'
True
user10984358
Word boundaries thing yeah I came across this
user10984358
09:18
It’s better to use startswith if I know the substring comes first?
@TheNamesAlc Maybe you should explain what you're actually trying to do.
user10984358
I want to see if an xml tag’s content has something of the form “DEVx+ON” where x=1,2,3... so the tag would be <tag>DEV12+ON<tag> or it could be <tag>ON</tag> so in the second case it must be a false.
Then I'd use startswith and endswith or regex if you want to validate that the text inbetween is a number
I got this close to rickrolling myself again
09:26
:D
10:26
@U10-Forward "min-reprex" in your canned comment is perfectly needless if you ask me
Welcome to Stackoverflow, Please provide a Minimal, Reproducible example (min-reprex), and show us what you want, what you're currently getting, or your current error message, and what you've tried so far, also see How do I ask a good question?, and also see How to write a perfect questionU10-Forward 2 hours ago
(let alone the rest of the gratuitous formatting)
10:58
This new UI looks fancy: i.sstatic.net/CaEJd.png
Isn't it?
I'm looking for a language to write a little .exe in - I need to read an environment variable, do some string operations on it, write it back and start a subprocess. I'm leaning towards C because it's just so trivial to compile to an exe, but I'm a bit scared of doing string operations in C...
@Aran-Fey Why does it have to be a .exe?
I want to use it as a python interpreter from IntelliJ, and as far as I know that only accepts exes on Windows
Oct 22 at 19:41, by Aran-Fey
I'm trying to run my project with a linux version of python (installed in msys2) but IntelliJ keeps adding windows paths to sys.path
Ah, ok.
11:13
@Aran-Fey c++?
I agree that string operations in C can be tedious, but a simple search & replace isn't hard. Just make sure your string buffers are large enough.
Hmm, not a bad idea. I usually try to avoid C++ because it sometimes needs runtime dependencies, but since the program is only for myself that doesn't matter
It doesn't need to be foolproof. Just use big fixed sized buffers, eg 1kb.
I'm not sure if 1KB is enough to hold all the cruft that IntelliJ wants to add... ;)
user10984358
hey guys, how do you split a line by space and check for its length using the walrus operator?
if splitLine:=line.split() and len(splitLine)==4: tried this got
NameError: name 'splitLine' is not defined
11:22
probably requires parentheses around the assignment
@Aran-Fey So go with 4kb or 32kb. ;) But are you sure that will stop IntelliJ from mangling your PYTHONPATH? Maybe throw together a quick & dirty test, and if it works then you can optimise it.
user10984358
wow that worked , I was that person who would use () for all if statements until recently and now this happens :/
I'm sure IntelliJ will mangle it, but I'm planning to unmangle it
@Aran-Fey Maybe do the test, to verify that the mangling step actually occurs when you believe it does.
Yeah, I'll start by writing a basically empty program just to see if IntelliJ even accepts it as a python interpreter
11:25
@TheNamesAlc and probably has higher precedence than the walrus operator.
The next step will be printing the PYTHONPATH
Sounds good.
Shame IntelliJ doesn't give you an actual shell to do this with.
not sure what you mean. What kind of shell?
Well, in Bash you could do PYTHONPATH=some:path python myscript.py and Python would be launched with that path in its environment. You could even do search & replace to create that path if you want. And you could set the whole thing as an alias, so you could do eg, py myscript.py
11:41
ah, yeah, that'd be nice
Also, Linux doesn't care if a program is an exe or a script. The script just needs the appropriate shebang line & it'll be launched with the interpreter specified by the shebang.
I'd expect on Windows that anything which can launch a .exe should also be able to launch a .bat file. But I've never used Windows much, and it's a very long time since I messed around with .bat files.
11:57
@Aran-Fey I was very pleasantly surprised by Rust. Much less tedious than C/C++.
I was looking for some good blog on dataclasses, and found this link: hackernoon.com/…
My brother said it's hard to get started with Rust, and judging by what I've seen of it I'm inclined to believe him :D
Just scroll to bottom :D
12:11
@TheLittleNaruto Nice post, we recently converted to 3.6, so with a backport of dataclasses I'm now embracing these newfangled features all the cool kids are using
But the code samples are missing for me (Chrome on MacOS).
12:22
Hi all. I need some assistance in web scraping.

i have got let's say 10 <li> inside 1 <ul> and I just need to count the number of <li>. but it's giving me 0 as output.

This is what I tried:

for ul in bsObj.find_all("ul"):
for li in ul.find_all("li"):
count+=1
that code looks fine, so we'll need a Minimal, Complete, and Verifiable Example
cbg y'all
@Aran-Fey indentation was the error. Thanks
@MunishGupta - does find_all return a list or a generator?
@PaulMcG my intention was to total count the number of li tags inside ul. Not sure whether this answers your question or not
12:36
@PaulMcG It is nice post; however it's funny to see the author photo at the end of every paragraph.
If it returns a list, then just write count = len(ul.find_all("li")) instead of iterating over it. If it returns a generator, this is a little more work, but count = sum(1 for _ in ul.find_all("li")) would give you your count of li's
@TheLittleNaruto From the context, it seems like that's where the corresponding example code was originally shown. Probably got changed after it was up for a month or so, now you have to go to his site to get "the goods".
@TheLittleNaruto I used to refer to this blog post together with the docs to get the hang of them realpython.com/python-data-classes
@PaulMcG I see.
@Arne Realpython. com is good. I took example reference from it to make readers understand about kwrgs
BTW, Thanks Arne I'll add this dataclasses thing to my blog.
glad to hear it
12:43
we used it a lot in our applications where data transmission protocols were involved, and it made everyones lives a lot better
Yeah it got rid of those boiler plate codes
@PaulMcG "ul" unresolved refernce?
BTW Any other feedback? Arne.
Or is it all good? I tried to cover how much I could and which were necessary.
looked good to me. but I'm missing some background since I never did any data wrangling in anything other than python
so I can't say too much about the big picture
It's good when we are at client side i.e. receiving end. Mostly in case of Desktop apps built in Python.
Similarly pojo classes are useful for android/ios applications
13:48
Cbg
I have following python code:
s = socket.socket(socket.AF_INET, socket.SOCK_DGRAM, socket.IPPROTO_UDP)
s.bind(("", udp_port))
while True:
    msg = s.recv(1024)
And In wireshark I see a udp broadcast coming in on my port, but I dont get it in python
I found this: stackoverflow.com/questions/38106302/… but that wasnt helpful
Man it was the firewall :D
Writing docs for my serializer, should I first show how to load data (load(some_file)) and then say "you shouldn't do that though" and show best practices (load(some_file, expected_type=List[str])) OR should I only show the best practices?
Depends how come the other option is in similar tools. If people expect a to work I would start with it and say dont do that, if its a kinda new thing, just tell them how to do it right
come = common :D
@Aran-Fey i'd say best practices only. you can always preface it with "the recommended way to do X is this". But note that this is just an opinion, and should not be given any more weight than just that.
The python docs seem to go for the barebones code first, and then the recommended route. At least in this one example in any case
I can see a case being make for that kind of documentation too.
14:04
The thing is, my load function takes a lot of optional arguments. I'm going to document all of those on a dedicated page, but I'm sure if I just drop a link to that page below a code example, nobody's gonna click it. So I think I should teach people to use the expected_type argument from the start, because that's the bare minimum you need to be safe from unexpectedly deserializing dragons where you expected cute puppies
@Aran-Fey in psychology we learned that instructors should avoid to include examples of things that shouldn't be done, because humans are notoriously bad at keeping the "you shouldn't" part in mind
It's decided then, thanks
I think it's best to show users what they are supposed to do, and drop a link to docs they can click iff they are interested in details
Agreed, the times when people will link to the "dont do it" portion of a docs to claim that the docs recommend it is scary.
Though in my experience, it's not that they saw how not to do it, how to do it, and then mixed the two. It's actually a case of "oh, i never read that far. i saw what i needed, and got out."
Yeah, I made that experience with SO answers. People stop reading at only look at the first code snippet. But I thought maybe that doesn't apply to people who read documentation...
14:11
Im sure the average volume of users who read documentation would not show trends that are too far off, even if we think or assume that people who read documentation are more sophisticated or better programmers in general. It's still an underlying pattern of how people go through online material when "stuck".
wishful thinking is one heck of a drug
Haha, that's a succinct way to perfectly phrase it.
I don't think you need to worry about making the first example as simple as possible, since the majority of people interested in the example are going to copy-paste it without reading it anyway
Source: I do this constantly with third party libs
It's only 1 line long, so I can afford to add a little bit of optional code no problem
Not being consistent about best practices would probably be more confusing in the long run anyway
14:31
Apparently sphinx's autodoc extension doesn't show the base classes of exceptions. Isn't that just great. The exception hierarchy isn't important anyways, right? Ugh.
I used to think that if I want to dynamically add a method to a class, all I need to do is C.myfunc = myfunc and then C().myfunc() will work correctly in all cases
But it doesn't work when super() is called in the function body =/
wim
wim
@Arne mcve?
Sounds right to me. IIRC zero-argument super uses a tiny bit of black magic and it only works if the __class__ variable exists in the scope where you call super. It exists inside a proper method, but not inside a function that you're going to attach to the class later.
wim
wim
@Arne wow, no joke
class test:
    def print_hi(self):
        print("hi")

def print_bye(obj):
    print("bye")

test.print_bye = print_bye

class child_test(test):
    def __init__(self):
        super().print_hi()
        super().print_bye()

obj = child_test()
14:45
Beaten, but have an mcve anyway dpaste.com/2AS3YTX
#output:
hi
bye
So im confused, did i miss something
wim
wim
looks like it works to me...?
Your code works because you only call super() within a class definition
In my code, I call super() inside a regular function, so it fails
wim
wim
maybe you meant using super inside the function that got monkeypatched on?
Sorry, strange request. if your code is short, could you paste it here?
(dpaste blocked.) :P
Or a gist works if that's not too much of a hassle.
14:47
class A:
    def troz(self):
        print("troz", self)
    def zort(self):
        print("zort")

class B(A):
    def troz(self):
        super().troz()

def zort(self):
    super().zort()

B.zort = zort
B().troz()
B().zort()

"""
troz <__main__.B object at 0x027AF270>
Traceback (most recent call last):
  File "C:\Users\kevin smiley\Contacts\Desktop\test.py", line 17, in <module>
    B().zort()
  File "C:\Users\kevin smiley\Contacts\Desktop\test.py", line 12, in zort
    super().zort()
RuntimeError: super(): __class__ cell not found
I used dpaste because my usual choice, pastebin, is blocked for wim. I guess I should find a service that both of you can access.
wim
wim
ah, I think Arne just discovered the Schrödinger's variable. A great reason to hate super.
Oops, that <__main__.B object at 0x027AF270> output is from a different version of the code. Ignore that part.
sorry, had to go for a couple of minutes
class D:
    pass

def foo(self):
    return f"foo: {type(self).__name__}"

def bar(self):
    o = super()
    return f"bar: {o.__name__}"

D.foo = foo
D.bar = bar
d = D()
print(d.foo())  # works fine, self gets resolved properly and all
print(d.bar())  # RuntimeError: super(): __class__ cell not found
yeah, 0-argument super only works in functions that are defined in a class
Now, i feel bad, i've been touting super as the way to access parent attributes.
14:50
You can still use two-argument super() just fine, if you're dead-set on continuing with the functions-as-methods design
wim
wim
It works if you use 2-argument super
Kevin'd
gotem
wim
wim
I wonder if the one arg super in a function should be an error at function definition time
because that's when the class cell is searched (and, presumably, fails in some dank C code somewhere)
@cs95 True! SO is great to improve your technical communication skills. Looking back I really used to waffle a bit, now I realize just how important it is to get to the point.
@ParitoshSingh that should still hold, patching methods at runtime is strange enough that it shouldn't influence best practices
it's super reasonable and not hacky at all in my case though since I'm working with dataclasses. the code is bound to be freaky
14:57
Based on the first code block of stackoverflow.com/a/36994027/953482, it probably wouldn't be too hard to make the code raise an error when you define a function that's using super when it shouldn't. I assume GET_IDENTIFIER is checking to see if __class__ exists in an enclosing scope, so it would be easy enough to determine that you're calling super() when you're not in a class.
I never thought about it, but I guess this explains why cellvars are mutable. The __class__ cell has to be populated after the class was actually created
wonder which part of the class creation process is responsible for that...
github.com/python/cpython/blob/3.5/Python/compile.c#L550 creates the cell and puts it in cellvars, but I have no idea where this function is being called from
wim
wim
compiler_enter_scope would suggest entering a class block or entering a def block
@Aran-Fey why? I don't follow that argument
I think in this case it's when it enters the def, since that's the scope that super() is going to look in
@wim The functions are created before the class is, so the contents of the __class__ cell has to be mutable
wim
wim
15:08
hmm.
I'm kind of fuzzy on how cells actually work, but I think it's possible for the bytecode compiler to tell the function scope "hey, there's going to be a variable named __class__, and it will be accessible at this position, but it doesn't exist yet, so don't look for it right now"
...though of course closure variables can be reassigned, so that too explains why cell contents can be reassigned
wim
wim
not too sure about that
def foo(): super().bar()
how do you make foo() succeed by putting a closure variable or an enclosing scope?
I think it's probably too late, since the cell var is looked up at defn time, no?
(lexical scoping)
foo.__closure__ is None, so yeah, I don't see a way to fix it
wim
wim
so, if you can't successfully monkeypatch it, why shouldn't it be an error at defn time?
15:16
What kind of error would that be? SyntaxError? Doesn't really make sense, does it?
wim
wim
Haha, I know why. Because you can rebind super
It’s just a name, not a syntax
This implementation is lame
All methods should have the __class__ cell tbh
hi, i have a question which may be childish... so I am sorry before...
I have written about 1500 lines of code. it is too messy and I want to break it into some subcodes. and I make a main python code and only run it. can i do this?
please give simple answers, i am not as professional as you...
@EnthusiasticEngineer yes, define functions
I have lots of inputs... how should i join them...
cant i stick these parts together?
15:31
with 1500 lines of code it'd probably be a good idea to split it into submodules, but I don't want to have to explain how to correctly structure and install a project
thank you. can you give me a reference for it if you have no time... so i can read it myself
I'm not sure if a correct and good reference like that even exists
ok. thank you
In fact I'm not even sure how to correctly install your own project because I've never done that
regarding the method patching I asked about, behold my needlessly complicated solution to a question nobody cares about any more: stackoverflow.com/q/58532383/962190
15:39
Google results came up empty, so here's a TL;DR: Make a directory that contains all the modules you want to import. All python files that you want to execute should be outside of that directory. Here's what a typical project structure looks like:
project/
    .git/
    project/
        __init__.py
        module1.py
        module2.py
        ...
    tests/
    docs/
    main.py
Assuming main.py is a file you want to execute
What I don't know is how to correctly make your project importable. Is it pip install -e project? And does that require a setup.py? I have no clue
wim
wim
15:52
main.py outside of package is lame
just define a main() somewhere inside the package, and set up a console_script hook in the package metadata.
project/
    .git/
    project/
        __init__.py
        module1.py
        module2.py
        ...
    tests/
    docs/
    pyproject.toml
^ better
inside the pyproject.toml you will have some metadata like:
[tool.flit.scripts]
myscript = "project.module1:main"
I didn't want to go that deep into packaging stuff, but I guess it's better than having a half-assed project
@Arne That's a relief. Makes sense
wim
wim
the actual structure of this section may depend on what build system you use, the example I showed is specific to flit.
if you use setuptools its in a separate setup.cfg file instead, and looks like this
[options.entry_points]
console_scripts =
    myscript = project.module1:main
@Aran-Fey well, you basically have to go into packaging. otherwise main.py won't be able to import the library code. pip install -e project will not work with the structure you showed.
Can I do something in a lambda function without returning it?
Weeeeellllll.... lambda: (func() or True) and None
16:02
yes. note that whatever you're thinking of is probably not a good idea.
ok, I am trying to debug
lambda: [func(), None][1]
so I wanted to print a value and return something else
wim
wim
then just use a def
and why lambda?
what wim said.
16:02
ok that works too
in js you can doing something like (x) => console.log(x) && x > 5
is that allowed in python?
wim
wim
what made you want to use a lambda for this? out of curiosity
im glad this isn't js. (but yes it's allowed in python)
the docs use lambda
wim
wim
what docs
I'm always puzzled why some people want to use lambda for everything and trying to figure out the source of that desire
ev3dev
I'm new to python.
16:06
From The Google: ev3dev = Lego Mindstorms mini-Debian
I have experience in other Langs tho
Ok, so lambdas are okay for simple function arguments that you might pass to sort or groupby (or filter or map if you are using them instead of list comprehensions - but use the listcomps), especially when they evaluate a simple predicate or value.
and especially when you need to use it once and throw it away
The problem happens when they get abused and begin to encompass multiple continuation lines, do crazy multi-statement tricks using "or", get knotted up with using args that reference nonlocals that change out from under the lambda, etc.
BUT - if this is a throwaway debugging line that is not going to be left in, you can do what you are asking, with something like lambda x: print(x) or x > 5. This only works with Python3, when print was converted from a statement to a function that returns None.
wim
wim
is console.log(x) truthy in js?
16:11
is None truth?
@wim yes
wim
wim
weird
Since print() returns None, print(xxx) or somethingelse will go ahead and evaluate somethingelse and return it as the lambda value
everything is truthy in js (except if its falsy)
@wim weird doesn't even BEGIN to define how deep the rabbit hole goes
js lets you run 600 lines of code without complaint with a missing input
wim
wim
leap before you look?
16:12
it just spits out undefined after undefined, and happily keeps chugging
just leap. who cares about looking.
wim
wim
class A:
    def bar(self):
        print("hi")

def foo():
    super().bar()

# your line of code here

foo()
^ super-lame puzzle: make foo call the method
stop complaining about js without know the why
So @JBis, please use this sparingly, it is definitely a discouraged practice - handy in a pinch for debugging, but nothing you'd like to leave in place
ok good to know thanks
16:15
I think a lot of JS's "why?" questions are answered by "JS was designed for tiny scripts on HTML pages, not actual software engineering"
Sounds like you don't like me complaining about JS. for what it's worth, this is my experience with it, and I, by no means intend to target you while talking about it. If you feel like that was targetted at you, im sorry, wasnt my intention
I know you aren't targeting me
But I don't want to get into a 20 min argument about js lol
We are in agreement on that then :)
wim
wim
@Aran-Fey correct
16:20
Wait, for real? I'm not adding this one to the riddles page ;P
wim
wim
too beginner for you :P
@Aran-Fey node.js: hold my beer
Compromise: I'll add it if you write a paragraph for the "explanation" section for me
...or maybe I should just delete that section
@wim yeah this
front end js sucks
node is good tho
if I grab a number from standard input using input() can I use it directly in a comparision (< > == etc) or is it a string that I have to cast as int first?
16:37
@erotavlas try it
fine :P
Y'all need a python eval in this room
(Depends on the python version)
so it hangs at my if statement

threshold = input()
if 1 > threshold:
  print("greater")
else:
  print("not greater")
I entered 0.8
and I'm using python 3.6
by "hangs" you mean "crashes"?
16:42
in debug mode in pycharm it just doesn't continue or crash
oh nevermind theres an exception - '>' not supported between instances of 'int' and 'str'
@erotavlas print(type(input()))
ok that answers my question, personally I thought it would work though
Sorry for the pings
@erotavlas this came up recently
@erotavlas It'd work in Python 2, but it generally wouldn't do what you expect.
2 days ago, by Anarach
When taking a user input why does python default to assigning values as str instead of the appropriate int or float type
See discussion there ^
16:46
ok
In Python 2, 1 > "0.8" is false, because "str" > "float". I hope you understand why that "feature" was removed in Python 3.
wim
wim
@Aran-Fey it doesn't need to be added
too late
@JBis Although this is the Python room, many of the regulars have a lot of experience with JavaScript (although some of us may be a little rusty). We discourage language wars in this room, but the occasional constructive comparison of language features is permitted.
wim
wim
> although some of us may be a little rusty
was that a rust pun?
16:53
is this better than using eval directly on the input()?

import sys

inp = input()
threshold = 1
try:
  threshold = float(inp)
  if 1 > threshold:
    print("greater")
  else:
    print("not greater")
except BaseException as error:
  print("Error 1: Input cannot be cast as float", sys.exc_info()[0], error, inp)
Sometimes, people will vent, & make a negative remark about a language. That's ok too, as long as it doesn't turn into an extended rant.
wim
wim
@Aran-Fey ok. well riddle #26 is even lamer, so ... shrugs
@wim Alas, no. Just a reference to the fact I've barely touched JS in 5 years or so.
Can you come up with a better riddle showcasing how imports can import either existing attributes or submodules though?
wim
wim
it's just a feature
people do from mod import attribute all the time, not sure why someone would be surprised by that?
16:59
I suppose it does only really get interesting when you have a circular import
@erotavlas use the specific error (ValueError?)
i.e. when you're trying to import from a module that is currently being imported

« first day (3301 days earlier)      last day (1872 days later) »