« first day (2778 days earlier)      last day (2170 days later) » 

4:00 PM
@AndrasDeak no GDPR stuff? ;)
but semi-private bugtrackers are the worst... creating an account just to view bugs... so annoying - even to report one i'd rather not spend more time registering if i don't care about notifications on comments etc
 
probably
 
does anyone know how to grab a value from a command line printed value in linux?
i.e. i run execute a terminal command and it prints 150. I need that 150 in my code
 
how are you running your command?
 
DSM
@ThiefMaster: as I said before and then again and now for the third, and final, time, feel free to suggest the policy should be revised on Meta. Until then, either respect it or find somewhere else to be.
 
@ThePeskyWabbit python your_script.py | echo 150 and then use x = input() in your script
 
4:04 PM
@Aran-Fey uuuuh
pipes go the other way around
 
I'll give it a go thanks
 
why go, not python?
 
@AndrasDeak Huh, you're right. That might explain why I never got the hang of bash scripting...
 
DSM
I've never been able to remember the order when making symbolic links. Is it ln -s target source or the other way around?
 
@DSM Which policy are you referring to?
 
4:06 PM
This seems like a good opportunity to throw in Larry Hasting's very fun talk about dropping the bash and just going the sloppy Python route ๐Ÿ˜€
 
DSM
@StevenVascellaro: this one.
 
@idjaw (clicked)
 
@Aran-Fey for the record, for a string literal you should do python your_script.py <<<150
 
cbg
 
but if I use input() in my code, wouldn't it wait for an input before running the terminal command? I am using os.system(--terminal command--) to execute the command
 
4:07 PM
cbg
 
@aran
 
@ThePeskyWabbit use subprocess instead and read the docs on how to catch the stdout of the process
 
kk
thanks
 
I think that's the proper route, if others start shouting in 2 minutes we'll know it isn't
 
@AndrasDeak I'll have forgotten that piece of information in no more than an hour :p
 
4:09 PM
oh well :P
 
@Aran-Fey I like to think programmers forgetting things is why Stack Overflow exists.
 
I don't forget. I just don't know anything
now where is my upside down emoji
 
One of the best feelings is reading an SO answer, only to realize you wrote the answer yourself
10
 
@StevenVascellaro Fair point, but before I start looking up bash syntax on the internet, I'll change my mind about bash scripting and write the thing in python instead (:
 
wrong smiley alert!
It's left-handed takeover all over again
 
4:14 PM
(: :)
 
This is driving me nuts, I've been on this for days. Can someone help me compile a Python project on Windows. I'm running VS Express 2017 (yes worst of all I was forced to switch from MinGW) . I am getting the traditional vcvarsall missing. Yep I tried stackoverflow.com/questions/2817869/… still not working. I do know where it is though C:\Program Files (x86)\Microsoft Visual Studio\2017\WDExpress\VC\Auxiliary\Build
 
DSM
@AndrasDeak: isn't idjaw left-handed? He looked normal enough when I met him.
 
Only to work out how to tell Python where it is.
 
@DSM did you see him use a knife? That would settle it. Blind panic -> leftie
 
4:28 PM
hey, does anyone know where I could look up X509 versions for specific OpenSSL versions?
Specifically looking to see what certificate is compatible with ssl ver >=0.9.8e
 
got it working. it grabs the integer i was needing from the terminal command now. thanks @Aran-Fey and @AndrasDeak
 
no problem, glad you did
 
@Simon you're trying to install via pip install? What library
 
Nah build my own project.
But the process should be the same.
 
I thought that's what you meant but I followed your link and that is re: install (but I get that the issue is common to both)
 
4:43 PM
isn't there a system environment variable you need to assign it to @simon ?
oh thats what the post is talking about
 
I've never actually done it so I can give it a shot, something to learn, but you'll need to start me off in the right direction and tell me where I can get the code base :)
 
