|
That seems like a relatively small project with a need for a DB. Right up Flask's alley. Frameworks like Django are for much larger projects but help with a lot of boilerplate (i.e. admin interface, automatic database setup, etc.) while Flask is a lot more compact but since it doesn't come with that extra stuff, you have to figure out how to implement it yourself. (Which is a pain.) Anyway, is there a way to alias a command to open Python on a certain path? Reason I ask is that I have Anaconda installed, and before I changed the PATH it automatically chose that install to use. I know that "conda" is a command to open Anaconda. Can I just bind the conda PATH to conda and the python PATH to python somehow?
|
# ? Dec 5, 2013 18:41 |
|
|
# ? May 24, 2024 21:31 |
|
You're on OS X right? You should be able to launch the version in question just by simply typing "python2.6" or "python2.7". I have not used Anaconda so I don't know how Anaconda interacts with the installed versions of Python.
|
# ? Dec 5, 2013 18:48 |
|
I'm trying to do some blurring/unblurring of images in Python and I can't get it to work properly. The image gets blurred fine, but the inverse blur just gives me back noise.code:
code:
Can anyone see what the problem is?
|
# ? Dec 5, 2013 22:44 |
|
My Rhythmic Crotch posted:You're on OS X right? You should be able to launch the version in question just by simply typing "python2.6" or "python2.7". I have not used Anaconda so I don't know how Anaconda interacts with the installed versions of Python. Apparently I can get things working just by using the Anaconda launcher, so there's that problem fixed. --- I'm realizing that I need a couple things when I start a new Flask project. I at least need a database, and a file that renders HTML/CSS/JS. Is there a Flask "template" I can follow so that I don't have to do a bunch of coding over and over when I start a new project? Is there one that has functionality like Django's automatic admin interface?
|
# ? Dec 5, 2013 22:58 |
|
Pollyanna posted:Apparently I can get things working just by using the Anaconda launcher, so there's that problem fixed. PyCharm can set up a lot of stuff by default when you start a new Flask project.
|
# ? Dec 5, 2013 23:02 |
|
Thermopyle posted:PyCharm can set up a lot of stuff by default when you start a new Flask project. Unfortunately, that's not the case for the Community Version. Unless there's a way to add that functionality to CE...?
|
# ? Dec 5, 2013 23:04 |
|
Pollyanna posted:Apparently I can get things working just by using the Anaconda launcher, so there's that problem fixed. IMHO the "simplicity" of Flask is not doing you any favors here. You want something reasonably quick that works out of the box. Django is that thing. Sure it can also do a gazillion other things you don't need, but just don't use those - it is reasonably well factored. Yes you can build the same thing in Flask, yes there exist template projects with most bells and whistles set up, yes there is an admin UI, but it just wont' be as smooth or straight-forward as django if that's what you want to do. There is a lot of wiring you have to do yourself with Flask (I know this because I just last week had to do it). I like this in my case because this is a long term project that I can afford to be fussy about and I want it set up just so. It's generally speaking useful for projects that you know for a fact start simple (in terms of dependencies) but you want the option to add to them later. Your case seems like the opposite of that: You are gunning straight for an admin-ui-ish arrangement. That's a big-rear end dependency, it ends up touching on pretty much all major components from django.
|
# ? Dec 5, 2013 23:09 |
|
Pollyanna posted:Unfortunately, that's not the case for the Community Version. Unless there's a way to add that functionality to CE...? Sure is!
|
# ? Dec 5, 2013 23:14 |
|
Boz0r posted:I'm trying to do some blurring/unblurring of images in Python and I can't get it to work properly. The image gets blurred fine, but the inverse blur just gives me back noise. What modules are you using? I'm not familiar with the blur module, is that something that you wrote? Also, in deblur_image it appears that you're doing nothing with the noise that you're passing in, and when that kind of thing happens usually the developer is also mixing up the order of their arguments, IE treating noise as x.
|
# ? Dec 5, 2013 23:15 |
|
Boz0r posted:Both methods yield the same result. What formulas are you trying to implement? inv(convolution_matrix)*matrix(x)*inv(convolution_matrix) looks weird. Are you doing element-wise multiplication or matrix multiplication? e: I'm guessing for the second version, you want "fft2(x) / fft2(kernel)" instead of "fft2(x) * inv(fft2(kernel))". inv() is the inverse matrix, which is the inverse under matrix multiplication. suffix fucked around with this message at 23:53 on Dec 5, 2013 |
# ? Dec 5, 2013 23:48 |
|
Pollyanna posted:Apparently I can get things working just by using the Anaconda launcher, so there's that problem fixed. It does also provide you with an admin interface. And what do you mean "a file that renders HTML"? That's a template. Templates can be like, one line long. Or you can output raw text directly with no fancy templates and HTML.
|
# ? Dec 6, 2013 04:18 |
|
Mr. Wynand posted:IMHO the "simplicity" of Flask is not doing you any favors here. You want something reasonably quick that works out of the box. Django is that thing. Sure it can also do a gazillion other things you don't need, but just don't use those - it is reasonably well factored.
|
# ? Dec 6, 2013 04:42 |
|
Are there any decent documentation generators out there that can spit out Confluence pages? I was hoping someone would have written something for Sphinx, but no such luck so far.
|
# ? Dec 6, 2013 06:34 |
|
My Rhythmic Crotch posted:Something as simple as adding an extra field to the user model was pointlessly complicated (I know the user model has since changed, but its just one example). quote:Tastypie was where I finally threw in the towel. More specifically the guts of Tastypie, which is some mind bending poo poo. While I don't agree with every design choice in Flask, I can actually read and understand the code that Flask and its related modules are made of. My general rule of thumb is that libraries with "clever" names that have obvious descriptive alternatives (e.g. something including the words "django" and "rest") should be viewed with extreme suspicion and discarded at the first signs of trouble.
|
# ? Dec 6, 2013 08:28 |
|
Speaking as someone who entered Python programmer as a total beginner (only HTML & CSS experience) Django was a much better place for me to start. Simply put, batteries included meant I didnt have to gently caress around with sessions, authentication, choosing how to bind to a database, or any of that. I could just start building something that worked for better or worse. The tutorial got you far enough that you could feel your way around from there trying to build an app. Sure, its hand holding, but at that point you pretty much need it if you're a raw beginner. I'm making an assumption here but I reckon most people who recommend Flask were already had some sort of programming experience when they started. Its the no brainer choice when you know how to build your app just the way you like it, because you don't get saddled with bloat, but that's just not practical for a genuine beginner. When I was starting the batteries let me get the runs on the board, which is critical motivation for a self guided project.
|
# ? Dec 6, 2013 08:46 |
|
QuarkJets posted:What modules are you using? I'm not familiar with the blur module, is that something that you wrote? Yeah, sorry, that module is one I have from our instructor, it just returns a simple gaussian blur kernel. In this particular example, there is no noise. suffix posted:What formulas are you trying to implement? inv(convolution_matrix)*matrix(x)*inv(convolution_matrix) looks weird. Are you doing element-wise multiplication or matrix multiplication? http://www.siam.org/books/fa03/FA03Chapter1.pdf In section 1.2 and 1.3 of this paper they present a method of blurring and a naive method of unblurring when noise hasn't been added. I changed the code to fft2(x) / fft2(kernel) instead, and now it looks like something that could become a picture in the future. Isn't matrix division defined as multiplying with the inverse, though?
|
# ? Dec 6, 2013 11:11 |
|
Boz0r posted:http://www.siam.org/books/fa03/FA03Chapter1.pdf You have to be careful because Numpy has two ways to multiply arrays, depending on their type: Python code:
If you want to be sure you are doing matrix multiplication, you can use .dot(), which works on both matrices and arrays: Python code:
You may want to toy around a bit with the interpreter to get a feel for what the different operations do and check that your data looks like you expect, especially if you've got ipython running.
|
# ? Dec 6, 2013 21:44 |
|
Mr. Wynand posted:Does the community edition do that remote interpeter vagrant magic? I sort of discounted using pycharm out of hand since I assumed it needed to run on the local python env and I always always always run the actual servers in a headless VM. But turns out it can absolutely do that that workflow, so now I am interested. Pollyanna posted:Unfortunately, that's not the case for the Community Version. Unless there's a way to add that functionality to CE...? quote:I said this last page, but Jetbrains are very lenient w/r/t handing out full licenses for open-source projects. Pollyanna posted:Dang. How do I change my current Python version, again? I tried editing .bash_profile but it didn't change whether or not I used Anaconda. Pollyanna posted:Anyway, is there a way to alias a command to open Python on a certain path? Reason I ask is that I have Anaconda installed, and before I changed the PATH it automatically chose that install to use. I know that "conda" is a command to open Anaconda. Can I just bind the conda PATH to conda and the python PATH to python somehow? I'm not sure I understand what it is you're trying to do, and you aren't talking about the PATH variable in the conventional sense. There's one PATH your shell will use to resolve non-builtins. Check your symlink to see if its pointing to your preferred interpreter: code:
code:
salisbury shake fucked around with this message at 22:40 on Dec 6, 2013 |
# ? Dec 6, 2013 22:36 |
|
Boz0r posted:Here, the first method returns noise and the second method looks like it's still in the frequency domain. If nothing else, going by the text you linked (figure 1.3), the naive method should be giving noise, because it's a bad method. But I think suffix has it right, use .dot() instead. If you look at the help for, for example, fft2: quote:This function computes the *n*-dimensional discrete Fourier Transform
|
# ? Dec 7, 2013 02:46 |
|
breaks posted:Are there any decent documentation generators out there that can spit out Confluence pages? I was hoping someone would have written something for Sphinx, but no such luck so far. https://developer.atlassian.com/dis...ion1andversion2 Last time I looked into this confluence accepts (and kind of demands) html anyway, so it seems reasonable to still use the output from sphinx as long you're taking care of pushing one logical sphinx page to one confluence page
|
# ? Dec 7, 2013 06:44 |
|
Based on the wonderful stylings of the shit_that_didn't_happen.txt thread, I put together a really small STDH-themed Mad Libs program (pastebin). This is the typical output:quote:SOOOO I was at a cafe with MY GIRLFRIEND and Megan Fox getting a bite to eat. There I was, blindly eating my crazy meal of Doritos and Doritos, when suddenly this crazy crazy guy ran up to me and said "Coconut sucks!" Aside from badly needing more fill-in-the-blank choices and a better written story, there's a clear bug here: only one answer for a field can exist at a time. So, I can't have more than one adjective at a time What's a better way to do this so that I don't run into problems like these? (You can review my program at that Pastebin link up there.) (edit: This is part of my webapp ) Pollyanna fucked around with this message at 09:30 on Dec 7, 2013 |
# ? Dec 7, 2013 09:22 |
|
What do you want it to do, randomly choose a 1->maxNumberOfChoices, command seperate them? http://docs.python.org/2/library/string.html#string.join Or do you want to define an array of adjectives first, and then define separate 'adjective_1', 'adjective_2' fields in your libs array? I don't understand your trouble.
|
# ? Dec 7, 2013 09:41 |
|
Well...looks like the second approach will be the easiest. vv I updated it. I keep thinking that there's got to be a more efficient, simpler approach to it, though...is there?
|
# ? Dec 7, 2013 09:57 |
|
You could extract the keywords used in the madlib using string.Formatter().parse(). With that information, you can write a function to create the dict to provide to .format() for a given madlib, instead of having to make each one by hand.
|
# ? Dec 7, 2013 18:31 |
|
If you want to be an actual Aspiring Computer Programmer, you write a Markov chain generator and use that thread as a training source.
|
# ? Dec 7, 2013 21:10 |
|
breaks posted:You could extract the keywords used in the madlib using string.Formatter().parse(). With that information, you can write a function to create the dict to provide to .format() for a given madlib, instead of having to make each one by hand. I think it's just fine the way it is. The less metaprogramming the better...
|
# ? Dec 7, 2013 21:59 |
|
I don't know that I'm really buying that pulling some strings out of a longer string and looking them up in a dictionary is "metaprogramming." It seems reasonable to turn this into a more purely data driven program. Is your complaint just about the use of string.Formatter.parse and you feel that some other means of extracting the tags should be used? breaks fucked around with this message at 22:30 on Dec 7, 2013 |
# ? Dec 7, 2013 22:15 |
|
evensevenone posted:If you want to be an actual Aspiring Computer Programmer, you write a Markov chain generator and use that thread as a training source. I might just have to do this And the one thing that bugs me is that having to do this with string interpolation (CoffeeScript, but similar enough to Python): code:
edit: If I were to implement a Markov text generator, is it worth it to try and write it on my own or is it better to use a module someone else wrote? On the one hand, trying to write one of my own would be good experience and I could claim it was all me, but on the other there's the whole "stand on the shoulders of giants" thing. Pollyanna fucked around with this message at 01:50 on Dec 8, 2013 |
# ? Dec 8, 2013 01:07 |
|
For learning? Write one yourself. With the data types python provides, it's fairly easy, and it won't be that much code. Merely finding/installing/understanding/feeding/using an existing one might end up being more work.
|
# ? Dec 8, 2013 02:55 |
|
I tried implementing a Markov chain, but I got stuck at the "map elements of the list to the words that follow them" part. I tried writing this:Python code:
Is there a name for doing something like this? "Getting the successors of each element" or whatever?
|
# ? Dec 8, 2013 04:20 |
|
quote:But I get AttributeError: 'numpy.string_' object has no attribute 'append'. You are using square brackets instead of parens in your call to whatever.append()
|
# ? Dec 8, 2013 05:50 |
|
Hey BigRedDot I just fired up Anaconda on Windows and it's pretty stellar. All the packages I needed were installed out of the box except for docopt and I was pleasantly surprised that all I had to do to get it was a pip install since it's a pure python package. It was actually easier to use than Ubuntu. I saw the numpy guy's blogpost about packaging and anaconda, is that you? He makes some of the same points you make.
|
# ? Dec 8, 2013 18:01 |
|
With statements. I decided to try with statements for setting up and tearing down an sqlite connection. Python code:
|
# ? Dec 8, 2013 18:12 |
|
Dominoes posted:How do I pull cursor (or any variable) from the with class? Is this an appropriate use? I've read 'with' is targeted at replacing try/finally scenarios, but this seems similar to the 'with open' style. Have the __enter__ return self and use with foo as bar: Python code:
Python code:
Python code:
Edison was a dick fucked around with this message at 18:47 on Dec 8, 2013 |
# ? Dec 8, 2013 18:40 |
|
Edison was a dick posted:Have the __enter__ return self and use with foo as bar:
|
# ? Dec 8, 2013 18:50 |
|
Dren posted:Hey BigRedDot I just fired up Anaconda on Windows and it's pretty stellar. All the packages I needed were installed out of the box except for docopt and I was pleasantly surprised that all I had to do to get it was a pip install since it's a pure python package. It was actually easier to use than Ubuntu. No that's Travis Oliphant, the author of NumPy, he's my boss.
|
# ? Dec 8, 2013 21:11 |
|
Pycharm question: I wrote a quick and dirty script to test out a poc: Python code:
Any way to do this with the IDE that doesn't essentially involve doing a manual regex?
|
# ? Dec 9, 2013 01:34 |
|
salisbury shake posted:Pycharm question: This is possibly PyCharm trying to tell you to not use global variables A rename to self.global_var is going to fail because self is not defined for the first instance of global_var, even if it's inside of a class. You need to put global_var inside of a class method first, ideally inside of __init__(self), and then it should work
|
# ? Dec 9, 2013 03:00 |
|
QuarkJets posted:This is possibly PyCharm trying to tell you to not use global variables Already tried to stick it in __init__, no dice. Every method that accesses it is in the same class, __init__ + the other methods have self as the first parameter. Just used Replace, though it was a bit tedious. Lesson here is to not half-rear end poo poo because it might save time.
|
# ? Dec 9, 2013 07:15 |
|
|
# ? May 24, 2024 21:31 |
|
Presenting......... The worlds most ill-concieved web framework, Appy! http://appyframework.org/principles.html quote:
quote:
|
# ? Dec 9, 2013 11:58 |