« first day (2503 days earlier)      last day (2446 days later) » 
00:00 - 17:0017:00 - 00:00

12:02 AM
@LandonZeKepitelOfGreytBritn you should read An Illustrated Guide To Formatting Code In Chat and use external paste tools for long snippets of code in the future. (you too @hope94)
 
user8451312
I will read it whole now. :)
 
Thanks
 
woohoo! learning lots about pytest today
I have this bastard test suite which is mostly unittest which is run in pytest. There is a single pytest fixture and the rest is unittest as far as I can tell.
Now that I'm learning pytest paradigms, I find it very strange that the almost-completely-unittest suite is run with pytest.
I'm going to gradually convert it over to pytest, though.
 
 
1 hour later…
1:11 AM
If I have an Alpha module where I have:
if __name__ == '__main__':
     var = 'Hi'
     import Beta
And in Beta I have:
import Alpha
print(Alpha.var)
Would it work? I have tried in my pc something like that but it didn't work... have I made something wrong?
 
@EnderLook - I'm sure you've heard this already - "didn't work" is not really enough to go on. Did this blow up? Python traceback? Do nothing? Melt your computer?
 
AttributeError: module 'menu' has no attribute 'config'
But now that I am thinking better I think my error is another, I am re-checking.
 
In general, this kind of cyclic import usually indicates that you need to reorganize your code and vars, perhaps introducing a module named Gamma that contains the vars that are accessed by both Alpha and Beta.
 
@PaulMcG But I am not sure if it necesary to make a whole new module for only this. I mean: I have a menu file (alpha) who reads a config.cfg and then execute another file: beta (import Beta and Beta.start() beta is a whole function). But Beta need to use the config so it import menu to get that variable. I don't think it would be necesary have a gamma module where it's stored the config...
 
Perhaps the config could be used in the constructor of a class in Beta, or passed as a parameter to start()?
Or that portion of config that start cares about could be passed as a parameter to start() so that start() only sees the parts of the config that are relevant to it.
This would be better than passing the whole config when it isn't needed
 
1:25 AM
@PaulMcG I also thought in make an argument in the .start() but I want sure, Shall I? About the constructor... I am not sure what means constructor!
@PaulMcG That sound great! Thanks
 
I say "constructor" because in other OO languages, a method is defined on classes that gets run when an instance of that class is created. For Python, I should really more properly call it "initializer", because it corresponds to the __init__ method in Python classes - it is so named because it doesn't really construct a new instance, so much as it initializes one
It is a fine point, so don't worry too much about it - just know that people (especially old people like me) will sometime erroneously use these terms interchangeably, when there really is a distinction.
So when I said "constructor" earlier, I really meant the __init__ method of some class that might be in Beta.
 
Ahh, thanks for the clarification. I don't know much about codding "theory".
@PaulMcG I instead of write it in the initializer I did:
 
class ConfigurableThingThatStartsAndStops:
    def __init__(self, config):
        self._config = config

    def start(self):
        # do things using self._config

    def stop(self):
        # stop doing things
And don't blow this off as academic theory, OO concepts in Python can help you write very complicated code while keeping related vars and methods organized.
 
 # Beta
 def start(config):
      class Server:
           def make_dir(config = config)
                # And then I used the config
# I hadn't tested it yet. I don't know if this works.
 
DSM
If you think you need to dynamically construct a class you're probably wrong.
 
1:34 AM
What purpose is your Server class, buried inside start()?
Why did you think you needed to define a Server class inside start()?
 
@PaulMcG mmm, good question. Know that I'm thinking it isn't necesary.
@PaulMcG ... I think DSM say last night that I should have the code of a module inside a whole function, so...
And then call it
...
I... I am trying to do this ---> pastebin.com/wcwhiwfJ
 
Or it's possible that what you are calling Server is what I called ConfigurableThingThatStartsAndStops
 
mmm, now thinking maybe I can put all the code outside the class inside ` __init__` and only has the class in the module. Then when I import it, instead of do server.start(), do server = server(), no?
 
DSM
@EnderLook: the idea is that you should be able to import a module without executing code which really belongs in functions. You don't need to push classes into functions, because building the class (as opposed to making instances of that class) should in general not have side effects.
 
Or, I don't know. This is so extrange!!
@DSM Ok
 
1:41 AM
Yes - and import __main__ is pretty bonkers too
Just get rid of that
 
@PaulMcG That wasn't my idea. I got help from an expert, talk with him!
 
