« first day (4110 days earlier)      last day (824 days later) » 

3:35 AM
@Aran-Fey Yes you can use sum() function to sum and divide the sum by using len() function
 
 
4 hours later…
7:31 AM
Does ngrok works for non website services like python socket server. I want to connect socket over internet. But I don't have a wifi
 
8:28 AM
@Huzaifa If you're trying to calculate the expected value for the sum of two dice, then you need to use product, not combinations.
from itertools import product
pairs = list(product(range(1, 7), repeat=2))
print(*pairs, sep="\n")
mean = sum(u + v for u, v in pairs) / len(pairs)
print(mean)
# Output
7.0
To save space, I didn't include the output of the 1st print call. ;)
 
8:44 AM
I can't find a library that can parse MIME strings like "text/html; charset=UTF-8", that's crazy
 
9:30 AM
@AndrasDeak might want to also add c.TerminalInteractiveShell.autoformatter = None
 
9:59 AM
I don't really understand the utility that bringing black to the REPLwas supposed to have. I might be a bit jaded in general because I block any PR that runs it over my tooling libraries just because of how it explodes pandas code. Still, it's a shame that Hettinger's twitter spiel might have cost IPython a core contributor :/
 
Maintainer at that. Hopefully it's only temporary. In any case Carreau explained some of the rationale, and that it had been optional for more than a year.
 
10:38 AM
@Aran-Fey Pretty sure there's something in the email package ...
 
I can see a mime class, but nothing to create one from a string
 
In which case maybe a CookieJar could help? Thought you wanted to parse them?
 
Is "parsing" different from "creating one from a string"?
 
10:54 AM
Not to my knowledge
 
11:15 AM
@roganjosh Have to second this and one-up the warning. We have YAML as the configuration for our entire compute center and even experienced, trained people regularly screw up. It's very easy to have minor differences completely change how YAML parses something.
 
Why not change it then? *cries in scientist*
 
When I was starting out, I foot-gunned a few times with it. I've actually been using a Config class for all my tooling projects and I quite like it. I use a lot of @property and setters to try catch bad settings because the problem gets dispatched off as JSON into C++ and Java servers... and it's not so easy to propagate sensible errors back to the user if they mess up the settings. Not very pythonic, really, but I have a better grip on what the user sees
 
Which part isn't pythonic?
Or just the specific implementation?
 
Well, this config object has 400 lines of getters and setters. I'm inclined to think that's not generally the pythonic way by strict definitions. I don't care either way, I just anticipated people shaking their head at my implementation
 
Unless it's methods called .get() it's fine
 
11:23 AM
In which case, I've just been overly defensive of my approach, waiting for someone to pounce on me :P
 
@AndrasDeak *mumble mumble*Ruby*mumble mumble*Puppet*mumble mumble*
 
You mean RUBY?
 
I reserve all-caps for RUBY PROGRAMMERS.
The languages is somewhat nice.
 
Heh
 
If you can get past thinking "I wish this were Python" every 7 seconds.
 
11:27 AM
I use it for automated CHANGELOG generation. That's the sum total of my Ruby experience
 
@roganjosh things like config.kiki_penalty = 42 with diligent validation is very much a pythonic API in my opinion
 
I also use it to flip other settings so it works well. Tbh, I've moved away from TOML/YAML/JSON for config just for that kind of functionality
 
those screams are more questionable though :P
 
I wanted to try pydantic in front of YAML/TOML but haven't got around to it yet. :/
 
Incidentally, you've pulled me on that before, Andras :P
 
11:34 AM
kudos to me!
 
They are, effectively, globals though, and they have a 1-to-1 pairing with the library I initially started with
 
They aren't, though. They are instance attributes.
You know what they are from config.
 
Not when they get to the backend
 
I don't understand that but I'll take your word for it
@roganjosh it's exactly pythonic to provide a sane python API that hides the shouting. All other things being equal.
 
I think you could be right tbh, but once it gets dispatched to the servers, they become global settings on how the solver will work. In any case, I don't think it bothers me in the grand scheme of things
 
11:39 AM
Yup
 
They come from the fact that it initially just wrapped this
 
Yeah, I'd hide that
You can deprecate the old API with fallback from the new :P
 
Controversial opinion: I actually like the shoutiness. I'm also not going to break everyone's code to go back through the config and make it less shouty. I surprise myself on how I can pass this when I get palpitations if I see code going over the 80 character limit line
When it was just me and one other guy in our "pod" (we split people into working groups based on category of problem) I also have the quote: “If you can’t handle me at my WORST_BEST, you don’t deserve me at my BEST_WORST” - Marilyn ‘Pilko’ Monroe. That helped cement it in my mind, I guess
 
@roganjosh fallback to the new API is about not breaking everyone's code
@property
def FORMERLY_SHOUTY(self):
    """Deprecated in favour of formerly_shouty."""
    return self.formerly_shouty()

@property
def formerly_shouty(self):
    """Do the thing... softly."""
    pass
