|
accipter posted:I just wanted to point out Pendulum: http://pendulum.eustace.io/ . It looks like it solves a number of datetime's issues without some of arrow's issues.
|
# ? Jul 11, 2016 21:19 |
|
|
# ? May 9, 2024 11:26 |
Would anyone reasonably familiar with python's (2) struct module mind looking into my problem? I'll post the quote describing it below, sorry for poor formatting and such. Spent better half of this day breaking spears against it at no avail, so likely it's something dumb and obvious.kalstrams posted:ffs this struct thing is getting annoying I'm struggling to understand the problem since I can't easily reproduce it on the machine where I am able to use debugger. I can get the exact same error on the exact same data, but it's on a remote workstation, and my personal computer might not be able to handle this exact computation in the event that I had data in situ.
|
|
# ? Jul 12, 2016 03:20 |
|
kalstrams posted:Would anyone reasonably familiar with python's (2) struct module mind looking into my problem? I'll post the quote describing it below, sorry for poor formatting and such. Spent better half of this day breaking spears against it at no avail, so likely it's something dumb and obvious. Unpack is being given an argument of the wrong length. Try running that long set of calls line-by-line and check that the object being returned by storage.read(line_bytes) is actually line_bytes in length.
|
# ? Jul 12, 2016 07:09 |
QuarkJets posted:Unpack is being given an argument of the wrong length. Try running that long set of calls line-by-line and check that the object being returned by storage.read(line_bytes) is actually line_bytes in length.
|
|
# ? Jul 12, 2016 11:30 |
|
kalstrams posted:Beats me how that could be possible but at least now I know where and how to look. Cheers! Not sure about your file format, but one reason could be your seek statement... Do you want to skip the pointer or to where your pointer is pointing?
|
# ? Jul 12, 2016 16:06 |
yippee cahier posted:Not sure about your file format, but one reason could be your seek statement... Do you want to skip the pointer or to where your pointer is pointing?
|
|
# ? Jul 15, 2016 02:35 |
|
I'd be willing to call myself an advanced beginner Python programmer, and I just completed a small project that someone actually paid me for! Iterating through the project made me realize I need to start implementing better testing into my design. I've already completed the project and I want to go back and build it again using TDD. For the life of me I can't figure out where to start. Does anyone have any good reads or tutorials on test-driven design? I've found a couple that show TDD with Django, but I'm not really looking to get into the whole Django workflow while learning TDD.
|
# ? Jul 15, 2016 16:24 |
|
This is a pretty basic question, but can I get a good tutorial to help me understand in the ins and outs of classes in python? Something about them makes my eyes bounce off them and brain refuse to understand how they work, no matter how many pages about them that I google and read. This is despite understanding the concept of objects (or so I think).
|
# ? Jul 16, 2016 00:50 |
|
jon joe posted:This is a pretty basic question, but can I get a good tutorial to help me understand in the ins and outs of classes in python? Something about them makes my eyes bounce off them and brain refuse to understand how they work, no matter how many pages about them that I google and read. This is despite understanding the concept of objects (or so I think). Is this your first time using classes in general, or just classes in python?
|
# ? Jul 16, 2016 01:41 |
|
QuarkJets posted:Is this your first time using classes in general, or just classes in python? For functional purposes, let's say in general, but I'm interested in python specifically. I've used them before in various online courses, some python and some not, but I just can't wrap my head around writing my own from scratch from an idea in my head. It just feels like there's so much going on, and trying to read examples of them is resistant to my attempts to understand.
|
# ? Jul 16, 2016 01:57 |
|
i can tell you a few unhelpful lies, but the nature objects is finicky when you consider EOL'd python (2.7 and below), so i'll cover how objects work in python 3 and new style objects in python 2. just use class Foo(object): in python 2, don't ask. so, in python we have dictionaries. we can get from them: del d["key"], we can set them d["key"]=1 and we can get them d["key"] objects sorta work the same way, they're kinda like dictionaries, except we use foo.bar instead of foo["bar"], and python does *magic* behind the scenes when you lookup an object's attribute code:
code:
instances are really just a wrapper around a class, an a dictionary for attributes code:
if python can't find 'bar' in the instance dictionary, it looks it up in the class instead, but classes are where the magic starts to happen for foo.bar code:
code:
you can think of foo.bar being partially appliying foo.__class__.bar(self=foo), if you want to, i guess code:
there is no special this or self keyword, python's self is just named thay by convention, and it's a lexically scoped variable too, so no more "var that=this" as seen in other languages recap: so, objects all wrap some dictionary (o.__dict__) which stores attributes. when you call foo.bar, you're looking up bar inside foo's dictionary when you lookup an attribute of a class directly, or lookup something inside an instance, no real magic is performed classes are just wrapped dictionaries of functions and values too. when an instance calls up to the class to find an attribute, it perfoms binding, turning the function into a bound method - where the first argument is the instance itself i'm too tired and i dunno how accurate my memory is but from here you can start to explore the metaobject protocol: a class with __getattr__/__setattr__ methods can start to change the behaviour of `foo.bar` it is worth shouting out to descriptors, which allow you to overwrite foo.bar by setting methods on bar, not on foo.
|
# ? Jul 16, 2016 02:14 |
|
there are plenty of places where this is not true but it's a reasonable set of lies to go on i hope
|
# ? Jul 16, 2016 02:16 |
|
jon joe posted:This is a pretty basic question, but can I get a good tutorial to help me understand in the ins and outs of classes in python? Something about them makes my eyes bounce off them and brain refuse to understand how they work, no matter how many pages about them that I google and read. This is despite understanding the concept of objects (or so I think). Forget objects - you don't need them!
|
# ? Jul 16, 2016 02:27 |
|
It's true that you don't necessarily need them but objects be useful sometimes
|
# ? Jul 16, 2016 02:37 |
|
there's a reason i didn't cover super.
|
# ? Jul 16, 2016 02:40 |
|
Dominoes posted:Forget objects - you don't need them! That's another thing I don't get. Do objects really do anything besides organize code and change the syntax? I like to be able to go dictionary[dictionary][thing], can I go class.class.thing? Do I -want- to go class.class.thing? Will a function I call from a class be different from a function I call from a dictionary? Can I even pass variables into class.class.thing like I can dictionary[dictionary][thing], ala class.class.x, x = thing? And what's the deal with airline food? All signs point to no, and also airlinefood.deal points to crashing the IDE. Emmideer fucked around with this message at 03:20 on Jul 16, 2016 |
# ? Jul 16, 2016 03:18 |
|
Objects are useful some percentage of the time. a large part of the rest of the time they don't really bring anything to the party, but they don't hurt either unless you don't understand them. The rest of the time they actively make code worse.
|
# ? Jul 16, 2016 03:29 |
|
Thermopyle posted:Objects are useful some percentage of the time. Could you give some examples of when and why this would be? Thermopyle posted:The rest of the time they actively make code worse. Examples of this would may also be interesting, if only for entertainment purposes.
|
# ? Jul 16, 2016 03:34 |
|
jon joe posted:Examples of this would may also be interesting, if only for entertainment purposes. https://www.youtube.com/watch?v=o9pEzgHorH0
|
# ? Jul 16, 2016 03:36 |
|
jon joe posted:That's another thing I don't get. Do objects really do anything besides organize code and change the syntax? There are a few extra features, like inheritance, but otherwise, nope! They're just organizing code and changing the syntax. jon joe posted:I like to be able to go dictionary[dictionary][thing], can I go class.class.thing? Do I -want- to go class.class.thing? Will a function I call from a class be different from a function I call from a dictionary? Can I even pass variables into class.class.thing like I can dictionary[dictionary][thing], ala class.class.x, x = thing? You can do that if you want, but some people consider more than two dots like that to be a sign of bad style. The interesting thing about functions you call from classes is that they will automatically have the class passed to them. For instance, if you do this right now: Python code:
It might not seem like much to you right now. That's OK. You don't have to use classes any time soon. Come back in three months and you might understand better.
|
# ? Jul 16, 2016 03:38 |
|
You technically can't do dictionary[dictionary][thing] because dictionaries aren't hashable. But I don't think you really intended to do that, you just meant dictionary[thing][another_thing], so I apologize for the pedantry.
|
# ? Jul 16, 2016 03:48 |
|
SurgicalOntologist posted:You technically can't do dictionary[dictionary][thing] because dictionaries aren't hashable. But I don't think you really intended to do that, you just meant dictionary[thing][another_thing], so I apologize for the pedantry. yeah, where thing in dictionary[thing][another_thing] is a key pointing to dictionary containing the key of another_thing I think If this is also wrong I'm sorry
|
# ? Jul 16, 2016 03:50 |
|
No that's not wrong. Nested dictionaries are a thing. I was just making sure you weren't asking about passing a dictionary to itself.
|
# ? Jul 16, 2016 05:46 |
|
It's also interesting to note that everything in Python is an object. Python code:
|
# ? Jul 16, 2016 06:16 |
|
jon joe posted:Examples of [OOP making things worse] would may also be interesting, if only for entertainment purposes. https://github.com/crsmithdev/arrow/pull/327/files Technique-only- Times I use objects: Something that can be thought of concretely as an object in the world Something that's like a new datatype I have a pile of related functions that take a large number of args. An API requires them, like GUIs or ORMs. NamedTuples are nice and have object-like syntax. If a class ends in 'er', watch out! Dominoes fucked around with this message at 11:21 on Jul 16, 2016 |
# ? Jul 16, 2016 11:12 |
|
Just a quick PSA that the talks at Scipy 2016 are going up on YouTube right away and seem to be unusually good. Not that they're not usually good. Just that I'm more impressed than usual. JupyterLab(https://www.youtube.com/watch?v=Ejh0ftSjk6g) looks awesome. I know we have some posters there who may also be giving talks, godspeed!
|
# ? Jul 16, 2016 15:08 |
|
This is going to sound rather silly, but how do I do this:code:
edit: removed .items() because apparently that works different in python 3.5 which is what I am using. Still same problem, though. editedit: Got what I wanted. Behold my terror: code:
Emmideer fucked around with this message at 17:01 on Jul 16, 2016 |
# ? Jul 16, 2016 16:18 |
|
There's no actual loop because you're only doing an operation once. The operation is "tuple unpacking". Pretty sure this should work in 3.5:Python code:
Python code:
|
# ? Jul 16, 2016 16:55 |
|
SurgicalOntologist posted:There's no actual loop because you're only doing an operation once. The operation is "tuple unpacking". Pretty sure this should work in 3.5: Oh that's much better than my horrible solution (and yeah, I figured out _list was a terrible idea, haha)
|
# ? Jul 16, 2016 17:00 |
|
Which is better:code:
code:
|
# ? Jul 17, 2016 04:50 |
|
jon joe posted:Which is better: Not bad solutions. But I think you'll be pleased to learn about defaultdict. Python code:
\/\/ Agreed. SurgicalOntologist fucked around with this message at 05:17 on Jul 17, 2016 |
# ? Jul 17, 2016 05:04 |
|
jon joe posted:Which is better: If you don't want to go with defaultdict (why wouldn't you), it think the snippet below is nicer. Python code:
|
# ? Jul 17, 2016 05:11 |
|
Aha, yes, default dict does make it much shorter/intuitive/(faster?). Though, interesting enough, it also does this: defaultdict(<class 'dict'>, {}) Which, I'm not sure the full implications of.
|
# ? Jul 17, 2016 05:24 |
|
That's just defaultdict's string representation. In this case it's saying "I'm a defaultdict, my default is value is the class 'dict', and I'm empty". Try adding some items and looking at it again, and try other defaults as well, e.g. defaultdict(list), to get a better sense of what it's showing you there.
|
# ? Jul 17, 2016 05:39 |
|
Any word on if Tensorflow is coming to Windows? Docker's a PITA I couldn't get working. At the bottom of the last page, I posted a library I'm working on for plotting functions; a thin wrapper for matplotlib that has easy syntax and sensible defaults. Any suggestions? It's helping me visualize things from Khan Acad's multivariate calc class, and I'd like to get it in a state where others can use it. Need feedback since I've only tailored it to my use case, and I'm not sure what others might use it for that I haven't covered. Here's a specific one: Is there a way to draw a 2d graph on the axis of a 3d one? Like have a surface plot, with its direction derivative vector field on the x/y plane? Would it be weird having a general plotting function that analyzes the number of inputs and outputs of your function-to-plot, then automatically figures out a type of plot to draw? Or is that too 'arrow.get' ? (ie, if there's 1 in, 1 out, draw a 2d graph; 2 in 1 out, draw a surface or contour, 2 in 2 out, draw a vector field.) Dominoes fucked around with this message at 11:41 on Jul 17, 2016 |
# ? Jul 17, 2016 11:32 |
|
defaultdict is the right answer, but you should google LBYL and EAFP and their pros/cons.
|
# ? Jul 17, 2016 17:36 |
|
Thermopyle posted:LBYL and EAFP and their pros/cons.
|
# ? Jul 17, 2016 17:39 |
|
Hey so I was updating my anaconda's pyside today and anaconda appears to have completely hosed itself; the Python and conda binaries are completely gone. Anyone else ever have this issue (on a centos system)?
|
# ? Jul 18, 2016 23:23 |
|
|
# ? May 9, 2024 11:26 |
|
QuarkJets posted:Hey so I was updating my anaconda's pyside today and anaconda appears to have completely hosed itself; the Python and conda binaries are completely gone. Anyone else ever have this issue (on a centos system)? I haven't heard of or seen anything like that. Feel free to shoot me details in a PM if you like, and I will try to see if anyone here has anything to say. Edit: My SciPy tutorial is up! https://www.youtube.com/watch?v=LXLQTuSSKfY Speaking of JupyterLab, I am so infinitely much more excited by it already than I have ever been by the notebook. The cross-org team working on it is pretty phenomenal. BigRedDot fucked around with this message at 16:01 on Jul 19, 2016 |
# ? Jul 19, 2016 15:59 |