Not in this chat room, surely
 
DSM
That was a too-clever-by-half way to avoid being explicit about a folder path, if I'm reading the transcript right.
 
From Rawing:
@EnderLook If you don't want to pass it as a parameter, you can do this:
import __main__
pathlib.Path(__main__.__file__).parent
 
Gah, my eyes! my eyes!
 
1:45 AM
He has 11,167 rep. That means he is pseudo-expert!
 
While this might work, please find another way to do this - importing __main__ is... just not done
 
Good Bye! It's late for me and I have school tomorrow.
I enjoyed the talk and I think I have learnt 2 or 3 things new.
Bye!
@PaulMcG Don't worry about __main__. With my new config I will delete that. No more "bonkers" things!
 
I'm one to talk - I've done my share of Stupid Python Tricks too
 
DSM
Like lots of tech chat rooms, sometimes for entertainment's sake we give a clever way to do something instead of a good way..
 
Caveat noober
Like this from my top-voted answer:
def secondsToStr(t):
    return "%d:%02d:%02d.%03d" % \
        reduce(lambda ll,b : divmod(ll[0],b) + ll[1:],
            [(t*1000,),1000,60,60])
I've always had a soft spot for divmod
 
DSM
1:59 AM
Yeah, I think I'd -_- that in a code review. :-)
 
Interesting... well. This time it's really, I have to go. Bye! (in chats I always say bye some minutes of really going because maybe someone want to say me one last thing).
That secondsToStr() is quite strange. Tomorrow I will analize that.
 
Don't - you have better things to spend your time on
 
? Okey, I will turn off my computer in a couple of minutes... lets read.
 
reduce() is a peculiarity in Python, and definitely should not take priority in your learning over many other fundamentals
 
@PaulMcG python-course.eu/lambda.php. What? Reduce is one of the cursed commands???
(I call cursed commands: lamba, filter and map because they are very useful but I don't understand them!!!)
ah, to by the way. I have finished some days ago the official python guide. What is next? Read all the documentation module by module?
Bye
 
2:08 AM
Maybe too soon
 
 
1 hour later…
3:27 AM
@EnderLook many pythonistas curse the name of lambda, filter, and map because there are other, "more pythonic" ways to do the same thing.
 
sP_
3:56 AM
Hey people, what are the ways in which I can notify myself about something for free using python? I'm making a scraper for a feed and I want to be notified if some word matches a keyword. What's the best way to do it? Could be a mail, or text notif, or an in app notif or anything. Preferable if it's free, else something that costs less.
And also will be better if it's instant. Need to notify just me, not a bunch of people.
 
4:57 AM
@sP_ too broad...
 
5:10 AM
cbg, and rbrb in a few minutes, but I was wondering if anyone knew whether it was better coding practice to keep random states/seeds as static variables for a class or as an instance.
as in, self.state, or class_name.state considering this isn't a singleton? I haven't really tightened the grip on whether things have to be reproducible, but now it does, and oh boy is this annoying
 
sP_
5:41 AM
@AnttiHaapala Hmm.. Okay.. So what are the APIs that will allow me to send sms or email for free? Those which can be easily used with python.
 
Morning cbg
 
 
1 hour later…
6:52 AM
@sP_ I wouldn't know, you need to google
 
@PaulMcG I only suggested that import __main__ solution after someone already told Ender to pass it as a parameter, and they then asked if there was no other way. But still... sorry about your eyes.
 
7:15 AM
cbg-morning
 
cbg
 
7:52 AM
I am doing cat myfile | myscript
and trying to read stdin using below code
with open(sys.stdin) as f_input:
and getting TypeError: coercing to Unicode: need string or buffer, file found
 
You don't need to open stdin, it's already a file-like object
 
ok, so just f_input=sys.stdin is good enough
 
Yep
 
thanks @Rawing that works for me :)
 
Has someone written a stack app that automatically suggests dupe targets yet?
 
8:04 AM
@Rawing stackoverflow should do it
thirdparty has no data for that
 
SO already has that built in, their suggestions are garbage :p
 
8:27 AM
@Rawing (Re: regex [][]) So you wouldn't really misunderstand it. And Python's own re documentation mentions []()[{}], and not in a discouraging way.
 
@StefanPochmann Had no idea that was a documented feature. Fair enough, I guess I have to live with it.
 
@Rawing Yeah, doc says "To match a literal ']' inside a set, precede it with a backslash, or place it at the beginning of the set. For example, both [()[]{}] and []()[{}] will both match a parenthesis."
 