you don't even have to raise a deprecation warning if you don't want to litter downstream, just make the shouty API undocumented
 
What does this buy me?
 
11:53 AM
Being able to use the non-shouty API going forward, with the hope of the old API being gone two years from now. But this all assumes you want to use the pythonic version.
If you prefer the shouty one then this is obviously pointless, even harmful.
 
I don't mind the shouty aspect of it tbh. It's also a lot of work when stuff is embedded and multiple libraries/servers have to be able to communicate. I really do consider them to be global settings in the first place, even if they don't fit your traditional notion of a global variable
I honestly thought the getter/setter pattern would be more controversial rather than whether the parameters are in CAPS
 
Standalone getter/setter methods are the anti-pattern. Because properties are the idiomatic design.
You have to set attributes somehow.
 
 
1 hour later…
1:05 PM
Someone Like You came up on YouTube... the date is 2012. Now I officially feel old. That was a decade ago?!
 
1:37 PM
@PM2Ring TypeError: 'list' object is not callable
 
I don't see any surprising function calls in there. Try copy-pasting that code.
You probably named a list list. Restart your shell.
And don't overwrite built-in names like that
 
okay
 
 
3 hours later…
4:54 PM
Sites can hide rep and badges on Q&A pages meta.mathoverflow.net/questions/5218/…
 
5:04 PM
I rely on user reputation to know the credibility of an answer on first sight
 
You shouldn't
It's a very unreliable metric
 
Just one of the criteria
Basically many new users spam answers without any knowledge on the topic
Like this new answer for example. For a minute someone might believe it is true, but it is not even close
 
So downvote it @CoolCloud. You're happy to bring that to our attention but not use the mod tools available to you?
 
@roganjosh Wasn't bring anything to attention here, was just explaining that I judge an answer also by its reputation.
 
5:20 PM
"Wasn't bring anything to attention here" what do you think linking questions/answers here does? Do you honestly expect a room of programmers not to follow that up?
 
@CoolCloud even if you weren't trying to bring attention to it here, you should downvote what you yourself think is misleadingly wrong
The one thing reputation can reliably convey is access to moderation tools. Downvotes are the most important moderation tools tied with close votes. You need 125 rep to downvote. You have 100x that.
 
Yea I should've downvoted it immediately, I surely will, soon.
 
RIP that 1 rep in a pointless ranking system
 
I guess the 1 rep is just to advice against serial downvoting?
 
I think it's more about making sure you have conviction in voting against someone else's effort. What does it matter? The answer is wrong; you're happy to tell the chat room that but we have to wait for you to act on it
 
5:33 PM
@CoolCloud Yam, now I wish there was a 1 rep cost for upvotes too...
 
Only if it were there.. :(
 
I'm sad. I could get away with relatively low-effort questions thanks to my 30k rep. Now people are gonna start asking me "What have you tried?"
 
"Asking on SO" doesn't count, does it?
 
Have you tried @Aran-Fey? ... I'll see myself out
 
@Aran-Fey I doubt that they will enable that on SO
 
5:56 PM
Another riddle: where is something printed when it isn't on stdout nor stderr? I don't know the answer to this one :|
It originates from something called cerr (but not the cerr) in C++ code.
scratch that, I think it's an alias for std:cerr
Why is there a library called py??
 
Appending type() of one list to a new list using append(type(lst1)), it gave me [<class 'float'>, <class 'int'>, <class 'str'>, <class 'bool'>, <class 'list'>, <class 'dict'>]. Can I have it without class and <>, just int, bool, str, etc?
 
@Huzaifa you already have them as int, bool, str. What you are seeing is the repr of those types.
try lst1[0](42) and you'll get a float 42.0
 
If you want the name of the class as a string, use .__name__
 
or that
crystal ball is hazy today
 
Okay
 
6:05 PM
Depends on whether the first item should be float or 'float'.
 
Why are you appending the type @Huzaifa?
 
Practicing python
 
Then you get what you were playing with? append(type(lst1)) will append the string of the type. I'm not sure what's surprising
 
@roganjosh it will not :P
 
Yeah nothing's surprising. Just wondering if I can get a list like [float, int, str, bool, list, dict] instead of [<class 'float'>, <class 'int'>, <class 'str'>, <class 'bool'>, <class 'list'>, <class 'dict'>].
 
6:12 PM
@Huzaifa no
 
okay then :P
 
Not until you specify a very specific situation. You could, but not the way I think you're asking.
 
Fair
a = []
a.append(type(123))
print(a)
print(type(a[0]))
 
You could build a string that equals '[float, int, str, bool, list, dict]'. Nothing stops you from doing that.
And if you want to ask "how?", Aran-Fey already told you
 
Nah, I am good :P I'll pass this time
 
6:18 PM
Mmm, I'm back to python novice land because I would have expected this to be a string
a = []
a.append(type(123))
print(type(a[0]))
 
yes, but type(123) is the int type itself, the type of which is type (obviously)
 
"obviously"
 
Now check what the type of type is :P
 
Well as per Aran-Fey answer, I got it.
for jj in t1:
t3.append(type(jj).__name__)
print(t3)
['float', 'int', 'str', 'bool', 'list', 'dict']
 
@Huzaifa that's not what you asked for
 
6:20 PM
Learning python is fun
 
truly the gift that keeps on giving
 
@AndrasDeak I think that's what I asked O.o
 
@roganjosh Too much exposure to javascript?
 
8 mins ago, by Huzaifa
Yeah nothing's surprising. Just wondering if I can get a list like [float, int, str, bool, list, dict] instead of [<class 'float'>, <class 'int'>, <class 'str'>, <class 'bool'>, <class 'list'>, <class 'dict'>].
 
@AndrasDeak those teeny weeny ' ' are fine :D
 
6:22 PM
@Aran-Fey Perhaps. In the back of my mind, type(123) would call __repr__ and that would return a string, no matter what I was really handling
 
@Huzaifa it's the difference between a type and a string
 
I was clearly very wrong on that
 
if you gloss over details like that then you will mislead people trying to help you and/or yourself
 
No, that part was right. You were wrong about the contents of the string though :P
 
@AndrasDeak OMG (crying)
 
6:24 PM
@Aran-Fey huh? type(123) doesn't call repr, the repr of the list does
 
Ah, ok, I get it now
 
@AndrasDeak ** (Crying in python) :D
 
there there
 
6:45 PM
@Huzaifa You can do it without the quote marks, but you shouldn't.
# Don't try this at home, kids
class Silly(list):
    def __repr__(self):
        return "[" + ", ".join([u.__name__ if isinstance(u, type) else repr(u) for u in self]) + "]"

a = Silly(['a', 'b', 'c', 1, 2, 3, int, str, list])
print(a)

# Output
['a', 'b', 'c', 1, 2, 3, int, str, list]
 
Thanks
Don't try this at home, kids because its silly xD
 
I wish sphinx hadn't taken this advice...
 
Just don't do a.append(a)
 
There are exceptions to every rule, including this one. ;)
 
