« first day (2897 days earlier)      last day (2052 days later) » 
00:00 - 15:0015:00 - 00:00

12:21 AM
cbg. all
It's been so long.
 
Hi all! Anyone is good with Keras?
I'm having a weird problem
 
@piRSquared It is the same with English(or any other language that is not used for programming), just because it can be confusing at times does not mean that those rules can have beautiful intricacy, and interesting reasons for being how they are.
Do share your problem payne.
Or is that to much of a payne? (Sorry)
 
12:36 AM
sorry, I was elsewhere, expecting a Ping :p
 
Well, rbrb.
 
inputLayer = Input(shape=(1400, 1400, 3))
firstConv = Conv2D(#blabla#)
outputLayer = Conv2D(#blabla#)
say I have this code and then:
 firstConv(inputLayer)
 outputLayer(firstConv)
model = Model(inputs=inputLayer, outputs=outputLayer)
that thing isn't working, somehow
but if I instead do:
inputLayer = Input(shape=(1400, 1400, 3))
firstConv = Conv2D(#blabla#)(inputLayer)
outputLayer = Conv2D(#blabla#)(firstConv)
model = Model(inputs=inputLayer, outputs=outputLayer)
it works
My question is: why is that so?
 
12:50 AM
@payne in the first case you throw away the result of the function calls, in the second case you bind them to the names firstConv and outputLayer
 
so the Functional API isn't really "Functional" programming?
 
the latter is equivalent to firstConv = firstConv(inputLayer); outputLayer = outputLayer(firstConv) in the first case, unless I'm mistaken
 
I would've expected my first case to have firstConv return a function that uses another layer to return a Layer, which would thus have worked correctly
 
@payne one of the very little I know about functional programming is that ideally everything should be immutable
@payne firstConv is a function that returns a layer. But when you create that layer you throw away the result
 
how am I throwing away the result?
 
12:53 AM
firstConv(inputLayer) <-- presumably returns a Layer, which you then discard. Compare firstConv = Conv2D(#blabla#)(inputLayer) where the right-hand side is the same call, but you're binding the result to the name firstConv
 
AH
I feel dumb
let me try that and come back to you in 1 sec
 
it's fine, easy to get confused with these things :)
 
you are 100% right
interesting how they used an imperative langage to create a simili-functional language
convLayer = Conv2D(#blabla#)
firstConv = convLayer(inputLayer)
outputLayer = convLayer(firstConv)
is this equivalent?
 
python is very bad at being functional, at least if you ask a lot of people including Guido (search developers.slashdot.org/… for "functional")
 
or since it reuses the Reference it will assign both to the same instance ?
(I'm trying to figure out how I create a way of reusing "sub-models")
 
12:57 AM
@payne it uses the same function but stores two different calls to that function. Should be OK unless there's some stateful magic going on in convLayer
it depends on the implementation. If the function returned by Conv2D will always give the same results for the same inputs (even if rerun multiple times), it should be OK I think
 
Using TensorFlow backend.
__________________________________________________________________________________________________
Layer (type)                    Output Shape         Param #     Connected to
==================================================================================================
input_1 (InputLayer)            (None, 1400, 1400, 3 0
__________________________________________________________________________________________________
conv2d_1 (Conv2D)               (None, 1400, 1400, 3 12          input_1[0][0]
it looks to me as thought they are both linked to the same convolution instance?
 
I don't actually know any ML frameworks so that tells me nothing ;)
Well it seems you can decide this for yourself. Do this version and the previous one, check if they're the same. You'll have your answer. That or read the documentation to figure out the behaviour of said function.
either way you'll need to figure this out on your own
 
thank you brother
 
1:26 AM
I've got a weird issue I can't figure out. I have a global variable that I declare but do not assign. Later I assign a bool from a json file to that global variable, but the interpreter makes it a string. Why would that happen?
 
In python when a bool silently turns into a string it's a good sign that it wasn't a bool to begin with.
Check that 1. you really didn't bind a string to the global name beforehand, 2. the bool is really a bool. If neither help, we'll need an MCVE to help further.
 
@AndrasDeak 1) yes the declaration and assignment are only a few lines apart 2) I put a logging line in with a type and it comes out as a bool
I'm assuming MCVE is a code example? not following that abbreviation.
 
1:49 AM
oh gosh. I just realized I misread the code... lol. @AndrasDeak I'm an idiot. Carry on...
sorry to waste your time.
 
no worries
 
 
2 hours later…
3:30 AM
# Complete the squares function below.
def squares(a, b):
    number_list = range(a, b+1)
    squareInts = list(filter(lambda x: float.is_integer(math.sqrt(x)), number_list))

    print(len(squareInts))
    return(len(squareInts))
Trying to complete this function but getting time out error. Any advice?
 
Hello
I need help with regex
this works in an online debugger but not in python for some reason
>>> ob_str = 'KGGG 202353Z 17007KT 10SM '
>>> ob_str2 = 'KGGG 202353Z 17010G15KT 10SM '
>>> re.match('(\d{5})(KT|G\d{2,3}KT)', ob_str)
>>> re.match('(\d{5})(KT|G\d{2,3}KT)', ob_str2)
>>>
nothing gets printed for some reason
I want to match the winds (the things with KT behind them)
 
Are we only two online right now in this chat room?
 
5 digits followed by either a "KT" or G with 2-3 more digits and then the KT
@newguy it's late I guess
 
Yes in the US I am in India
Can you advice on my problem?
 
no idea
 
3:34 AM
ok
 
3:47 AM
cabbage
 
cauliflower
 
It works if the string I want is in the front
>>> re.match('(\d{5})(KT|G\d{2,3}KT)', '10010KT')
<re.Match object; span=(0, 7), match='10010KT'>
>>> re.match('(\d{5})(KT|G\d{2,3}KT)', 'KGGG 10010KT')
but not if there is something in front of it
 
 
1 hour later…
5:02 AM
solved it
works if I use .search instead of .match
 
 
2 hours later…
7:18 AM
cbg-ning
 
8:14 AM
cabbage
 
cbg
 
8:28 AM
cbg
 
8:48 AM
cbg
 
9:21 AM
ᴄʙɢ
 
cbg
 
⅁𐐒Ↄ
 
cbg
 
9:34 AM
cbg
 
WTF is cbg?
 
[avatar_my-cabbages.gif]
 
9:56 AM
minpack.error: Result from function call is not a proper array of floats.
every time I try to use scipy.optimize I end up with a new error I've never seen before...
aha!
one of my 1d arrays was 2d
 
minpack, you liar
cbg
 
@newguy you derailed the cbg train. omg
 
Poor choux choux train.
 
10:09 AM
Hi friends,
if i want to send messages to another user even if he is offline, he can view the messages once he comes online.
what api,library or service can help me to have such a chat feature?
 
email?
 
it should be within a web app, u shuld not redirect to gmail for that
like facebook, u can send msg even if opposite user is offline, he can reply once he comes online
 
Does mentioning someone in a room they are not in trigger a notification on SO?
 
Yeah but it's not just sat in cyberspace. Facebook probably has some other-worldly solution but as a basis you could just save the message to a database and when the user logs in, scan your DB to see if they have unread messages
 
in a healthcare web app, u want to provide a feature where patient can talk to the doctor who prescribed him.
 
10:13 AM
@Chillie only if they spoke in said room up to two weeks beforehand, unless it's a directed reply
 
so doctor is not going to be online all the time to receive patient's msg
 
@ArunRaaj oh, we're not talking about Stack Exchange here? My bad.
 
@roganjosh so is this better idea to save the msgs to db and the receiver views them once he comes online?
 
no MCVE stackoverflow.com/questions/52441163/… And he just added two more images of code 15 minutes after I told him not to do that. Some people...
 
10:21 AM
@ArunRaaj where else would they be? You could use something like Kafka for a messaging queue but I don't see why you'd need it
Out of interest, what country is this system used in?
 
usa
 
Ok. I was going to say if it's in Europe your options may be heavily limited by the constraints of the GDPR, especially with issues over patient confidentiality. You'll need to look at relevant laws before deciding on something
 
Hi
I need to get current datetime in below format
How I can do that
2017-01-12T22:11:31+05:30
 
@Vijay try strftime.org
and "get current datetime" should give you that part via google
 
10:37 AM
thanks, What are few of those limited options that can help me to implement this feature?
is saving the msgs into db right choice?
 
Where else would they be?
 
ys thanks.
 
@ArunRaaj you understand the implications of what I said, right? Waking up one morning and deciding to build one of these systems could be an express ticket into jail.
I wouldn't touch such a project unless I was convinced that we had people who were amazing in data security and someone who knew how to be 100% compliant with regulations. I don't think you're going to find people in an online chat room, I'm not going to advise you on what tech I think you should use
 
@roganjosh what i understood is, saving msgs to db is not a problem but it should be secured and delivered securely
 
And do you feel competent enough to implement such a system considering that 10 minutes ago you didn't have an idea of using a database?
 
10:45 AM
im not going to implement, i want to hav idea how it works in web app
 
"if i want to send messages to another user even if he is offline, he can view the messages once he comes online.
what api,library or service can help me to have such a chat feature?"
And you said it was going to be used in the US
 
whats so serious? if u want to know how a healthcare app works in usa
 
healthcare is one of those things that's regulated to death when it comes to sensitive data (and everything is sensitive data)
@roganjosh also lawyers :D
 
There was a BBC Panorama a few weeks ago about this exact thing. People getting prescription meds online that would do them serious damage
 
11:03 AM
simple thing, patient visited last week a doctor as per his appointment, now if the patient wants to talk to the same doctor regarding the treatment. not exactly "prescription"
such features are available in healthcare apps in usa
 
Fair enough, that correspondence is still confidential information though
And I'm not saying that such a thing doesn't exist.
 
👍
 
Where is piR? I could do with a round of code croquet to save me from Friday debugging
 
11:25 AM
@Vijay Do you really need the output to be like "2017-01-12T22:11:31+05:30" ? Using the standard datetime module it's easy to make it like "2017-01-12T22:11:31+0530", where "0530" is your local timezone offset, but unfortunately there doesn't seem to be a simple way to put a colon into the timezone offset, so that part has to be done manually. Both forms are valid in ISO 8601 date + time strings.
 
mmm, it looks like it's supported by tzinfo, just trying to work out how to implement it
 
Heh. I just scored another upvote on my old Bash random image generator command-line. unix.stackexchange.com/a/289670/88378
@roganjosh datetime.strptime("2017-01-12T22:11:31+0530", "%Y-%m-%dT%H:%M:%S%z") works, but it chokes if you put a colon in the timezone offset.
 
11:45 AM
Yes , I need timezone with +05:30
 
Somehow I ended up with 2.4 docs as my first hit.
tzname( self, dt)
Return the time zone name corresponding to the datetime object dt, as a string. Nothing about string names is defined by the datetime module, and there's no requirement that it mean anything in particular. For example, "GMT", "UTC", "-500", "-5:00", "EDT", "US/Eastern", "America/New York" are all valid replies.
 
Yes
 
So I took that as an implication that somehow it will cope with a colon
 
okay
 
Sorry, was saying that to PM 2Ring. I haven't made progress in actually getting it to output with a colon :/
 
11:47 AM
But How I can get timezone dynamically
 
@PM2Ring looooool
 
:)
 
hey guys I am getting
AttributeError: module 'sys' has no attribute 'last_type'
Why so?
Am I missing something stupid?
 
what is your python version?
 
3.6
 
11:49 AM
(although 2 has it too)
 
It doesn't work in 3.6 for me
 
> These three variables are not always defined; they are set when an exception is not handled and the interpreter prints an error message and a stack traceback. Their intended use is to allow an interactive user to import a debugger module and engage in post-mortem debugging without having to re-execute the command that caused the error. (Typical use is import pdb; pdb.pm() to enter the post-mortem debugger; see pdb module for more information.)
Are you trying to use it as intended? MCVE please.
 
@roganjosh Give me a couple of minutes. I think I've found a neat solution.
 
Why is it undocumented in the link though? Its appearance doesn't constitute anything other than "btw, this exists" to me :P
 
import sys

try:
raise Exception("duh!!!")
except:
print(traceback.format_exception_only(sys.last_type, sys.last_value)))
 
11:51 AM
@roganjosh it's not, it's three items with one description
 
</facepalm>
 
there's a small gap between separate items which is missing from among these three
 
I need only have read a little lower. I don't function on Friday
 
@Mahesha999 the docs says it's primarily to be used interactively. Don't you need sys.exc_info() instead?
also what is traceback? :P
 
11:54 AM
ah, the module, OK
 
is traceback not recommended / un-preferred
 
no, I'm just trying to make sure
 
ok seems that I am unable to understand that "interactive user ..." explanation... :\
 
what is your use case?
 
@Vijay Here you go:
 
11:55 AM
stackoverflow.com/questions/52442569/… no MCVE. It already has a non-answer.
 
# Get the current time
nowtime = datetime.now()
# Add the current local timezone info
nowtime = nowtime.astimezone()
#Format it as an ISO 8601 date + time
s = nowtime.isoformat(timespec='seconds')
print(s)
Or in one line:
s = datetime.now().astimezone().isoformat(timespec='seconds')
 
^ nice
 
@AndrasDeak my server gets request (from clients) on port to execute different things. If error occurs during execution, I have to send back exception type and message (value) in json format to client...so I thought what if I use these variables...
 
Hopefully, you're using at least Python 3.6, otherwise you won't be able to use the timespec arg. And that probably means you'll get microseconds.
 
11:59 AM
@AndrasDeak so read-eval-print loop is one such interactive user scenario...?
I am getting it a bit...but why is it so? why just for for interactive user?
 
I have no idea honestly, I've never used these modules. But the fact that the sys docs says what it says and the official traceback examples say
try:
    lumberjack()
except IndexError:
    exc_type, exc_value, exc_traceback = sys.exc_info()
 
was it impossible to just have them always refer elements of tuple return by sys.exec_info
 
@Vijay Otherwise, this should work:
 
I'm inclined to think that this ^ is what you should be doing
 
nowtime = datetime.now().astimezone()
s = nowtime.strftime("%Y-%m-%dT%H:%M:%S%z")
#Insert colon
s = s[:-2] + ":" + s[-2:]
print(s)
 
12:01 PM
try:
    int('hi')
except Exception as e:
    print(e.args)
 
@Mahesha999 as I understand the use case is that when an unhandled exception bubbles up to an interactive user, there's no python stack because execution has ended, so there's no way to call sys.exc_info(). You're no longer in that code block. But you can go back using the traceback info
 
mm, actually, that's not all the info you need
 
>>> import sys
>>> try:
...     raise Exception('oh noes')
... except OSError:
...     pass
...
Traceback (most recent call last):
  File "<stdin>", line 2, in <module>
Exception: oh noes
>>> sys.last_type()
Exception()
>>> sys.last_traceback()
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
TypeError: 'traceback' object is not callable
you have access to the unhandled exception from the outside via sys.last_...; you have access to the currently handled exception (i.e. inside an except: block) via sys.exc_info
@roganjosh it's not, that's why I didn't suggest that in the first place ;)
 
I just wanted to feel like I was helping
 
You were. Here's a lollipop ---@ ;D
 
12:05 PM
YEY
 
@Vijay Sorry, I forgot to mention you also need from datetime import datetime
 
@Mahesha999 the interactive nature is relevant because if you're running a script non-interactively then you either handle the exception (i.e. you're inside except: and have sys.exc_info), or you don't handle the exception but then it's already too late, and execution has stoppedt
 
now it all makes more sense
point is if there is anything more to it...?
 
More how? The exception info is enough to reconstruct your state in a post mortem. I don't think it gets any more informative than that.
Presumably there's a problem you want to solve; see if you can solve it based on the above. I'm certain you need something like the example I linked
 
Me: Ok, so it returns a dictionary. Have you tried iterating through the keys and values and printing them?
OP: What Should i do?
mmm
 
12:12 PM
I meant if there is any more blend of meaning to "interactive user" scenario. Or what you said is the exact and the only reason for those variable to exist in interactive user scenario.
yes sys.exec_info() is perfectly enough...
 
@roganjosh close as lacks minimal understanding
@Mahesha999 think about what I explained and try to come up with a scenario where it can also be relevant
 
It just amused me. Sometimes I think OP's see a notification and think "yes, I've hooked one!" then proceed to ignore all of the content of said message and just keep hammering the same question
 
well...thanks for those fine points...
I hope docs had some more stuff for a noob
 
What do we do about ancient chameleon questions like this? Rollback and invalidate an answer? Leave it alone? Close it?
Also notice the 32k (wasted) views...
 
That's a mess :/
Does simply removing import re from the start at least give it a better narrative?
 
12:29 PM
Yeah, but asking two separate questions is still bad
 
@Aran-Fey Sad. I'd say roll it back, and edit John La Rooy's answer. He can fix it if he doesn't like your edit. ;)
 
How would I edit it though? It would be obsolete
No point making it a clone of the other answer either
 
@Aran-Fey Asking two unrelated questions at once is bad enough, but chameleoning it like that is really annoying. But it's understandable that people do it. As far as they're concerned it's just one question: "my program doesn't work, how do I fix it?"
 
Well, the guy's got 200k rep, so he probably won't mind the loss of 1 upvote because an answer become obsolete
 
@Aran-Fey You roll back the question, I'll fix John's answer.
 
12:33 PM
Done. It took the OP 4 attempts to make that "I added import re" edit, that's pretty impressive
 
cbg
 
By the way, does anyone know a better "you need to import modules before you can use them" canonical than this?
 
Every upvote is a validation of my self-worth. I mourn every downvote and the dreaded "user removed"
 
If you do it right, "user removed" wins you points because you get back the points you spent downvoting their rubbish answers. :) Sadly, bad answerers are less likely to be removed than bad question askers.
I can't quite figure out what this OP is saying. Their profile says they're in Germany, but I get the feeling that German isn't their mother tongue either. stackoverflow.com/questions/52441524/…
 
I'm trying to iterate over a collection of floats, and calculate the cumulative sum in each iteration. If I use regular old addition, then error gradually accumulates. If I use sum, then it's O(N^2). Is there a third approach I'm missing?
 
12:48 PM
numpy?
 
@Kevin itertools.accumulate? A numpy thing?
 
import numpy as np
np.array([np.pi] * 4).cumsum()
 
If accumulate is implemented similarly to the rough equivalent laid out in the documentation, it would be as accurate as regular old addition (albeit with much less manual work for me, as is often the case with itertools)
 
Note that doing cumulative sums of floats is very prone to errors, especially if you have mixed +ve & -ve numbers, due to catastrophic cancellation. But I guess you already know about that. :)
 
All of my floats are positive and within an order of magnitude of one another, so I don't expect enough drift to actually harm my results. But if there's an easy way to guard against it, I may as well
I'll probably end up using cumsum() once I get around to integrating numpy
 
@Kevin You should be ok then. You could use Decimal but it will be slower.
 
This loop is only the second biggest bottleneck in the program, lagging behind the first by a fair margin, so I can afford to make it less efficient
(by a constant multiplier, hence why I don't want to use sum, which is O(N^2))
 
letter= 'hello world'
obj= {}
for i in letter:
    obj[i]=(obj[i] or 0)+1

print('obj',obj)
why won't this work
 
@vaultah Oh yeah! I'd forgotten about that algorithm. But it was rattling around in the back of my mind. :)
 
I am trying to get a count of all the letters in the text
 
12:55 PM
@Rick Well, uh, do you know what a KeyError means?
 
@Rick obj[i] or 0 is not the proper way of expressing "the value in obj having key i, or 0 if there is no such key"
In general there's no way to do "try this, and if that crashes, use this instead" in an expression
 
well i want it to default to 0 if it is undefined
 
In the specific case of avoiding KeyErrors in dicts, you can use obj.get(i,0)
 
well I also want to overwrite the value too
 
Or, you know, collections.Counter
 
12:57 PM
obj[i] = obj.get(i,0) + 1 should properly overwrite.
Or, you know, collections.Counter.
 
nice it works
 
>>> import collections
>>> collections.Counter("hello world")
Counter({'l': 3, 'o': 2, 'h': 1, 'e': 1, ' ': 1, 'w': 1, 'r': 1, 'd': 1})
 
@kevin you are the man. I don't like using too many abstractions
collection.Counter can't go out of my way to memorize that shiz
 
90% of the modules I know about, are because I kept re-discovering them over and over. Maybe 20,000 hours from now the same will be true with you and collections :-)
 
Counter is pretty handy, and it has some cute methods like .most_common. And you can add & subtract Counters. But half the time I can't be bothered using it, and just use a plain dict. :)
 
1:01 PM
Similarly, I never use itemgetter.
 
I have a preference for recognizing patterns over memorizing ambiguous functions
python is good at trying to do the thinking for you.
 
@Kevin You should. It's about twice as fast as the equivalent lambda.
 
"memorizing" implies active effort. Good functions brand themselves into your mind with raw merit alone
 
I'm ambivalent about Counter. It's great when the stuff you want to do with it aligns with its designer's intentions, but once you deviate from that path it can be really annoying trying to get it to behave. But I guess you could say that about any class. :) My favourite toy in collections is deque. It's simple, with no weird corner cases, and fast.
 
Counter is good for doing exactly and only the one thing that it was designed to be good for. And that's OK.
 
1:10 PM
I guess defaultdict is ok, but I rarely use it, except when answering questions that already use it. Most of the time dict.setdefault is good enough for me. Unless you need a recursive dict.
 
Still mildly bothered that you can't* make an infinitely deeply nested defaultdict without an assignment statement (or some equivalent trick that binds a name to the scope you're using it in)
(*or at least, I've never found a way. Or if I did, I forgot about it)
 
I just noticed in the docs that Counter implements unary +. Which is handy if you want to wipe out items with non-positive counts.
 
\o cbg
 
@Kevin I think you're correct.
 
1:26 PM
I think the specific parameters of this riddle, as I originally posed it many moons ago, was "make it so that d = defaultdict(some expression goes here) binds an infinitely nested defaultdict to d"
 
d = defaultdict((lambda f: (lambda x: x(x))(lambda y: f(lambda *args: y(y)(*args))))(lambda f: lambda: defaultdict(f)))
More readable version:
Y = lambda f: (lambda x: x(x))(lambda y: f(lambda *args: y(y)(*args)))
d = defaultdict(Y(lambda f: lambda: defaultdict(f)))
 
technically it's the same as assignment because you have two defaultdict calls in there
is it not?
 
I don't think so. All I'm doing is using a variable twice, surely that's not against the rules?
 
Not against the ones I've stated today, no.
 
1:42 PM
no, I meant the spirit of the problem
as I imagine what Kevin would like is defaultdict(something_without_defaultdicts) that gives him an infinitely nested defaultdict
 
That's... probably impossible, I think
 
You're right to some extent. All of the solutions I was examining shared a common quality in that the callable I was passing to defaultdict was composed only of built-in types. A solution using defaultdict more than once falls outside of the domain of what I was considering.
And yet, it if it had occurred to me myself to use defaultdict twice, my reaction probably would have been "hey, that's promising" and not "well that's obviously cheating"
 
TIL Use double backslash when using latex directives in docstrings for sphinx/mathjax rendering
 
or raw string docstrings ;)
 
or that (-:
 
1:49 PM
I would like a solution using exactly one defaultdict reference, but that won't stop me from awarding the first place prize to Aran-Fey
[100 quatloos have been credited to your account]
I merely need to establish a zeroth-place prize of 1000 quatloos, now
 
Yay, I'm rich now \o/
 
Future Kevin: take these proceedings into account the next time you pose the defaultdict riddle.
With any luck, at that time I'll be able to find this conversation via search. Unless I search for "defaultdict puzzle" instead of "defaultdict riddle". But I guess this message solves that problem.
 
class fict(dict):
  def __init__(self, *args, **kwargs):
    super().__init__(*args, **kwargs)

  def __getitem__(self, key):
    return self.setdefault(key, fict())

d = fict()
d[2][3] = 1
d['a'][('hi', 3)][10] = 'wow'

print(d)
# {2: {3: 1}, 'a': {('hi', 3): {10: 'wow'}}}
 
2:04 PM
I award you the Plaque of Practicality for finding a solution that doesn't make print(d) display a zillion <lambda> addresses
 
Huh! I don't need to define that __init__ do I?
This will do:
class fict(dict):
  def __getitem__(self, key):
    return self.setdefault(key, fict())
"NotMe: Hey, pir! Why did you name that class fict. Me: Because I just made it up."
are there such things as anonymous classes? clambda?
 
You can make classes by calling type, but you still have to give them a name.
I've been using "fingle" as a metasyntactic variable recently, after reading Terry Pratchett's Eric. In the story, the Creator of the Universe confesses that in his long tenure of creating worlds, he only once forgot to include fingles. None of the inhabitants are consciously aware of their absence, but they are constantly filled with a nameless yearning.
No explanation is given as to what fingles are, since presumably the reader of the book would already know about them, unless they were from that one tragic universe
 
sucks to be them
 
>>> type("fict", (object,), {"__getitem__": lambda self, key: self.setdefault(key, fict())})
<class '__main__.fict'>
 
I read Eric...I was probably around 12 or 14 and I only remember the cover
 
2:14 PM
Only problem is,
 
I'm trying out Audible's $15/month get a book credit per month. I may put that on the list
 
>>> type("fict", (object,), {"__getitem__": lambda self, key: self.setdefault(key, fict())})()[2][3]
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "<stdin>", line 1, in <lambda>
AttributeError: 'fict' object has no attribute 'setdefault'
Supplying a name as the first argument doesn't actually bind that name to anything in the current scope
 
@Kevin You forget to inherit from dict.
 
You should be using type(self)() in place of fict() anyway
 
Oops, copy-paste error. One moment.
>>> type("fict", (dict,), {"__getitem__": lambda self, key: self.setdefault(key, fict())})()[2][3]
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "<stdin>", line 1, in <lambda>
NameError: name 'fict' is not defined
@Aran-Fey Hmm, now we're getting somewhere :-)
>>> from collections import defaultdict
>>> d = defaultdict(type("fict", (dict,), {"__getitem__": lambda self, key: self.setdefault(key, type(self)())}))
>>> d[0][0][0]
{}
 
2:17 PM
Oh, smart. I didn't think of using that class as the factory for defaultdict
 
"Reinventing defaultdict from the ground up is kind of cheating the spirit of the 'no using defaultdict more than once' rule, don't you think?", you say. Violating the spirit of the rules but not the letter is practically a pastime in its own right at this point.
 
Fict = type('Fict', (dict,), {'__getitem__': lambda s, k: s.setdefault(k, Fict())})
obj = d = Fict()
for s in 'cabbage':
    obj = obj[s]
print(d)
# output
{'c': {'a': {'b': {'b': {'a': {'g': {'e': {}}}}}}}}
 
We didn't reinvent defaultdict.
We made a very specific one
 
I can condense the 1st 3 lines to:
obj = d = type('Fict', (dict,), {'__getitem__': lambda s, k: s.setdefault(k, s.__class__())})()
 
But defaultdict is now unnecessary and should only be included to satisfy the requirements
 
2:20 PM
Yeah.
 
I can also use an empty string as the class name. But that's kinda scary. :)
 
Legend tells of a class with no name. It wanders the earth, trying to steal names from those it comes across. Usually with its razor-sharp talons.
 
^ then would () get parsed as a tuple or the class named ''
 
hey, @Kevin. How do you feel about helping a ransomeware developer today?
 
My terms are: 15% of the gross and you agree not to defect against me in Prisoner's Dilemmas
 
2:24 PM
Chaotic Neutral it is.
 
Sick reference Kevin.
 
You can do some fun things with class names :D This one makes a sound every time you print an instance:
>>> alarm = type('\a', (), {})()
>>> alarm
<__main__. object at 0x7f9142ac4860>
 
@piRSquared It's still a tuple. Phew! :)
 
The lexer would spontaneously combust if you told it that the empty string was a legal identifier
 
type('\0', (), {}) doesn't work: ValueError: type name must not contain null characters. I guess that means they're null-terminated C strings.
 
2:27 PM
"Hey parser, I'm about to send you the tokens. You ready?"
"Yes, lexer, go ahead"
"IDENTIFIER IDENTIFIER IDENTIFIER IDENTIFIER IDENTIFIER IDENTIFIER..."
[parser checks watch]
"IDENTIFIER IDENTIFIER IDENTIFIER IDENTIFIER IDENTIFIER IDENTIFIER..."
"Are you nearly done?"
"You're joking, right? I'm not even at character 1 yet. IDENTIFIER IDENTIFIER IDENTIFIER IDENTIFIER IDENTIFIER IDENTIFIER..."
Parser could get to the second identifier and raise a SyntaxError, but he's paid by the hour, so.
 
Are you on the energy drinks again? :)
 
I was yesterday. So this is withdrawl-related psychosis rather than the regular psychosis.
 
hello
 
@Kevin that's okay then... always healthier to keep your psychosis varied...
 
Give the Illuminati a break from beaming telepathic messages at you from all electronic devices, by instead obsessing over why the medical-industrial complex keeps rearranging your organs while you sleep
 
2:36 PM
THEY DO?
 
Only if your insurance covers it.
 
So it's actually a service? Ot is this like the internship thing, they want me to think this is actually a service.
 
Unclear. Their website is even less organized than my wall of tacked-up photographs of mannequins connected with red string
 
Are the mannequins connected with red string or the photos?
 
can someone say to me what is wrong with this: pastebin.com/rzhHureU i get "UnboundLocalError: local variable 'player' referenced before assignment" but i assigned the variable "player" the value 0 at the very start so i don't know what's wrong. Also are my 9 if-statements ehm, retarded?
 
2:42 PM
Cbg
 
Cbg
 
@Alucard Assigning 0 to the global variable "player" won't have any effect on the local variable inside playerturn that happens to also be called "player"
If you're thinking "but I don't want to have two variables named player, one of them global and one of them local. I just want a single global," that's easy enough: put global player inside your function.
 
thanks @Kevin
 
And yes, having nine ifs in a row can almost always be refactored into something smaller.
#Perhaps something like:
x = (sign-1) % 3
y = (sign-1) // 3
if board[y][x] == 0:
    board[y][x] = player
else:
    print("Please choose an unoccupied field.")
 
@Kevin I was almost going to fie you 5 quatloos for encouraging use of a modifiable global, but I guess it's kind of tolerable for the player flag to be a global.
 
2:49 PM
Alucard comes back tomorrow, saying "My program works great, but now it needs to host one million games in parallel. Can I still do that with globals?"
"tictactoe dot biz launches tomorrow and I need this to scale"
 
gotta pray for the scope creep God
SCG to their friends
 
Most likely someone will suggest Docker
 
ditto
oh, cor blimey! I missed my coffee time!
 
@Kevin not happening I promise :D
 
00:00 - 15:0015:00 - 00:00

« first day (2897 days earlier)      last day (2052 days later) »