Wonder if that also applies to other regex flavors... I know "empty" negated character sets [^] behave differently in python than in JS for example
> "a[b]c".replace(/[][]/, "x")
< "a[b]c"
^ JavaScript
So I'm still going to avoid that syntax
 
@Rawing Yeah I just tried that as well. Ok, that's a better argument against it. Or maybe just against JavaScript :-P
 
No, JavaScript is perfect and has no flaws, what are you talking about :/
*frantically tries to find another language that displays the same behavior as JS*
 
8:44 AM
@Rawing Java is really weird about it, claiming "Unclosed character class near index 3": ideone.com/NsUKI3 What the hell, that message doesn't make any sense.
 
Java ¯\_(ツ)_/¯
Oh. That error actually makes sense if Java supports nested character classes.
 
9:00 AM
@Rawing Hmm, ok, because of the word "near". Admittedly I overlooked that before. The caret points at the second "]", and that made me think it's complaining about that.
 
I'm not sure what Java's doing. How exactly does "a[y]c".replaceAll("[\\w-[x-z]]", "x") result in "x[x]x" :/
But hey, it didn't throw an error, so I guess it does indeed support nested classes.
 
Yeah it does support them, and it's documented by examples: docs.oracle.com/javase/8/docs/api/java/util/regex/…
 
Ah, I see it uses && instead of -
 
What language uses "-" for intersection?
 
That was meant as "it doesn't support - so you have to use &&". I don't think any regex flavor uses - for intersections
 
9:16 AM
But it does support "-". It just doesn't have its special meaning between character classes. Because... what should that even mean?
 
- usually does set subtraction, so [\\w-[x-z]] would be "all word characters except x, y and z"
 
What? No. "-" usually does range.
Oh well, ok, between classes it could mean subtraction, yes.
Is there a language that does use set subtraction for [\\w-[x-z]]?
 
^ Yeah, that's how it usually works. But java seems to interpret is as a literal -, so it ends up being equivalent to [\wx-z-]
 
I tried your [\\w-[x-z]] example in Javascript, Python and Ruby as well, none of them do subtraction (in Javascript and Python I get an error). Do you know languages that do subtraction for it?
 
It's surprisingly difficult to find one that does...
 
9:28 AM
i used `smtplib` to send emails as said in [here](https://stackoverflow.com/questions/10147455/how-to-send-an-email-with-gmail-as-provider-using-python). Just after sending the email, disconnecting from the internet cause the program to run forever. How to implement a timeout with that?

`KeyboardInterrupt` caused following lines:

KeyboardInterrupt Traceback (most recent call last)
<ipython-input-13-b4ad094879da> in <module>()
----> 1 sendError('12')

<ipython-input-2-bf188777c3a5> in <lambda>(error)
 
According to the .NET docs it should be supported, but I can't make it work in an online REPL...
 
As the keyboard interrupt says the program is stuck at the position of logging into the gmail account. SMTP.login only have the arguements username and pwd. No timeout option was given. Is their a way to apply an interrupt externally?
 
9:42 AM
That's from 2004 and I guess it was that author's personal wish to get this done :-). I couldn't find it on this page or its subpages.
 
Wait, those aren't the official docs? Oops. Google, you have failed me! *shakes fist*
 
Well, it might be, but it still looks like only a plan. It does say "The concept which is unsupported today in the framework" and that if Perl 5.6 contradicts it, then that takes precedence.
 
Well, I can't find an actual language that supports it, but it's mentioned on regular-expressions.info at the very least
 
10:01 AM
Maybe that page is mistaken? I'm not familiar with .NET and don't know how to test it. The page does say "character class subtraction syntax is incompatible with Perl and the majority of other regex flavors", so that might've ruled it out according to the article you showed.
 
Not sure what that paragraph about incompatibility is all about tbh
 
11:00 AM
@Rawing oh, sorry. It wasn't my intention put you on the frontline. I thought that use __ main__ was something good, or at least acceptable. Sorry.
 
Afternoon cbg
 
@EnderLook Don't worry about it. I thought you had already decided to pass the directory as a parameter and were only asking if there was an alternative solution out of curiosity. I guess I should've explained that using __main__ is a bad solution.
 
11:58 AM
working cbg
 
12:17 PM
@Nkls155 now the code is even more wrong, you mustn't share the session with threads! — Antti Haapala 22 secs ago
@aquire smtplib is not the way how a sane person sends email. Too bad that poor excuse of a library is in the standard library
@Rawing umm no...
that doesn't work anywhere that I know
the set difference is done by taking the complement of union of complements
[^\Wxyz]
 
