« first day (2467 days earlier)      last day (2706 days later) » 

00:33
cbg
so, i'm thinking about working on a project in python, but i'm not sure of the best approach
> I'm thinking about what sorts of things would be necessary to create a "Digital Aristotle" type of program (see cgpgrey's video here). One method might be combining Khan Academy's problem/understanding check system and YouTube's videos with an algorithm that checks your performance on problem checks and herds you towards similar videos.
I'm thinking videos of a similar style can be determined by looking at the users who follow that channel and seeing what other channels they follow.
however, I'm not sure if (assuming a set database of problems and videos) machine learning is necessary for the algorithm. i've been watching videos/reading about machine learning but still am confused on whether or not it's applicable/necessary.
01:10
cbg
can anyone check this to see if it holds as a duplicate?
there is a bit more work involved based on what the OP is looking for.
01:42
well nvm...they got it all worked out.
 
2 hours later…
03:12
@heather Programming involves a lot of problem solving and optimisation (in several senses of the word), much like 'applications' and more advanced word problems in algebra, geometry, and calculus - which are the very problems systems like Khan academy tend to be weaker on. I think such a system for programming would be great, albeit difficult to structure into an efficient system to teaching/progressing students.
03:23
hello
 
3 hours later…
05:57
Hello
How to run a program in distributed manner on different computer using python
06:13
recbg
1
Q: How do I filter out expressions from a line of text using Python?

