|
uhhh...quote:Developers are often guys that live on another planet. Some think this is because software development is so exciting that everything else is poorly considered. We are deeply convinced that most developers do not enjoy themselves. They spend their lives together with complex problems that never go away from their minds. Nobody understands them. Their family? Their managers? Their clients? Their friends? No. Nobody. Nobody is able to imagine how huge and complex their tasks are. Consequently, what they do is underestimated. Worst: they can't communicate. Don't believe this is due to some intrinseque geek attitude. Their geekness results from the global incapacity to apprehend the very nature of their abilities. So they are forced to work harder while experiencing the true impossibility to share their permanent software experience. Of course, it may lead to social disasters.
|
# ? Dec 9, 2013 14:28 |
|
|
# ? May 24, 2024 06:32 |
|
You know it's going to be good when you read that. "I can't convince anybody how good my lovely idea was, because I'm a nerd"
|
# ? Dec 9, 2013 16:10 |
|
This web framework works by adding Python expressions to the "Review Comments" section of Word/Excel documents.
|
# ? Dec 9, 2013 16:11 |
|
Suspicious Dish posted:You know it's going to be good when you read that. The worst part is that's not just in there, it's how it starts. "I am incapable of communicating effectively. But listen, this idea I have is really good so it is totally worth slogging through my barely comprehensible bullshit, I promise."
|
# ? Dec 9, 2013 17:27 |
|
quote:So they are forced to work harder while experiencing the true impossibility to share their permanent software experience. Of course, it may lead to social disasters. Hey, so PyQt's flagging some of the methods of my Qt main window class as static. I read up on static methods and the @staticmethod decorator. Most of what I read pointed it to being pointless, and for the examples posted, I agree. I feel like this is a somewhat special case where @staticmethod may be more clear. Ie: These are functions that are only called from pressing a button etc in a QT window, and belong to the GUI structure. They seem to make sense grouped in with the other QT methods, even though the code they affect isn't part of the GUI. What's your take on this? Python code:
How would you handle refresh? -A normal method that's static (like above) -Decorated with '@staticmethod', no self arg -A function in the program body Dominoes fucked around with this message at 18:38 on Dec 9, 2013 |
# ? Dec 9, 2013 17:39 |
|
Sometimes I try to do a hybrid between type checking and duck typing. By this I mean that I immediately check that the passed-in object has the attributes and methods I expect to use later on. I do this for the following reasons:
So, if you came across code doing this would you shake your head?
|
# ? Dec 9, 2013 21:04 |
|
Thermopyle posted:Sometimes I try to do a hybrid between type checking and duck typing. By this I mean that I immediately check that the passed-in object has the attributes and methods I expect to use later on. I do this for the following Example?
|
# ? Dec 9, 2013 21:44 |
|
Thermopyle posted:Sometimes I try to do a hybrid between type checking and duck typing. By this I mean that I immediately check that the passed-in object has the attributes and methods I expect to use later on.
|
# ? Dec 9, 2013 22:02 |
|
Dominoes posted:Example? Python code:
Plorkyeran posted:That's not a hybrid; it's just duck typing with some error checking. Nothing about duck typing requires that you not verify that the thing you're passed actually does look and quack like a duck; merely that you don't care about it's actual type so long as it does implement the interface you need. Yeah, I guess you're right. Typically I'll see code just blindly using whatever objects its passed and relying on downstream exceptions to raise when its the wrong type of object.
|
# ? Dec 9, 2013 22:06 |
|
I do stuff like that when it seems appropriate, only subbing what would be exception handling for raising an error in your example. It's due to the explicit > implicit paradigm, which doesn't always agree with duck-typing. For example: Python code:
Python code:
Dominoes fucked around with this message at 05:49 on Dec 10, 2013 |
# ? Dec 9, 2013 22:15 |
|
Thermopyle posted:Yeah, I guess you're right. Typically I'll see code just blindly using whatever objects its passed and relying on downstream exceptions to raise when its the wrong type of object.
|
# ? Dec 9, 2013 22:15 |
|
Thermopyle posted:So, if you came across code doing this would you shake your head? As long as you're checking for quacks and not for class types, it would seem ok. I often skip the checks and convert to the type I want (so I'll call tuple, or list, or dict, etc, making a copy but it catches a lot of annoyances)
|
# ? Dec 10, 2013 01:17 |
|
tef posted:I often skip the checks and convert to the type I want (so I'll call tuple, or list, or dict, etc, making a copy but it catches a lot of annoyances) I like that. In other news, Jetbrains is having a 1 hour webinar wherein they build a Pinterest clone with PyCharm. I know there's a few newerish users around here, so I thought I'd mention it. quote:We'll demonstrate the workflow and tools to make using databases, Flask, HTML, CSS, and JavaScript a breeze by building and deploying a Pinterest clone. Come learn many of the tips and tricks PyCharm provides to turbocharge your daily tasks.
|
# ? Dec 10, 2013 17:39 |
|
This article is pretty cool. It's about how the LA Times used NLTK to parse recipes out of news articles and create a cookbook. http://datadesk.latimes.com/posts/2013/12/natural-language-processing-in-the-kitchen/
|
# ? Dec 11, 2013 14:44 |
|
Thermopyle posted:PyCharm doesn't flag those for me.
|
# ? Dec 11, 2013 17:07 |
|
Dominoes posted:Just updated to this version, and the bug's still there, every time. (without ignoring Pep8 # 226 in settings) I'd contact support and/or file a bug on their issue tracker. Jetbrains is quite responsive.
|
# ? Dec 11, 2013 17:19 |
|
Done.
|
# ? Dec 11, 2013 17:32 |
|
From their response it looks like this is where you need to file a report: https://github.com/jcrocholl/pep8/issues
|
# ? Dec 11, 2013 18:59 |
|
A previous version of PEP8 suggested (a + b) * (c + d). It seems that changed recently: http://hg.python.org/peps/rev/37af28ad2972 http://hg.python.org/peps/rev/16dd63848921
|
# ? Dec 11, 2013 19:07 |
|
Sounds like that's the issue; the external tool is out of date. The new method's easier to read, and I'd probably break the Pep8 rule if it still said to use spaces always. Reposted
|
# ? Dec 11, 2013 19:42 |
|
Tried to take the Python test on E-Lance and I couldn't even get past the first question The question was "write a problem that takes an input "n" and returns the maximum" blah blah gently caress I don't totally remember it was something about finding the maximum number of range(1, 9xn) that is evenly divisible by n. Like, 9x2 would be "99", and the result would be "98" since that's the maximum number that's evenly divisible by 2. I submitted an answer for that one and ragequit when it was wrong. Especially since it was taking too long for me to write it. I may have freaked out a little too harshly Has anyone seen that problem before? Am I retarded for not finishing with 5 minutes or am I retarded for blowing the whole thing on one fuckup? (it's the latter)
|
# ? Dec 12, 2013 21:02 |
|
Pollyanna posted:Tried to take the Python test on E-Lance and I couldn't even get past the first question And in python you can multiply strings by numbers, so 'x' * 4 which will give you 'xxxx' http://repl.it/NFZ ManoliIsFat fucked around with this message at 21:11 on Dec 12, 2013 |
# ? Dec 12, 2013 21:06 |
|
ManoliIsFat posted:final_answer = number - (number % 2) I am loving retarded. This was my implementation: Python code:
|
# ? Dec 12, 2013 21:12 |
Pollyanna posted:Tried to take the Python test on E-Lance and I couldn't even get past the first question Don't get so down on yourself and keep practicing. It takes time to build up the mental toolbox of things you can use to solve problems. You aren't alone in experiencing these frustrations. You do yourself a disservice though if you don't learn from these moments! Sometimes for those types of problems, it's better to just bust out a pen and paper and play around with the numbers to figure out how your program might work.
|
|
# ? Dec 12, 2013 21:19 |
|
Pollyanna posted:I really don't know what the gently caress I'm doing, do I? Write out the answer in English before you start coding.
|
# ? Dec 12, 2013 21:33 |
|
Pollyanna posted:I really don't know what the gently caress I'm doing, do I? Maybe I'm reading the question wrong, but I'd assume the largest number is always either the last number in the list, or the last number -1. There's no reason to save a list of every even number between 2->n, then take the max of the list. If you really needed to run through the whole range, you might wanna keep a running max. code:
Just keep on keeping on! These type of exam problems will always be tough for a dude starting totally fresh, teaching himself.
|
# ? Dec 12, 2013 21:59 |
|
Pollyanna posted:Tried to take the Python test on E-Lance and I couldn't even get past the first question Python code:
|
# ? Dec 12, 2013 23:50 |
|
Just won an old client back, and some old django I worked on about a year has been returned to me for updates, well, in updated form. The coder they hired was a very special person. code:
One problem the client has is that when someone else logs on the supplier data isn't there. And there is so much more of this sort of horseshit. He pulled out all the nato-standard django auth I used and made his own homebaked one that stores all the user data (username/non hashed password/email/etc in profile because "cant find User model" (according to the #comment). And on it goes. I informed the client I'm rolling that poo poo back 6 months and spending the week rewriting it and creating migration scripts to renormalize, resane-ify, and generally unfuck the whole thing. Its like having my beloved child return after a year on the run and she's now a meth-head pregnant to corrupt cop and a rampant STD infection. Just horrible.
|
# ? Dec 13, 2013 22:33 |
|
Heh I just had pretty much the exact same thing happen just now. I passed the project on to a friend instead... not his baby, he can handle it.
|
# ? Dec 13, 2013 22:47 |
|
What the hell is the deal with using pip with a python3 virtualenv? When I'm not in a virtualenv, pip installs to python2.7, pip3 to python3.3, and pip-3.3 isn't recognized. When I'm in a python3 virtualenv, pip points back to the root python2.7, pip3 points to the root python3.3, and pip-3.3 installs into the virtualenv. Is it supposed to work this way?? pip3 outside of a virtualenv and pip-3.3 inside it?
|
# ? Dec 14, 2013 22:54 |
|
Looking for advice on atabase / python data structure use. I've been working with some persistent data for an algorithmic stock trader. Two basic types of data I'm saving. 1: relatively small lists (ie < 1000) of objects representing stock transactions. 2: Large collections of historical data. (hundreds of mbs) I load the object lists from a YAML file (similar to JSON in that it mimics Python data structures, but supports objects natively) when starting the program, and periodically save over the file with updated data. I load the historical data from a sqlite database, and convert it to a 3-axis dict when the program starts. I previously saved and loaded it the same way I did with transactions, but with JSON instead of YAML. The database system seems more robust, and has an immediate advantage of being able to insert individual records, instead of periodically saving a (huge) file. Is loading a database to a python data structure like this required for fast operation? Would it be appropriate to skip loading the historical data to a dict, and directly make database queries (SQL or an abstraction like alchemy) whenever I need data? Is it doing a hard drive pull whenever I make changes? Is it appropriate to use databases for relatively small data sets like the transactions list? Dominoes fucked around with this message at 01:23 on Dec 15, 2013 |
# ? Dec 15, 2013 01:18 |
|
Dominoes posted:Looking for advice on atabase / python data structure use. Pandas but 300mb is pretty tiny
|
# ? Dec 15, 2013 01:27 |
|
Dominoes posted:Looking for advice on atabase / python data structure use. Have you considered using HDF5 for your historical data? HDF5 is a file format that works kind of like a miniature chunked file system that stores N-dimensional data with whatever dimensions or chunking sizes you prefer. HDF5 is generally faster, more robust, and easier to use than MySQL, especially in a Python environment. HDF5 files are also highly portable, so they get used a lot in the scientific community (they are obsoleting FITS files and similar flat formats). However, HDF5 lacks the power of a database, so if you want to run relational queries then that's going to require a lot more work. You can think of HDF5 as a materialized view, which is fine if you just want an archive of historical data. Using HDF5 goes something like this: Python code:
For financial data, if you want 2D or 3D (or ND) datasets then you could just categorize them into various groups and be able to easily access them elsewhere. QuarkJets fucked around with this message at 01:49 on Dec 15, 2013 |
# ? Dec 15, 2013 01:47 |
|
I'm having virtualenvwrapper problems. For some reason running which pip is no longer changing to the virtualenv pip after running workon .... Any ideas? I rancode:
Note: this is unrelated to the question about pip I asked a few posts up, that behavior is on my remote machine. There, which pip properly reflects the active virtualenv. E: poo poo. There is no pip in the virtualenv bin directory. I must have installed this env with PyCharm, and that's probably the issue. SurgicalOntologist fucked around with this message at 04:43 on Dec 15, 2013 |
# ? Dec 15, 2013 04:39 |
|
What's a good way to do XML-based GUI programming in Python? I've heard of Glade, but I don't think it's unique to Python.
|
# ? Dec 15, 2013 06:48 |
|
QuarkJets posted:
Pandas supports HDF5 backed data structures that have worked really well for me. Have the awesome data table structure but automatically set up all the HDF5 stuff transparently.
|
# ? Dec 15, 2013 06:50 |
|
Pollyanna posted:What's a good way to do XML-based GUI programming in Python? I've heard of Glade, but I don't think it's unique to Python. Glade is an app for building GTK+ UIs. It exports it into an XML format called GtkBuilder and it's built directly into GTK+. A simple app I maintain is Alacarte. It's a bit old, but it uses Python and GtkBuilder: GtkBuilder file, associated Python code I write my GtkBuilder XML files by hand, and don't use Glade, though.
|
# ? Dec 15, 2013 07:02 |
|
I was hoping for some PyQt4 help. I am preparing a polling loop to show some analog-digital conversion on a Raspberry Pi once the right hardware shows up. So I just have a separate thread setting some progress bar widgets forwards and backwards based on a sweep of values over time. I am sure the code as-is is a big problem because that's a separate thread screwing with the GUI thread; I don't know of a GUI toolkit that tolerates having other threads jack up its widgets directly. I just don't know what the policy is supposed to be in PyQt4 for getting the GUI thread to handle these correctly. I suspect it involves signals and slots, but I can only ever find examples where, say, changing one widget changes another directly. This is pretty useless because that connection stays within the GUI thread. I need to understand how to coordinate the GUI with asynchronous behavior. What suprises me is how often this code actually succeeds, but I have had it die impressively and arbitrarily too. How should I properly set the GUI components? Here's some code:Python code:
|
# ? Dec 15, 2013 07:40 |
|
QuarkJets posted:Have you considered using HDF5 for your historical data? HDF5 is a file format that works kind of like a miniature chunked file system that stores N-dimensional data with whatever dimensions or chunking sizes you prefer. HDF5 is generally faster, more robust, and easier to use than MySQL, especially in a Python environment. HDF5 files are also highly portable, so they get used a lot in the scientific community (they are obsoleting FITS files and similar flat formats). However, HDF5 lacks the power of a database, so if you want to run relational queries then that's going to require a lot more work. You can think of HDF5 as a materialized view, which is fine if you just want an archive of historical data. For groups would I set it up like this? /dataset/GOOG/2013-01-01/close = 800.74 /dataset/GOOG/2013-01-01/high = 810.34 /dataset/GOOG/2013-01-02/close = 801.25 etc Would I use attributes? Haven't tried Pandas yet. Dominoes fucked around with this message at 16:35 on Dec 15, 2013 |
# ? Dec 15, 2013 12:45 |
|
|
# ? May 24, 2024 06:32 |
|
Rocko Bonaparte posted:I was hoping for some PyQt4 help. I need to understand how to coordinate the GUI with asynchronous behavior. Python code:
Here are the four bits of code I added. You can use them as a template for doing this in the future.
quote:I suspect it involves signals and slots, but I can only ever find examples where, say, changing one widget changes another directly. Dominoes fucked around with this message at 14:59 on Dec 15, 2013 |
# ? Dec 15, 2013 13:33 |