any of you guys got any experience with django?
 
yes, enough. That's why I don't use it any more .
 
any chance you could help this lad out stackoverflow.com/questions/45839116/… ive never used it before but i helped all i could
 
> Do not link your recent (< 1-2 days) questions in the room. The main site is the dedicated space for posting questions, and having them answered.
Chatroom rules - sopython.com/chatroom
@AnttiHaapala Do you have other better frameworks in mind?
I might be getting to your stage, soon.
 
12:33 PM
Linking somebody else's question is more of a gray area, though
 
oh, I assumed it was OP
 
Hi I need some career advice here --> I learned Angular 2 bootstrap html css and a bit of java for my first year as a junior developer now my company moved me to devops and I have to learn CD process and tools like ansible along with Python and more of java so what should i do will my earlier knowledge be of any use and worth consideration as my career moves forward
 
The whole rationale of "if it's only been half an hour, then the people in the room interested in answering questions have probably seen it already" still applies, but the solicitor's motives are unselfish so the act is not so much scornworthy as it is merely ineffective
 
@AtharvaPandey Unless you unlearn some things, I don't think it should be a problem. But yes, amount of experience you have in those, or the lack thereof, will certainly be considered.
@Kevin yeah, my bad. If I had known it wasn't the OP, wouldn't have mentioned the rule.
 
i don't mind unlearning anything but then i feel like i lost 1 whole year ... ehh well i guess i should just go with the flow
 
12:39 PM
morning cats
 
This might be subjective, but IMO, in one's early years, it helps to know a lot of different things so that you can start focusing on the stuff that you like and excel in that.
 
All of the languages I learned but don't use any more, did not turn out to be a waste of my time because they all conveyed generalizable lessons that weren't specific to their own environments. Ex. OOP design principles and logical thinking
 
12:54 PM
@AnttiHaapala Antti, I second Ashish question. To which framework did you switch, as you abandoned django?
 
Pyramid. It doesn't have that many batteries included but I can replace the batteries as I wish.
Please provide the entire traceback in the question itself, as plain text, for the code in the original question, not the modified one. — Antti Haapala 55 secs ago
@WhatsThePoint well, you only managed to confuse OP there :D
 
@AtharvaPandey - don't look at time spent learning other languages as being "wasted". I have probably worked with a dozen mainstream languages during my career, and it is good to have a broader view about relative merits of each, in the context of their respective times and design goals.

But don't become the cliche developer who moans, "(current language) sucks, if only it had feature X of (previous language)."
The core concepts about OO design, multiprocess coordination/synchronization/communication, data persistence, ... these transcend specific frameworks and languages.
 
1:10 PM
and OO is overrated.
everything is overrated.
(insert any buzzword) is just a buzzword.
 
Starting with Java and moving to Python is a common path, and has some pretty standard learning curves (Java: setters/getters are a must, vs. Python: meh, just leave the attributes public). There are a number of resources online for "Python for Java Programmers" to help you map concepts and practices from your previous life to your current one. In your travels, you will probably run into the blog posts "Python is not Java" and (I think) "Java is not Python, either". They are good reads.
 
I assumed everyone quietly acknowledged that everything is terrible and we collectively agreed to roleplay people that think otherwise because it's less depressing that way.
 
@Kevin I didn't say that everything is terrible.
just saying that smart people didn't write horrible programs before OO, except maybe in Fortran.
 
@Kevin First rule of Software Development Self-Delusion Club: Don't talk about Software Development Self-Delusion Club!
@AnttiHaapala There have always been horrible programs, written by some very smart people, both before and since OO.
 
Cro
how could i configure opencv_createsamples to create colored positive samples? if anyone have an answer, tell it out before u send the real answer out plz
 
1:19 PM
import tkinter as tk
from tkinter import font
 
guys how do I use this hirangani keyboard on mac? I can't get it to make the symbol for dog
 
Why do I have to import font separately, when I, as I understood it, already imported everything from tkinter..?
also, font doesn't show up in the dir(tkinter). Probably connected, but why then is it imported from tkinter?
 
user8451312
So, here is a problem.I was wondering why the whole my code runs so slow, and i taught that it was just because stemming last too long. It does last lon, about 4 min, but there is another problem. When this code runs, and cv calls custom tokenizer, it runs like this:

1.#split-space
2.#stem tokens
3. #filter tokens
...

1.#split-space
2.#stem tokens
3. #filter tokens

...and again it goes in circle...

So every part runs multiple times. I cant figure out why cv works like that, and how to prevent it.
 
user8451312
def custom_tokenizer(text):
    #split- space
    tokens = ' '.join(post_text_train).split()

    #   stem tokens
    for i, token in enumerate(tokens):
        for key, val in d.items():
                if re.match(key, token):
                    tokens[i] = val

    #filter tokens
    tokens = [token for token in tokens if len(token)>=3]
    return tokens

cv=CountVectorizer(tokenizer= custom_tokenizer,analyzer ='word',encoding='utf-8',min_df=0, max_df=1.0, stop_words=frozenset(dict))
 
@hope94 have you tried asking a question on the main site...
 
user8451312
1:26 PM
nope
 
@hope94 you're using the post_text_train in your tokenizer...
... so what's that text argument/parameter that goes in there...
 
user8451312
omg, i saw that now, because i copeid that line from another file of mine where i was trying something.
 
user8451312
it stills goes through tokenizer multiple times
 
user8451312
but stemming is running fast
 
@DrOnline Since you imported tkinter as tk, try dir(tk)
 
user8451312
1:42 PM
how can i writ in new line when writing post in main site?
 
user8451312
i wrote text and then shift+enter, but it wont go to new line
 
Just Enter by itself ought to do it.
Alternate strategy: compose post in Notepad, then copy-paste into browser
 
user8451312
oh k
 
user8451312
ok*
 
Cro
how
could i use python 2 make a screen virtual keyboard?
 
1:47 PM
so much garlic
I've been super unmotivated lately. All I have to do for Flask is write a bunch of docs. :-(
 
hey, still better than my contributions to flask
 
Trip report: Rode 600 miles to see the eclipse. Enjoyed the first 1/3rd of it. Totality was completely blocked by a tremendous slow-moving cloud. Tried to adopt a stance of "well it's still pretty cool that the temperature dropped 20 degrees in ten minutes and it got as dark as 30 minutes before sunset", and succeeded until I read today's XKCD describing how mind-blowingly amazing it would have been to actually see anything.
5
 
Co-worker just got back with his eclipse trip report: totality was amazing to behold, but post-eclipse 7-hour traffic jam to get back to the hotel, not so much
 
I only had a 2.5 hour traffic jam, so I've got that going for me, which is nice
 
That map of severe traffic exactly in the path of the eclipse was pretty good.
 
1:56 PM
@hope94 umm, plain enter should work on the main site. Also the question format there doesn't have "lines", if that's what you were asking, it has paragraphs. A paragraph is separated by 2 enters...
next total eclipse in Finland: 250 years...
I guess I need to book tickets for year 2024 :D
 
On the bright side, failing to cross an item off of one's bucket list means that one has all the more reason to continue not kicking the bucket.
 
cbg all
 
I should come just short of fulfilling my goals more often.
 
I was 8 when this occurred: timeanddate.com/eclipse/solar/1990-july-22 - should have begged parents more to go to the SE Finland then
 
Next time I'll fly to the totality zone and see it from the airport hotel's balcony, thus avoiding 100% of potential road congestion
 
2:03 PM
and then your hotel doesn't have a balcony to that direction.
 
I'll need to break into (outto?) the roof, then. Airports let you carry lockpicking tools, right?
 
DSM
Midweek cabbage for all.
 
\o cbg
@DSM took a day off sorry. 4 in a row makes me sad, starting to not look good for us. Time to sell ?
 
After spending virtually all of my life in the Delaware Valley and/or 50 miles from the ocean, I have just recently learned that America has mountains. Like, I knew it, but I didn't know it.
My favorite was the one with the red rocks on it. It was in Virginia.
 
DSM
@MooingRawr: yeah, I think so, unfortunately.
 
2:12 PM
Also: sometimes rivers have rocks in them. Possibly related???
Where are all these rocks coming from
 
I am slow at photo editing, but Kevin needed a motivational poster.
 
It's beautiful, thank you.
 