Wait. On a completely different post Use Windows SDK v7.0 compilers, open the SDK shell and call
Nice start `'setenv' is not recognized as an internal or external command,
operable program or batch file.` :(
YES it's working.
@ThePeskyWabbit looks like you were right. Initialise the SDK with set DISTUTILS_USE_SDK=1 otherwise it chucks out an error
 
... I'm not sure I've ever said anything like that, but I'm happy to take credit :P
 
@ThePeskyWabbit Sorry wrong person. :/
 
all good! was confused lol
glad you got it working tho
 
4:52 PM
I feel like going to bed now, but it wouldn't really be right if I did :D
 
DSM
Power move! So speedy!
 
My core competency as an RO is performing tasks that nobody could get mad at me about
 
5:07 PM
Uh, okay; I've never done this chat thing before - is this an okay place to ask for general help and maybe guidance/mentorship regarding a python question? (Since it's 'chatting', I thought that may be permitted, but I don't want to break any rules...)
 
wim
Yes, it is.
 
Yep, if you wanna check out the rules you can look here: sopython.com/chatroom
 
wim
it's intended to be a safe space for people to ask constructive questions, and a place for regulars to hang out that is less strict than the main site
 
I was mildly upset at the rounding error in your name but I see that it's actually SO that made the mistake from your actual profile
 
wim
there are a few room owners that seem to want it to be as strict as the main site, but they are in the minority
 
5:12 PM
Okay, cool, thanks...
 
DSM
I don't know anyone who feels that way, given that pretty much all of the conversation here would be justly flagged if it were a comment on the main site, but then what would I know? ;-)
 
@roganjosh; that's hilarious, thanks. :)
Okay, so I'm trying to work in base64. I just recently realized that it's not a one-to-one mapping from ASCII (or byte values) into b64 characters, more like a 4-to-3 mapping based on bytes (or is it 3-to-4)...
 
Hilarious and tragic. In school we had some weird memory test to see if we could memorise pi to 20 d.p. in 1 minute. 20 years on I still have that locked in my memory :(
 
Okay so that first SQL question from me was for sure rookie level but I feel this one might be intermediate. On this answer theres a program that searches for a string in any column on all tables. It currently returns the table, column, and value or the row it found. Can someone help me get more information on the row? Like all columns for the row it found would be nice.
 
@roganjosh Reduce the font size in your browser & more digits will appear.
@ZackTarr That's not a Python question, so it's not actually on-topic here in the Python room. Yes, we talk about all sorts of stuff in here, but we try to keep the programming questions connected to Python, or generic language-agnostic questions.
 
5:15 PM
I imported the base64 module, and executed the b64 -> ASCII conversion properly (command-line python, 2.7 fwiw), but I'm wanting to hide the hex values that aren't ascii, or just have them 'render' - although I guess rendering in the terminal could result in funky behaviours with command characters. So I guess just hiding is ideal. Any suggestions how I could do that?
 
DSM
Not sure I follow. Which characters aren't ascii?
 
@PM2Ring Yep was just fishing for knowledge. Its being used in a python program, just on the SQL side.
 
wim
I've memorised 20,000 digits of pi. Just got to remember the ordering now..
 
@user3.1415927 It's common for hexdump programs to use a dot for bytes that are outside the printable ASCII range. FWIW, this task is a bit easier in Python 3, using bytes strings.
Here's a hexdump function I wrote when I started on Python 3.6 chat.stackoverflow.com/transcript/6?m=30542743#30542743
 
The quick and dirty way to prevent special characters from doing special things to your output, is to print the repr of the string rather than the string itself:
>>> s = "hello\rworld!"
>>> print(s)
world!
>>> print(repr(s))
'hello\rworld!'
 
5:21 PM
How to simplify this...
 
In this example, the carriage return causes the cursor to return to the beginning of the line, overwriting half of your output. repr escapes the character and renders its escape sequence instead.
 
np.add.reduce(sess.run(tf.squeeze(result2)).transpose([2,1,0]).reshape([2,3,3]), 0)      ))
 