7:01 PM
If anyone's relying on numpy.distutils: next step in discussing its deprecation, tracking issue
 
Avv
7:15 PM
Hello Guys, Do you know any online Python AST visualizer please?
AST (Abstract Syntax Tree).
 
7:28 PM
The only ast visualizer I know is ast.dump(..., indent=2)
 
If you run it in aws does that make it online?
 
Google says python-ast-explorer.com but I've never used it.
 
 
1 hour later…
user17921218
8:40 PM
2 days ago I asked a question, but I still haven't received an answer. I know what the problem with the error is, but I can't fix it because I'm new to Python. Could anyone help me find the solution please? stackoverflow.com/questions/70707296/…
 
8:58 PM
@NathanMüller Your question has a lot of code that is irrelevant and it's missing code that is relevant. If you know exactly what the problem is you should whittle down your code to the simplest of examples that still demonstrates your problem. You don't need comboboxes to demonstrate this. Just two classes (probably even in the same file) that try to use one another's attributes.
And an error is more than just the error message: the traceback has a lot of information, it's printed for a reason. These are all pieces in an MCVE.
 
user17921218
@AndrasDeak I know what the problem is and in fact I have reduced the code to the simplest of examples. I'm new to python, but I think it's obvious what the problem is. Also no, the two classes are in two different files. I need them in two different files as in the question
 
@MisterMiyagi JSON is a subset of YAML. Use that?
 
user17921218
Why was my application preview deleted? Thus the question has no visibility in the chat. Sorry, but I ask the question again. It is not spam. Thank you :)
 
@NathanMüller I moved it because you already linked to it, and insistently reposting it is spam. Please stop.
 
user17921218
9:19 PM
@AndrasDeak I didn't reissue it insistently. I noticed that the link in the question is not noticeable, because there is no big preview of the question. More questions here in chat have a great preview. I, on the other hand, have only posted a small link. So I posted the question with the preview.
 
user17921218
I think it would have been spam if I had posted the preview of the question twice, instead there was just a simple link in my question without any preview. You don't even notice that little link. Anyway ok, I don't publish that link anymore. But who reads this, I invite you to go up a little in the chat where you can find the link (without preview and not very visible) that is in a chat message. Thank you
 
user17921218
Excuse me. I am new here :)
 
9:32 PM
Making DNA to Protein translation. Every 3 DNA base is a codon, and correspond to a specific value in dictionary.
 
@Huzaifa have we pointed you to our formatting guide yet?
 
I did copy pasted using dpaste, but idk what happened
 
that is totally not an answer to my question
@Huzaifa please read sopython.com/wiki/… and practice in the sandbox before retrying
 
@AndrasDeak Allow me to translate: "No"
 
okay
 
9:34 PM
@Aran-Fey much obliged
 

« first day (4110 days earlier)      last day (824 days later) »