@davidism perfect picture describing other things, too. :(
 
Don't need that poster as I have already completely internalized its lesson
 
@DSM o/
@MooingRawr o/
 
2:29 PM
cbg \o Andy.
 
It feels weird to have to import re to use a regular expression in 2.7
 
DSM
That hasn't changed even in modern Python, though.
 
@SterlingArcher it's the same in 3
 
How come it's not built in? I know python likes it's imports, but regular expressions?
 
if I want regexen as builtins, I'll use perl
 
DSM
2:39 PM
I'd say it is built-in.
 
>>> from builtins import re
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
ImportError: cannot import name 're'
:P
 
I guess yeah, you're right, I didn't have to pip anything
 
DSM
Python just prefers to push functionality like that into functions rather than making the syntax carry the weight.
 
@DSM makes sense.
 
DSM
@AndrasDeak: nerf. Nerf bat for you.
 
2:40 PM
live by the pedant-stick, die by the pedant-stick
 
cbg
 
DSM
I can see why people who use lots of regexes would find it less convenient, and to be honest I wouldn't have minded if we had a syntax like [identifier]"string" which called the identifier, so you could write rx"some_regex_here" which would be expanded into rx.__fromstring__("some regex here") or something to make it easier to make a RegularExpressionObject or whatever, but I also don't use patterns like this often enough to care.
 
So I'm reading a PDF and – appears in my print statement as Œ, which yields: SyntaxError: Non-ASCII character '\xc5' in file aws-pdf.py on line 10, but no encoding declared; see python.org/dev/peps/pep-0263 for details
Basically I'm trying to regex "Notices 38 Å’ 61"
I'm not sure how to encode? this character properly
 
Python 2's default source encoding is ASCII. You need to put a # -*- coding: utf-8 -*- comment at the top, and use u'Notices 38 Å’ 61' unicode strings.
Or just use Python 3.
 
Did not know, that stopped the error 😀 thank you. Now to see if I can teach myself regex
 
2:46 PM
This is your bimonthly reminder that many tasks can be performed using ordinary string manipulation rather than regex
For instance, removing all instances of "Å’" from your file can be done with str.replace rather than re.sub
 
what the... I ran page_content = page_content.replace("Å’", "-") and it turned all Å’ into Ð
lmao
 
@idjaw cbg
 
Arg, gotta let this chill. Time for a standup. Thanks for the help folks
 
My Unicode sense is tingling. replacing a character and that having an effect on adjacent characters seems like something that can only happen in multi-byte character encodings
My incredibly generic-to-the-point-of-useless advice is: make sure your encodings all line up
 
DSM
Life is too short to think about Unicode issues in Python 2. It seems to work the way it should in modern Python.
 
2:59 PM
Unrelated: does anybody actually use namespaces? By which I mean, writing classes which will never be initialized or subclassed? Contrived example:
import math

class UserInterfacePart:
    x = int(input("Enter x:"))
    y = int(input("Enter y:"))
class GeometryPart:
    angle = math.atan2(UserInterfacePart.y, UserInterfacePart.x)
class OutputPart:
    print("The angle is: {}".format(GeometryPart.angle))
 
why not use a separate module for that?
 
I introduced the pyparsing_common namespace into pyparsing, because I didn't want any more API bloat.
 
(that's a "no" from me)
 
I ask because I wanted to reply to What's the point to allow statements directly in the class body? with "because namespaces are one honking great idea and we should do more of them", but I don't think anyone actually does this or wants to do more of this
 
nope, that looks like a mess. If anything, those classes should be functions
 
3:02 PM
@AndrasDeak Maybe I want to keep it all in one file, for some reason.
 
Tempted to say youtube.com/watch?v=guv5LUT1AFw&t=7s but maybe there's a good reason for them
 
@Rawing Agreed for this particular contrived example. Doing return x,y is simple enough since you only need those two values. But this may be less obviously preferable when your namespace wants to expose more attributes than can be comfortably returned in a single tuple.
x,y = getUserInput() is easily written, x,y, theta, phase_of_moon, is_users_star_sign_pisces, blood_type, favorite_smell = getUserInput() less so
God forbid you get them in the wrong order and determine that they love the smell of O-positive
 
But in that case you wouldn't write code in the namespace. You'd simply make a class that holds all the values you want to return
class UserInput:
    def __init__(self, **kwargs):
        self.__dict__.update(kwargs)

def getUserInput():
    return UserInput(a=5, b=3)
 
I'm getting the feeling that every use case for class-namespaces is already better fulfilled by some other existing approach
 
That's looking more like a namedtuple anyway
 
wim
3:15 PM
I wonder what happens if you import a module in the class namespace
do you get to access it by Classname.modname ?
never actually tried it
 
class X:
    import math
print(X.math.sin(0))
Runs.
print(math.sin(0)) crashes with NameError
 
wim
heh. neat.
so it's in sys.modules, but no name bound
 
Yes that is my expectation
 
This works for me
class X:
    import re

X.re.compile(r".*")
Out[28]: re.compile(r'.*', re.UNICODE)
X.re.compile(r".*").match("BLAH")
Out[29]: <_sre.SRE_Match object; span=(0, 4), match='BLAH'>
 
cbg guys :)
 
3:18 PM
Oh, I misread your post, Kevin
 
wim
"already better fulfilled by some other existing approach" is import math; del math
 
I asked a question yesterday night at like 3 AM, and understandably didn't get a response, but am still curious: What's the general concensus on having a static random_state within a class vs. a new random_state for each instance of the class?
or are there specific use cases for each one that I fail to see?
 
What is the type of this random_state value?
 
In sklearn's code, I observed that they like to do the latter, and have a random_state created in the initializer.
could be random.Random(seed) or np.random.RandomState(seed) or anything along those lines.
 
@Kevin well I was asking for that reason :P
 
wim
3:20 PM
the class namespace is kind of crippled, you can't get enclosed names using a list comprehension
kind of an ugly part of Python imo
 
When it comes to PRNGs, it is often desirable to have deterministic behavior during testing so you can more easily track down bugs across multiple executions. I would want my class instances to have individual state if there was any chance of them running simultaneously.
Otherwise you'd get race conditions where sometimes instance A gets the rand() value that instance B got last time, and now oops your heisenbug disappeared
 
@wim The most nefarious of those cases is when you do a list comprehension creating lambdas. All the lambdas share the same namespace so you end up screwing your variables
And mm I see @Kevin, that's a valid case :) forgot about multiprocessing for this scenario
 
I am also thinking of situations of asynchronous communication, for example a server talking to 2+ clients.
Perhaps you'd prefer that each client have its own state. This might even be good from a security perspective.
Alice requests a random number every 24 hours. Bob dislikes Alice and determines your server's RNG has a period of 2**32-1. Every day he requests 2**32-2 random numbers, so Alice gets the same random number every day.
 
Ah I see. I'm currently not doing any web development/general backend stuff. Playing around with extending the scikit learn library, with the assumption of no adversaries
 
what about the tensorflow mafia?
 
3:26 PM
Alice's Widget-spoker, which depends on an even distribution of random numbers to properly run, eventually throws a gasket
 
But that's a valid point there(bob must rly dislike alice)
well it is uniform, from [a,b] where a=b
@Andras me?
 
yeah
 
Do you mean why I'm messing with scikit and not tf? :O
 
I imagine if you use the wrong ML library you can easily end up with concrete shoes at the pier
I was only trying to reflect on the "sklearn" vs "no adversaries" thing, think nothing of it
 
Ah, tf is a great library but it's only really used for graphical models; in contrary people should use less tf and more scikit
also have you seen the source code for tf?! holy crap I do not want to peek in there
 
Prediction: the first human-level-intelligence AI will have essential components that will be completely incomprehensible to human analysis
"Yeah, we just kind of mashed a bunch of media into the ML box until it started looking on piratebay for Game of Thrones rips"
 
I don't think there'll be something you'd call "human-level". They'll probably be a hell of a lot smarter than us in some aspects, and a hell of a lot more stupid in others.
 
"Finally the mystery of consciousness will be solved! Let's look at the neural network associations... Yep, this sure looks like a lot of connected nodes and such"
You could have concluded "consciousness requires connected nodes" using only the supplies of 1 very sharp knife and 1 microscope
 
rbrb folks
 
\o rbrb Andy
 
3:41 PM
@Rawing If it skips right to super-human level, then in the resulting hostile takeover and/or techno-utopia, nobody will care about any predictions I made in the Before Times. I'm not necessarily trying to maximize my odds of being right, just my odds of being smug about being right.
For the same reason that you shouldn't bet any money on "the sun will explode tomorrow", because if you win you won't be able to collect
 
I want to assemble some sort of list that I can use to improve myself or just review. So I was wondering, what are some pythonic essentials or related concepts to python that separate a beginner from professionals?
 
The first sentient AI will have the worst case of crippling impostor syndrome. "Jim, what if...I'm not really sentient, only pretending so well that even I believe it?"
 
Or it will turn out that sentience is poorly-defined enough that the AI is completely disinterested in whether it's sentient or not until we come up with an objective test for it
Imagine if aliens land and say, "we notice that your species never really struggles with whether you are truly florby or not" and you ask what florby means and the alien says "welllll it's kind of one of those 'I know it when I see it' deals, you know?". I expect not many people would lose sleep that night worrying about how florby they are
 
I guess that was too general, I'll review some of the materials on sopython. :P
 
I'm 8/10 florby usually
12/10 with rice
 
3:54 PM
5/7 florbs
 
yoyo, does anyone have a preference for documentation tools? Like sphinx/RTD/etc
 
@Programmer There's sijinjoseph.com/programmer-competency-matrix which always depresses me by the time I read halfway through it
 
Hello fellas :)
 