user110327I want to remove words that do not belong to a pre-defined list. For example, if my list is: ANIMAL BIRD CARNIVORE HERBIVORE MAMMAL OMNIVORE My input is like this: (ANIMAL (CARNIVORE (BIRD Peacock)) (HERBIVORE (MAMMAL Goat))) I want my output to be: (ANIMAL (CARNIVORE (BIRD )) (HERBIVORE (...

bag of badness :D
@AkshayKandul that's a bit broad :D
enter that in google.
and read yourself more info on this so that you can narrow your question :D
@AnttiHaapala thnxs for reply but wanted to which packages in python can be used for that purpose.
06:43
@AkshayKandul Like he said, you should read up more on the topic. The package that you will use will depend directly on the narrowed down question, which will also can be easily googled.
06:55
@AshishNitinPatil okay
cbg-ning
07:31
Anyone here nominating themselves for the SO elections this time?
cbg!
 
1 hour later…
08:45
Cabbage
user6845426
09:17
cbg
10:27
Cabbage
user6845426
cbg PM 2Ring o/
@sidnical "I just cant get withdraw() to work so the main window is always there ". Did you ever figure that out? I suspect not, since you mention using Qt instead of Tkinter in later messages. I don't understand what your problem is, the .withdraw method behaves as expected for me on Linux. Here's a tiny demo:
@PM2Ring \o
import tkinter as tk
root = tk.Tk()
root.withdraw()
win = tk.Toplevel(root)
tk.Label(win, text='Hidden root test\nClick "Ok" to close').pack()
tk.Button(win, text='Ok', command=root.destroy).pack(side=tk.RIGHT)
root.mainloop()
Hi, Andy.
11:20
Hi, does anyone know if beautiful soup allows you scrape elements within a form? As at the moment I am having difficulty getting an anchor element within a form. I'm guessing the code is angular js
If you have the element before you pass it to beautifulsoup, it can be accessed. But if it is fetched after an AJAX call, thus, likely not being there in the html passed to beautifulsoup, then no.
Hi there everybody
Having a hard time with tox for testing. Can anybody help me out on this stackoverflow.com/q/44929158/1718174 ?
Take a closer look on update 1 please.
@Vini.g.fer There are a few regulars who are familiar with tox, but they aren't currently online. But they'll see your question later.
@mp252 What Ashish said. Beautiful Soup can only parse a static HTML document, if the page is created dynamically you'll need to use something like Selenium.
@AshishNitinPatil Currently I am using selenium and phantomjs to get the content before I parse it in beautiful soup, I manage to get the content from the the driver, however when I put it into beautiful soup and try to access elements using find_all it returns nothing.
Thanks @PM2Ring!
I'll keep an eye for messages directed to me on the chat room
11:30
@mp252 There are only 2 issues possible in this scenario - 1. Element not present, 2. Element present but you are accessing it in the wrong way (wrong xpath, etc.)
The 2nd scenario is likely, since you are sure that element is present. I'd suggest checking whether the form is in an iframe, then you'd first have to switch to the iframe and then try to access the element.
@Vini.g.fer Good idea, but if they can help they'll probably respond on your question page: it's silly to have the information split between two places, and it will be of more help to future readers if they respond on your question page. But chat can be useful if they need to ask you questions that won't work well in the comments.
Don't know if this was posted here
@AshishNitinPatil ok thanks, will give it a go.
12:24
cbg
12:54
cbg @Andy, good luck with the elections!
Thanks @AshishNitinPatil
cbg, all
@AshishNitinPatil I like the way they are realistic about the required level of dedication - kudos to anyone who spends half an hour most days on SO moderation
yep, dedicating more hours is significantly more important than having more reputation. Because it's moderation, not helping with the Q&A specifically.
I already saw 3 good candidates that I would vote for, one of them is Andy.
But nominations period is active for 6 more days, let's see.
@Vini.g.fer I will mention that AFAIK py.test has been superseded by pytest. As to the rest. 'fraid it will have to wait for someone who knows what they are doing
13:21
cbg \o
Hello, everyone. I have a small stylistic question. I'm maintaining an API with some basic data classes. The usage is that a JSON object is retrieved from a server, and passed to an object constructor as **kwargs. Now, I want to "export" that object back to the json structure that it was created from to update the server. What is a common pythonic idiom for that? Should I add a to_json() method to the object?
or to_dict, I dunno.
I'm a layman but if it's going to return a json, don't call it to_dict
^ allow me to clarify that. If it returns a (json) string, call it to_json, if it returns a dict, call it to_dict.
@holdenweb actually...
I'll return a dictionary, I think, and let the actual method that sends it to the server convert it to json. Makes more sense. I only need it as json for the wire format.
And requests might be able to do that for me automatically anyway.
13:27
having it as dict for most of the time might be useful if you want to manipulate or monitor it in between
Ah, yes, it seems requests.post can receive a dict as a value to the json parameter and automatically convert my dictionary to json when sending. Perfect.
Python isn't my native language, so I was just wondering if to_dict would look ugly as a method name and if there's a more common idiom for that.
morning everyone
if originally you don't have a dict and the method turns it into a dict, I think to_dict should be fine
numpy has tolist() methods for instance
Status: still don't know what to do about logging.
but that's a third-party module
13:30
cabbage
__dict__ will return all of the object's fields as a dict, right?
aw davidism is still talking about how it took me three years to approve his answer on my question
hehe :D
namedtuple has _asdict - leading "_" is there to avoid collisions with field names
@AvnerShahar-Kashtan - it will also give you other internal fields, usually prefixed with '__'
13:32
I read somewhere non-python-specific that in lieu of other guidelines, "as*" should refer to stuff that return views, and "to*" that returns copies. For instance, numpy.asarray returns the original object if it's already an array, but numpy.ndarray.tolist returns (a copy as) a list
well this was a difficult message :|
@AndrasDeak Yeah, that's how I would do it in C#.
Since tuples are immutable, this wouldn't apply
yeah
though you could still try mutating mutables inside the returned dict, right?
That works
Presumably _asdict() just does shallow copy
>>> from collections import namedtuple
>>> tp = namedtuple('tp','x')
>>> x = tp([1,2,3])
>>> x
tp(x=[1, 2, 3])
>>> d = x._asdict()
>>> d
OrderedDict([('x', [1, 2, 3])])
>>> d['x'].append(4)
>>> x
tp(x=[1, 2, 3, 4])
yup
13:37
@AndrasDeak Yeah, well obvs even more kudos to those who give even more time
I'll stick to to_dict. Thanks for your help.
@holdenweb yup yup :)
That tuple is not hashable, tho
@PaulMcG that kind of goes with its mutability, right?
its = that of its contents
Generally, namedtuples are nice as hashable keys, but this only works if all the field values are also hashable
13:39
I assume it somehow hashes recursively?
Immutability is also a good thread-safety characteristic
I'm sure it is the same as hashing any tuple
Is that a yes or a no? :D
if the answer is anything else, I'll google it myself
13:57
trumpet sounds
President Lego enters scene
waves
raises CBG flag
Hello peasants fellow room 6 dwellers
9
crowd cheers; thunderous applause
o/
\o
lego women faint
peasants look around nervously
satisfying nod
14:03
Today I am annoyed by login pages that seemingly load instantly and all the page elements are there, but the loading icon is still spinning, and you enter you username, and you start to enter your password, and it finally finishes loading, and it "helpfully" returns keyboard focus to the first field (the user name field), but you don't notice, and you type the second half of your password in the username field, revealing "Kevin.Kevinsonunter2" to any interested shoulder surfers
That's happened to me too but with 100% password reveal
I've typed passwords into these chat sessions in the past. Extremely annoying having to change my password. Fortunately I am now back using a sane windowing system.
BTW, does anyone know any Android developers? My company is looking, and recommendations are always preferred.
I have appx twenty hours of Android development under my belt. Most of that was cursing at Java.
"Next" ...
Well let's be fair. 90% cursing at Eclipse, 10% cursing at Java.
14:14
But some credit for finding Java unusable
And don't get me started on Eclipse ...
Android development is borderline pleasant when done in the Processing environment
At least easy enough to rough out a prototype
But it is still Java...
use Kotlin instead :p
A lot of my frustration was due to a very slow compile-run-debug-diagnose-correct development loop. Just getting Eclipse to start up a virtual Android device instance took like a full minute.
I enjoyed the couple of hours of Xamarin android dev I did. C# is a much more pleasant language than Java.
@PM2Ring I was trying to setup a tray icon and I needed to launch a main tk window and then hide that so it wasn't shown while the tray icon was running. Ultimately I wasn't finding info on how to do what I wanted with the tray icon so I gave in and started playing with pyqt.
14:20
Hey guys, I'm trying to give different life values for every object I'm putting in to class Enemy and I've tried something like
class Enemy(x):
life = x
since functions worked like this I hoped this might work like this as well bu it didn't go as planned, how can I accomplish my goal?
none of android devs I know use these virtual android devices
But yeah, the compile-debug loop is painfully slow.
I was using my physical Nexus 6p and it was still quite slow.
@IşıkKaplan instance attributes should go inside the __init__ method.
class Enemy:
    def __init__(self, x):
        self.life = x
Likewise, arguments to the constructor should be defined in the __init__ signature. class Enemy(x): means "the Enemy class inherits from the parent class x", which doesn't sound like it's what you want
@MorganThrapp did you use hot swap?
@Kevin Do I write it as Enemy(5) after defining init function?
14:22
with android proper env setup is crucial
@marxin I have no idea. I just plugged my phone into my computer and then selected it in visual studio.
@IşıkKaplan Yes, that should give you an Enemy instance whose life attribute is 5.
Quite puzzled that this Python bug has been around for 3 years, been reported since 6 months, makes warnings very cumbersome to use, yet nobody but me appears interested :-/ (SO question on workaround got me a tumbleweed)
@Kevin Thank you, that solves my problem!
@sidnical Oh, ok. Sorry I can't help you with the tray icon stuff, I don't use Windows.
14:30
when I wrote my silly little app, the virtual device wouldn't boot up in like 15 minutes, so I ended up testing on my phone live instead
14:44
@idjaw we <3 peasants!
user5969682
hey, what's wrong with the line 73 in dpaste.de/YyCo , i get an syntax error unexpectedly
ok for those of us who are challenged do you mock requests effectively. if you use .json() you can't just directly mock it without adding a .json() method on your mock
@AbdullahUYU add a closing bracket at the line 72
user5969682
bracket ??? in python
:|
just look at that line
user5969682
14:54
i can't see any reason to have syntax error
well, line 71, anyway "the line before the error"
Is it possible to call two function from a class without repeating the object?

class Name:
def first_name(self,name)
print("Işık")
def last_name(self,name)
print("Kaplan")

a = Name()

From here instead of a.first_name a.last_name is there something like a.first_name.last_name?
1 min ago, by vaultah
@AbdullahUYU add a closing bracket at the line 72
also, it's better to quote the error message literally next time (not necesssary now, because we have the cause of the error)
@IşıkKaplan please read this for formatting code in chat.
user5969682
don't judge me but do you mean this dpaste.de/2miN#L72 :)
14:56
I do judge you
@AbdullahUYU how did that happen?
did you try to stop, read and understand before trying to fix?
garlic... bleh
@Kevin the sandbox link on your delightful tutorial might need a bit more strict wording. Hypothetically, someone might read "Want to experiment with these techniques, but don’t want to bother users already talking in a programming room?" and conclude that they don't worry about bothering others, and start playing around here.
@IşıkKaplan what problem are you trying to solve? this feels like an XY problem
user5969682
of course i did, at line 73 i am defining a varible named pltname. all my doubt is about time.ctime() 's type, and it's string.
@IşıkKaplan as for your Y in your XY: a.first_name is the first name itself, so a.first_name.last_name would refer to the last name of the first name, which wouldn't make sense semantically. Instead you should define an a.full_name that perhaps calls a.first_name and a.last_name under the hood.
7 mins ago, by vaultah
@AbdullahUYU add a closing bracket at the line 72
15:00
@AbdullahUYU read line 72
6 mins ago, by Andras Deak
well, line 71, anyway "the line before the error"
that's enough ^
read those two yamming lines around your error, and read what vaultah told you
you need to pull your weight for the rest of the way
@enderland In the above code I want to print first name and last name in the same line
@IşıkKaplan why not have a "full_name" function
15:02
man, none of the answers here really make me feel good about their approaches stackoverflow.com/questions/15753390/…
@enderland That obviously makes more sense, but I'm a bit too curious for no reason. Is there a way to do it elseway?
@IşıkKaplan not the way your current setup is working
you could do something like:
In programming, there are almost always more than one way to solve a given problem.
there's possibly also a "difference between print and return" problem hidden here
15:04
class Name:
    def __init__(self, first, last):
       self._first = first
       self._last = last

    @property
    def first_name(self):
        return self._first

    @property
    def last_name(self):
        return self._last

    @property
    def full_name(self):
        return self._first  + ' ' + self._last


n = Name('Işık', 'Kaplan')
print(n.full_name)
print(n.first_name + ' ' + n.last_name)
something like that
so much unnecessary indirection
@davidism lol I'm assuming the example is a basic example.... :| maybe not
also, half the chat window taken up with anti-garlic
You should generally not write a property that simply returns an attribute. Just do self.first_name = first in the __init__ and access it directly
the most minimal solution is print("Işık Kaplan")
15:08
@AndrasDeak technically if it's python 2 it can be more minimal ;-)
plz don't burn the heretic!
user5969682
@AndrasDeak oh i see it, actually python distracted me, it said line 73 and i didn't need to look at line 71.
it didn't say that you didn't need to look at line 71 (we did)
For future reference: I'll be ignoring your messages in chat. Good luck!
>> comes back, sees garlic, backs out slowly.
user5969682
sure, but i have to say that i couldn't express myself well due to linguistic reasons.
:38190251
class Name:
   def first_name(self,name):
      return("Işık")
   def last_name(self,name):
      return("Kaplan")

a = Name()

print(a.first_name, a.last_name, end="")
@davidism Uhm, is this correct?
15:13
+1
@IşıkKaplan did it work? I'd say it's mostly useless right now, but yes, that's how you use end.
@davidism It says invalid syntax, god I'm never gonna able to learn this
I think I broke it, I tried to run it again and
<bound method Name.first_name of <__main__.Name object at 0x00B2A350>> <bound method Name.last_name of <__main__.Name object at 0x00B2A350>>
stop using Python 2
@IşıkKaplan it sounds like you don't have a firm grasp of Python yet. Unfortunately, this room isn't the place to be led step by step through the learning process. Please read a tutorial or two: sopython.com/wiki/What_tutorial_should_I_read%3F
@davidism Thanks, I'll be back in one week with more knowledge hopefully with questions much harder than these. Bye!
Seconding a tutorial recommendation. It's not productive to try random syntax like class Enemy(x): in the hopes that it works. Getting a good foundation from reading the docs will yield dividends faster than raw experimentation with no guidance
15:19
We don't care about how hard the question is, we care about you having the baseline for us to work productively with you.
this is impossible in python, right?? (assuming you need to call print or something, and don't rely on REPL output as in the python answer already given) codegolf.stackexchange.com/questions/132786/…
@LangeHaare why would you think it's impossible in Python?
cbg heather \o long time no see
@MooingRawr I don't know any way to print that is made up of doubled-up characters
15:22
@LangeHaare codegolf.stackexchange.com/a/133021 literally got answered in Python... from the same question :\ :D
@MooingRawr yep but look at the comment on that answer and the caveat in my message above!
@LangeHaare never say never. Are you familiar with quines? Based on what my impression of programming languages is, those shouldn't exist.
@AndrasDeak yeah! There's lots of clever similar things on codegolf - eg this one is doing something quite similar codegolf.stackexchange.com/a/129466/71554
At a glance I can't think of an obvious way to do it. print gives a NameError when it doubles to pprriinntt, and sys.stdout.write gives a SyntaxError when the periods double.
Not that you'd be able to use imports anyway, since iimmppoorrtt ssyyss is also a syntax error
rb folks
15:30
anyway I can't figure out a way, thought I'd throw it open to the room and see if anyone had any strokes of genius!
Potentially useful: The program
"""
a
"""
b
Doubles to
""""""

aa

""""""

bb
a is just a string literal in the original program, but it actually gets evaluated in the double program.
can't think of a way to use print, pprint, sys.stdout, eval or exec... or any other way to produce output
let's start a petition to rename pprint to pprriinntt
@Kevin True, but not a, actually aa is evaluated - and I don't think there's anything printy made up of doubled-up characters
None of the built-in functions double to an existing name, you can't import, you can't use exec or if or while or for or try or yield or def or class...
yep... so I think it is probably impossible
unless there's some bizarre whitespace/comment trick I haven't thought of
15:37
Then Python is not Turing complete!
Take that Python 3 advocates!
@PaulMcG That would explain a lot!
I'm 99% confident that it's not possible. Possibly a clever trick exists involving comments/docstrings/line continuations/trigraphs, but it's way off the beaten path
A catalog of wizard types: wizardindex.com
Jul 7 at 13:11, by Kevin
unrelated: https://www.sbnation.com/a/17776-football/chapter-1 looks interesting but the images are loading way too slow on my work machine. Posting this so I can find it later at home.
Follow-up: this turned out to be really good. Everyone go read 17776 when you have a spare hour or so
15:52
I'm really upset this name was taken: skeletor.readthedocs.io/en/latest
Like...legit upset.
Back to the drawing board.
You don't need to know anything about American Football despite the ostensible source material
and that teams keep trying to walk it in
@idjaw what are you trying to name?
I want to make a skeleton project for future projects that usually follows a software pattern I always go for. So I wanted to make life easier for me to have stuff ready to use
@LangeHaare a utility that removes all comments and obfuscates all function/class/variable names? it skeletonizes the code?
15:54
I was going to call it skeletor
:(
@enderland lol that's actually pretty funny
Why the yam is datetime.datetime.utcnow() timezone-agnostic?
Isn't UTC always timezone-agnostic?
UTCCST?
No - to get proper UTC datetime, I need to do utcnow().replace(tzinfo=timezone.utc)
Which I can only do in Py3.5 and later, with timezone class added to datetime
>>> import datetime
>>> datetime.datetime.utcnow()
datetime.datetime(2017, 7, 18, 16, 0, 8, 600133)
you mean that doesn't return the right value for you?
16:01
>>> datetime.utcnow().replace(tzinfo=timezone.utc).timestamp()
1500392978.82394
>>> datetime.now().timestamp()
1500392985.656832
>>> datetime.utcnow().timestamp()
1500410991.858158
I get a good datetime, but its timezone-agnosticity makes timestamp() compute incorrectly
DSM
DSM
Midday cabbage for all.
5 PM cbg DSM!
I was trying compare timestamps returned from two systems, one with timezone set to my local tz (America/Chicago), and one set to UTC. The one set to UTC is only running Py3.4, so I could not import timezone, so had to use agnostic timestamps. Clocks appeared to be off by 5 hours
you cant compare timezone naive and timezone aware datetimes
Well, I knew that, I was unaware of timestamp()s implicit conversion to UTC
16:17
guys help I broke everything forever
DSM
DSM
There, there. Have some frog.
Hey, look at it this way, you get a nice early retirement.
someone wiped my configs in the database... not happy about it :\ (at least I still have my sql script that populates the tables so I can re run it but still!!!)
ok. I'm sick of this. when mocking requests, I can use requestsmock which works _perfect_ -- however, I cannot easily validate that I am always using the same requests session, since that mock overrides it.

but, if I use a mock, then I have to implement a fairly sophisticated mock response object (or ops like `.json()` fail on the mock return results)
On another note, I got my hands on these panda cookies, and they are sooooo good D:
16:22
I think I could implement my own "mock response" object which implements all the required functionality, but that seems a bit silly to have to do
@MooingRawr from panda import cookies
just implement what's needed
possibily you use just json() and status_code
@marxin probably. but that seems like a common enough problem someone should have solved it by now
@AndrasDeak from 🐼 import 🍪
7
:D
:D
probably a syntax error...right?
I need to construct a language where unicode animals are letters.
16:24
I bought the random pack ones where inside is either, vanilla, chocolate, or strawberry filling. It's so random.
I want in on that language so fast :D
https://chat.stackoverflow.com/transcript/message/38189434#38189434
Thank you kind stranger, the upvote should prevent the question from being deleted as abandoned :)
@PaulMcG Ah. Timestamps that used local time would be insane on a network that spans timezones. Wiki says «Unix time (also known as POSIX time or epoch time)[citation needed] is a system for describing instants in time, defined as the number of seconds that have elapsed since 00:00:00 Coordinated Universal Time (UTC), Thursday, 1 January 1970,[1][note 1] minus the number of leap seconds that have taken place since then.»
Shame about those leapseconds, though.
@gerrit My pleasure.
😄 = 🍪.☕()
🐍 = 😄[🐙]-🙀()
🐳(🐍)
Image all the possibilities!
we would be supporting the emoji industry and introducing younger generation to coding.
in javascript you can
there must be an emoji-based esolang? surely?
16:32
Until Unicode accepts the combining heart above proposal, it will fail.
@marxin You can use Unicode in identifiers in Python 3, but they have to be valid letters, so you can't use emojis.
@PM2Ring sounds like @idjaw's skeltetonizer could also convert things to emoji!
The only illegal symbol in an identifier I've ever wanted to use is ∂
its not possible to use emojis in JS :( just some unicode chars, not sure which ones
@PM2Ring thats a shame
almost racism I would say
θ = 1
>>
🐼 = 1
>>SyntaxError: invalid character in identifier
This is animal cruelty... :( Free the Pandas, free the snakes :(
DSM
DSM
[Wrong window.. happens about once a month like clockwork..]
:D It's that time of month for you DSM ? (it's a joke please don't smite me :\ )
DSM
DSM
Unfortunately all of my funniest responses are inappropriate for a public room, so you're safe. :-P
why doesn't json.loads take multiple strings... grg
DSM
DSM
16:44
What would the advantage of that be?
@DSM when you have to rewrite response.json() for your mock it'd let you avoid doing the dict combining... :(
why would you need to rewrite json.loads ?
err, I have to rewrite the .json() function for my mock response object
@marxin If unicodedata.category() says it's a letter, it should be valid to use in identifiers. Allowing other codepoints is just silly, IMHO. Frankly, I'd prefer it if people stick to pure ASCII for identifiers.
I understand wanting to use general Unicode in literals, but even then I'd prefer it if they used escape sequences if they want to make the script available for general consumption, unless it's a language specific script. And of course if the script is for private use only, then they can do whatever they like. But if they stuff it up, they better not post it on SO and expect us to help them fix it. ;)
basically this doesn't work, which would be nice if it did:
    def json(self):
        return json.loads(self.text, self.headers)
16:47
Jinja would like if people just used ASCII identifiers too. Instead, we have to load this monstrosity into memory for lexing: github.com/pallets/jinja/blob/master/jinja2/_identifier.py. Which isn't that bad compared to the previous version before I used ranges.
@PM2Ring but isnt it nice:
>>> З = 2
>>>
DSM
DSM
@enderland: but what would that do?
@DSM magic :D
as in, it'd magically know you will never submit collisions ever
so it can just add everything to a root dict
@enderland as far I know json() function in requests just does json.loads(self.content)
or something similar
you possibily dont want your mock do something else :d
DSM
DSM
What dict are we talking about? json.loads could return a list. (Or an int, a float, a string..)
16:49
the main problem is backwards creating "self.content" -- I am using the headers/text fields of the mock response, since that's what my code uses (but the requests response magically converts the full text to that)
@PM2Ring - so I can safely compare across nodes if both sides use datetime.now().timestamp() or datetime.utcnow().replace(tzinfo=timezone.utc).timestamp(), but not datetime.utcnow().timestamp()
DSM
DSM
[Hmm, we have four site mods lurking in the room at the moment. Suspicious, suspicious..]
basically want to avoid this:
    class MockResponse(mock.MagicMock):
        def __init__(self, text='', headers=''):
            self.text = text
            self.headers = headers
            super().__init__()

        def json(self):
            t_dict = json.loads(self.text)
            h_dict = json.loads(self.headers)

            return json.loads(h_dict.update(t_dict))
@PaulMcG so actually its because utcnow() aligns time to UTC and returns naive datetime, and timestamp() again aligns to UTC, is this what is happening?
16:52
makes sense
the only thing i find strange is that your difference was 5 hours, common sense says that shift should be divisible by 2 (shifts twice by the same value)
but no worries, just wondering :p
@enderland - ChainMap?
from collections import ChainMap
return dict(ChainMap(json.loads(self.text), json.loads(self.headers)))
@PaulMcG I don't know why datetime.utcnow().timestamp() does that; OTOH, I don't have high expectations of the datetime module. For more details ask Antti Haapala what he thinks of datetime. ;) FWIW, when in doubt, get the timestamp directly from time.time().

« first day (2467 days earlier)      last day (2706 days later) »