Sample of non-ASCII output:
`>>> b6.b64decode(mys)
':\xff\xab\x03\x01\x01\x11LoadUpdateRequest\x01\xff\xac\x00\x01\x02\x01\x0bBaseRequest\x01`
 
it seems like i'm using some functions both tf and np can do
 
DSM
Ah, so it's the decoded bytestring we want to display. That makes a lot more sense than the other way 'round, which is what I was thinking. :-)
 
5:22 PM
@DSM; sorry, happy to clarify.
 
Here's a Python 2 version of that asclist stuff.
printable = range(0x20, 0x7f)
asclist = [format(u, "c") if u in printable else "." for u in range(256)]
 
DSM
No, it was my mistake, I went in the wrong direction.
 
@Niing isn't add.reduce without an initializer simply np.sum?
oh, there's no initializer
 
DSM
@PM2Ring: I was going to recommend string.printable but I'd forgotten about the whitespace junk at the end. :-/
 
printable = range(0x20, 0x7f)
data = ':\xff\xab\x03\x01\x01\x11LoadUpdateRequest\x01\xff\xac\x00\x01\x02\x01\x0bBaseRequest\x01'
out = ''.join([format(u, "c") if u in printable else "." for u in (ord(c) for c in data)])
print out
#output
:......LoadUpdateRequest........BaseRequest.
 