Yeah, I'm clearly lacking. I've always been solo here though so it's just getting from A to B without a lot of guidance on best practices, etc.
 
wim
I like readthedocs
e.g. whenever I push to my repo on github.com/wimglenn/djangorestframework-queryfields , the docs on djangorestframework-queryfields.readthedocs.io/en/latest get automagically updated
no manual steps necessary. and it's a free service.
 
4:13 PM
@wim Ah, cool :) I'll check out the tutorials
 
4:31 PM
how do i upload my selenium bot on server ?
 
The same way you upload any other kind of software on to a server, I imagine
 
so it will not require any specific webdriver or something ?
 
I don't know. I suggest trying it and seeing if it works
 
@AnttiHaapala I tested with smptlib for my error logging application. It worked fine except for that hanging issue. That issue only occurs if I disable the network connection **just after** sending the mail. If there was no network connection before sending the mail and I send the email, smtplib raises an Error without any lag. Just now I figured that smtplib has the facility to include the timeout when calling smtplib.SMTP but I didn't tested it yet.
This is my first time using python for these kinds of services. I would appreciate a good recommendation on sending emails using python. Even
 
user8451312
I wanted to make dictionary like this:
sentdict={"some sentence here":[some, sentence, here], "why this doesn't work":[why, this, doesn't, work]}
 
user8451312
4:42 PM
sentdict={}
for sent in post_text_train:
    sentdict[sent]=sent.split()
print(sentdict.values())
 
user8451312
Output i get is the whole dictionary, not just values. How to get t the vaues?
 
DSM
That definitely seems like it should just print the values.
In [14]: post_text_train = ["some sentence here", "why doesn't this work"]

In [15]:
    ...: sentdict={}
    ...: for sent in post_text_train:
    ...:     sentdict[sent]=sent.split()
    ...: print(sentdict.values())
    ...:
dict_values([['some', 'sentence', 'here'], ['why', "doesn't", 'this', 'work']])
 
user8451312
Omg, I found mistake, sorry
 
Today I have seen two independent misspellings of "lightning" as "lightening" and it's really rustling my jimmies
We need a context-aware spellchecker that can tell a word is wrong even if you spelled it right. This would also solve the problems of your/you're, there/their/they're, and its/it's
 
@Kevin that would be highly enlightning
 
4:53 PM
[fry.png]
 
I am always forgiving with its/it's because it's the intersection of two grammar rules that conflict at that point.
 
DSM
@AndrasDeak: I'm a little disappointed in myself I didn't immediately get that.
 
@KevinMGranger I don't see what you mean
 
If the ivory tower lords of English proclaimed that it should always be spelled "it's" no matter what, I would have a celebratory cookie
 
"it's" == "it is"
it's as simple as that
 
4:55 PM
"use an apostrophe and an S to signify a possessive" works everywhere except "its"
 
DSM
To be honest I'm not a fan of how we map "'s" to the sound we say. We shouldn't need to write an apostrophe to make something possessive.
 
(And also some plurals and similar corner cases, but let's focus on only one flaw of English at a time)
 
There's also "his" and "hers", but you never see someone write "he's" or "her's"
 
I've seen misplaced apostrophes like you wouldn't believe
 
4:57 PM
I find it intriguing that the two of you who oppose "its" are natives while the two of us who are OK with it are foreign speakers
assuming Rawing is also OK with it
 
In Esperanto, you just turn the word into its adjective form to be the possessive, because you're describing the thing as relative to the posessor.
 
I am ok with it. Someday I should find out why we use "his" and "hers" and "its" instead of "he's" and "her's" and "it's" though.
 
DSM
I remember being a little disappointed when I first heard about Esperanto as a kid. It wasn't as magically simple as I was hoping it was.
 
00:00 - 17:0017:00 - 00:00

« first day (2503 days earlier)      last day (2446 days later) »