5:27 PM
Yes, that's quite the trick; thanks!
although, maybe off-topic - I thought I read recently that the for x in ... portion of list comprehension should go at the front of the line; which is it? (I've always used it at the end of the line...)
 
no
good: [thing for x in lst if cond], [thing1 if cond else thing2 for x in lst]
 
@user3.1415927 Translate the list comprehension to nested for and if statements and it's a lot easier to understand.
 
bad: [thing for x in lst if cond else ?????], [thing1 if cond for x in lst]
 
anyone know of a guide on what doc strings should look like considering type hints
 
In Python 3, data would be a bytes string, so you could do:
data = b':\xff\xab\x03\x01\x01\x11LoadUpdateRequest\x01\xff\xac\x00\x01\x02\x01\x0bBaseRequest\x01'
out = ''.join([format(u, "c") if u in printable else "." for u in data])
 
5:29 PM
@user3.1415927 oops, I missed that you asked about the for, not the if
then again I may have answered your question anyway
 
Yep, question answered .. I'll have to find the reference and maybe ask about it another time.
Thanks all!
 
And in 3.6, the out list comp could be:
out = ''.join([f"{u:c}" if u in printable else "." for u in data])
 
it's two different kinds of "if"s, one is a ternary and the other is part of the listcomp syntax
 
It's usually confusing to use an if expression as a comprehension's output expression. You have to look for the else, and then add the parens in your brain, before it makes sense.
Except for the simplest cases, where the expression is just a trivial if-else, and the rest of the comprehension is just for x in lst.
 
DSM
@piRSquared: we use Google style here, so all we needed to do was move the type info from beside the variable names to the signature.
 
5:33 PM
@piRSquared Are you writing 3.6+ code, where the comments are in addition to inline type hints, or 2.7/3.5 code, where the comments are the type hints?
 
yes 3.6+
MCVE
from typing import Dict

def f(i: int, j: str) -> Dict:
    """This is my doc string

    :param i: Integer value
    :param j: String key"""
    return {j: i}
 
DSM
def function_with_pep484_type_annotations(param1: int, param2: str) -> bool:
    """
    Example function with PEP 484 type annotations.

    Args:
        param1: The first parameter.
        param2: The second parameter.

    Returns:
        The return value. True for success, False otherwise.

    """
^ life at NumberFirm (okay, I moved the first line to where I want it)
 
And that's google style? I'm assuming sphinx has an option for google style
 
DSM
Yeah, that's in fact ripped off of the sphinx (well, sphinx-contrib) docs here.
 
Cool! Thx (-:
 
5:38 PM
It's not an option as such; you need the Napoleon extension
 
How dictatorial
 
The two ways to configure sphinx are extensions and monkeypatches, there are no options :/
 
@piRSquared If the parameters don't have any meaning beyond "Integer value" and "String key", the docstrings aren't really telling you anything more than just saying "value" and "key" and letting the type hints specify the types. (Unless your autodoc tools don't understand type hintsโ€”I talked to someone whose team was upgrading from 3.5 to 3.6, but were still standardized on Sphinx 1.1โ€ฆ)
 
I have an opportunity to start fresh and thus start right. I like google style because it seems easier to read. I"ll endure the monkeyextension for sphinx. As for i and j. just silly example to show what PyCharm pukes out when it asks if I want to add parameters to docstring.
 
@wim FWIW, here are the digit frequencies for 20,000 digits of pi (not counting the initial 3), courtesy of mpmath and Counter:
[('0', 1954), ('1', 1997), ('2', 1986), ('3', 1986), ('4', 2043), ('5', 2082), ('6', 2017), ('7', 1953), ('8', 1962), ('9', 2020)]
from mpmath import mp
from collections import Counter
digits = 20000
fudge = 5
mp.dps = digits + fudge
print(sorted(Counter(str(mp.pi)[2:1-fudge]).items()))
 
5:47 PM
someone please chi^2 that and tell me if it's reasonably uniform
 
eyeball test says it is
 
Is your data science eyeball test more reliable than my physics eyeball test? :P
 
My keen eyes tell me that there are more 5s than other digits, hope that helps
 
@AndrasDeak (-: We'd have to generate some data to test it
 
The decimal point is extremely underrepresented, comprising only 0.1% of the first 1000 characters of pi
 
5:51 PM
I heard it only gets worse.
 
Such inequality in 2018!
 
>>> import scipy.stats as spst
>>> dat = [('0', 1954), ('1', 1997), ('2', 1986), ('3', 1986), ('4', 2043), ('5', 2082), ('6', 2017), ('7', 1953), ('8', 1962), ('9', 2020)]
>>> _,freqs = zip(*[('0', 1954), ('1', 1997), ('2', 1986), ('3', 1986), ('4', 2043), ('5', 2082), ('6', 2017), ('7', 1953), ('8', 1962), ('9', 2020)])
>>> freqs = np.array(freqs)
>>> spst.chisquare(freqs, np.full(freqs.shape, freqs.mean()))
Power_divergenceResult(statistic=7.716, pvalue=0.5630004667458498)
please someone tell me what this means
 
There are a couple more decimal points around the quadrillion digit mark. And a snowman emoji? Nobody is sure how that's possible.
 
I think pvalue is the probability that it matches the expected distribution?
So...it's more likely than not that it's uniform. I hope I nailed the statistics.
@AndrasDeak oops, wasteful non-use of dat there
 
ord('.') gives 46. Rest assured that there's also an infinite number of decimal points, just encoded.
 
5:59 PM
There is a certain elegance in calculating pi in hexadecimal. You get BBP, for one thing.
 
"The discovery of this formula came as a surprise". I can verify this statement, I didn't know about it until now and I cannot describe myself as anything other than surprised.
 
DSM
Simon Plouffe's an interesting guy. He used to be active on the seqfan (OEIS) mailing list.
 
@Neoares stackoverflow.com/a/34643081/5290519, it looks like the last one of strides should always be 1
 
Before I looked up that article I assumed it was discovered like eighty years ago.
 
i think tensorlfow is the best playground to practice numpy reshape, transpose, reduceat, etc. and high dimensional arrays become meaningful
 
6:12 PM
Yay. The OP finally re-appeared on that "generate all the tuples" question
 
@Niing the last one is 8
in his example
 
Is the assertion by the OP in this question that this is valid syntax... valid? I'm not sure I can set up a proper test case without domain knowledge, but I've never seen anything like it.
 
I vaguely remember a discussion here that the standard library doesn't provide this, since there's not a big demand for it, and it's easy enough to write:
def call(f):return f()
 
Not even the operator module has something like that, which I found surprising
 
Isn't that just f()?
 
6:21 PM
Relatedly, I'm still mildly annoyed that there isn't a built-in version of lambda x: x
 
Whatever you pass you can directly call. What am I missing?
 
The OP's using it as a function decorator, and you can't write def f():()
 
@Aran-Fey wow
Am I naive for expecting a decorator to keep functionness? Unless f returns another function
 
You should really just click PM2's link at this point :P
 
Hehe, fair enough
I'll do that when I'm back at my laptop
 
6:26 PM
Decorators are supposed to receive a callable, and return a callable, usually of the same type. But they can return anything. Of course, decorators that do return weird stuff are evil. :)
 
evil a negative word. can we agree on goodness challenged
 
cbg
 
def evil(f): return 'hi'
@evil
def test(): return
print(test)
#output
hi
 
Hi guys, I need assistance on this piece of code: dpaste.com/2YCMYJJ
 
> 518 bytes, Python 2
grrr
 
6:37 PM
I am trying to submit 3 dns entries and wondering if there is a way I can assigning dns_1 to first ip, dns_2 to second and so on
I can do it with IP but is there anyway I can iterate dns variables to it all happens in this loop
 
dnses = [
    "server_abc_conn1",
    "server_abc_conn2",
    "server_abc_mgmt"
]
Whenever you have variable names with numbers at the end, that's a tremendous red flag that you should be using a list or other collection instead
 
ahh and do dns[i]
 
I was thinking for i, dns in enumerate(dnses, 1):, but same diff.
 
same difference is such a meaningful oxymoron
 
but "same diff" could be a git thing
 
6:42 PM
"meaningful oxymoron" may itself be a meaningful oxymoron
 
@AndrasDeak wow, way to take a joke
 
I think Andras is worried that newbies feel alienated if their first interaction with the chatroom involves some insider lingo they don't understand, and I also think he has a point
 
my subsequent message explains why I think it's not funny nor in good taste
frankly "if you want to live here learn our language and respect our culture" is something I hear a lot where I live and I'm not particularly fond of
 
@Kevin Why do you want that to be a builtin? Even ignoring the fact that Python isn't curried so you often have to deal with multiple arguments (in fact, all of Python's ridiculously complicated/powerful parameter semantics), almost every case where you'd use something like that in, say, Haskell is a bad idea in Pythonโ€”Haskell's optimizer and debugger understand calls to id; Python's don't.
 
but that wasn't a newbie, and I wasn't alienating them
why are you so hypersensitive to everything?
 
6:51 PM
Thank you for understanding
 
I literally started with "hey is for horses"
no one says that seriously :P
I get where you're coming from, I just don't understand it
I mean, I would if I were serious about it
 
@PM2Ring I've seen decorators that return None when they're all about some side effect, like registering the function to be called indirectly through some other mechanism. I can see the reason for thatโ€”it's just like lst.appendโ€”but on the other hand, a def statement that ends up assigning a global to None feels weird.
 
@abarnert I think the last time I wanted an identity built-in, was when I was writing some variant of a max function. And I wanted to be able to specify a key function, and just use the identity function as a default. But I didn't want to write the function header as def max(x, key=lambda x: x) or as def max(x, key=None): followed by an if key is None: key = lambda x: x block. def max(x, key=identity) would have been comparatively more self-documenting.
 
for i in range(1,4):
    ip_address = ipaddr.IPAddress('10.10.10.0')
    ip_address_dns = ip_address + i
    print ip_address_dns
    print dns[i-1]
This works .. but does n't seems like a good code with i-1
Is there a better way/
 
Yeah. The enumerate approach I mentioned.
 
6:57 PM
that would be the main loop or go under for?
 
If you're asking "would I replace my current loop with that, or add an additional loop inside my loop?", you would replace your current loop.
 
Is Flask's @app.route just a synonym for self.add_rule, or does it call self.add_rule and then return func?
 
ok thanks
 
Never mind; the easiest source code search I've ever tried tells me that it returns the func. So I guess the Flask guys thought a decorator returning None is weird more than a mutator returning a value is weird.
 
10.10.10.1
e
10.10.10.2
r
10.10.10.3
v
# Loop 3 times and add +1 to ip address. Submit DNS record for each dns via post
for i, dnses in enumerate(dns, 1):
ip_address = ipaddr.IPAddress('10.10.10.0')
ip_address_dns = ip_address + i
print ip_address_dns
print dns[i-1]
 
wim
7:12 PM
 
xkcd is along the same lines too, unsurprisingly I guess
 
I've seen more memes about privacy policy changes than I've seen actual notifications about privacy policy changes
 
^
also, cabbages
 
my inbox if chock full of these emails
 
.... maybe I don't check my inbox as much as I should ;)
 
7:17 PM
just on my last page of emails I've got 3 local businesses, an international conference, dropbox, patreon and ebay
I mean last screenful of emails, that's a bit below 20
 
I just did and saw a huge pile of such emails. It was quite cathartic actually because it reminds me that nothing I create on the web is as bad as hotmail/outlook online and it's been a frustrating week.
 
@FรฉlixGagnon-Grenier Maybe we look at memes too much ;(
 
I furiously lack any negative answer to that :/
so, I'm following pluralsights tutorials on Python things (specifically the making a desktop application) and... wow, qt is much easier better for my hair than css.
 
wim
Just used dict.setdefault for the first time in my life
Why does this method exist? isn't d.setdefault(k, v) equivalent to d[k] = d.get(k, v)? if not, how not?
 
7:33 PM
@wim and I'm about to timeit because I have a suspicion that the simplest answer given will work faster
 
Wordlessly reopened that, huh? Well, I don't disagree with that.
 
wim
@Aran-Fey yeah, the dupe wasn't good. didn't say anything about how to union the keys.
 
Half this question is finding which keys need to be filled in anyways
 
I'm not sure that it should have been closed with that dupe but people asking for the "best" method for something that can be solved with a for loop, without trying anything, irritates me as much as me answering in comments irritates you.
 
wim
@Aran-Fey not disagreeing with me for once :) we are making progress
 
7:35 PM
I wasn't sure if I wanted to reopen the question or just add more dupes to the pile, so I decided to close the tab ¯\_(ใƒ„)_/¯
 
@wim I think it is equivalent...
but with setdefault you DRY
plus no explicit pointless rebinding
 
wim
hmm yeah I guess k could be a function call here. good point.
 
the name is horrible though
oh, and setdefault returns the value
 
yeah, it lets you do ugly things like d.setdefault(k, []).append(5)
 
mutating non-None returning method with weird name FTW
 
wim
7:40 PM
@roganjosh They did try something. They converted to a pandas dataframe and back.
 
@wim Check the edit time for that attempt being added. It came after you answered.
 
Truly an impressive attempt.
 
Are there some python decorators that help with POD style structures? I have a large array of a pretty simple class. I wan't PyCharm to give me better code hinting...
 
wim
what is a POD style structure?
 
Tell me if I got this wrong:
def wim(lst):
    keys = set().union(*lst)
    for d in lst:
        for k in keys:
            d.setdefault(k, '')

def akash(lst):
    for data in lst:
     if "name" not in data:
             data["name"] = ""
     if "id" not in data:
             data["id"] = ""

def timgeb(lst):
    all_keys = set(key for d in lst for key in d.keys())
    [{**dict.fromkeys(all_keys, ''), **d} for d in lst]
%timeit wim(lst)
2.71 µs ± 12.6 ns per loop (mean ± std. dev. of 7 runs, 100000 loops each)

%timeit akash(lst)
633 ns ± 19.9 ns per loop (mean ± std. dev. of 7 runs, 1000000 loops each)

%timeit timgeb(lst)
5.94 µs ± 62 ns per loop (mean ± std. dev. of 7 runs, 100000 loops each)
 
wim
7:44 PM
you're probably using the same lst instance each time
 
Unless I've made a mistake (I'm tired, it's possible), it was a bit of a pointless exercise.
 
wim
and invalidating your results
 
ooo, yeah ok
 
@wim Its got "plain old data" (its what we call them in C++. Aka, no associated functions, every member is publicly accessible. In my case it has 4 simple members (2 ints, and 2 numpy arrays)
 
wim
@Mikhail like a struct ?
 
7:45 PM
@wim Basically
 
wim
if you want to be near the bleeding edge, install Python 3.7 and use dataclasses
 
@wim Well, I'm using Python 3.7
 
wim
ok, great
 
I just re-tested. My timings match up with resetting the list.
 
damn @wim, beat me to the punch
@Mikhail heres the PEP for it anyways python.org/dev/peps/pep-0557 btw sup I see you in the lounge p often
 
7:47 PM
So, if I have a bunch of np.arrays but they are only 2 elements, it some very of np.array that avoids dynamic allocation?
 
wim
ndarrays with 2 elements seems overkill
can you just use tuples or complex numbers instead?
 
@wim It was easier to use numpy functions like sum, or absolute value
 
anyone familiar with ffmpeg?
 
wim
fair enough
 
@wim But yeah, it seems like overkill :-/
 
wim
7:48 PM
I'm not sure what you mean by the dynamic allocation
numpy arrays don't do anything like that unless you explicitly resize them
 
@ThePeskyWabbit a bit
 
@wim So, when you make a numpy array, doesn't it call the memory allocator?
So in my case its an ungodly number of calls
 
wim
>>> import numpy as np
>>> np.empty((2,))
array([6.95334834e-310, 6.70192539e-317])
it's just whatever bytes happened to be in memory at the time
 
So, if this was C++, I'd read it it as std::vector<std::vector> which isn't fun compared to std::vector<std::tuple>
 
wim
@roganjosh akash answer is hardcoded keys so it's kind of cheating
in Python 3.7:
 
7:52 PM
@wim I'll give you that
 
wim
@dataclass
class Obj:
    x: int
    y: int
    a1: np.ndarray
    a2: np.ndarray
something like that
 
@wim yup thats exactly what I used
But I still don't like the np.ndarray :-)
also I realized ints are apparently unbounded :-/
Muh RAM
 
DSM
If you have a large number of these objects your code will probably be slow for other reasons than just np.ndarray construction, of course.
 
wim
@Mikhail yep, just like in math. wonderful isn't it!
 
Does anyone know what Python3.5 does differently than Python2.7 when it comes to the `read()` method on a file?

I am migrating some code, and, in Python 2.7โ€”I was able to "file.read().encode('base64')" without a problem (this was the contents of a .wav file); it was then JSON serialized and some other stuff, but everything worked fine
I just switched to 3.5โ€”and keep getting an "... is not JSON serializable" error. I've tried encoding it w/ the base64 module, I've tried encoding it to utf-8 (i didn't think that would work, but tried anyway)
 
wim
7:57 PM
The difference is in Python 2.7 read returns a str and in Python 3.x read returns a str [sic].
 
heh
 
um
maybe you know more about python than i do
but that looks more like a typo to me than a joke (were you making a joke? >.>)
 
wim
it was kind of a joke but also kind of the truth
 
ok, so as someone who doesn't actually get any info. from that
what do i have to do to whatever 3.5 read-returns to make it look like what 2.7 read-returns? :p
 

« first day (2778 days earlier)      last day (2170 days later) »