|
wins32767 posted:Just out of curiosity, what do you have against Pylons? I'll quote what I wrote on another site a while back: quote:I see what you're saying here about how Pylons makes heavy use of WSGI chaining, but I really just cannot fathom that Django is "approaching" Pylons. Perhaps things have improved since I last used Pylons, but there were so many issues with it that drove me absolutely crazy and eventually drove me away from the framework all together. This was in the context of a discussion about djng. And if you couldn't tell, I prefer Django. I was skeptical of it when I first came upon it in the pre-1.0 days, and that's what eventually led me to Pylons. However, since then, Django has improved by a vast amount, and it's now really easy to pump out web apps with it. That said, I do prefer the mix-n-match WSGI approach for low level/high performance web services.
|
# ? Oct 9, 2009 21:17 |
|
|
# ? May 27, 2024 12:41 |
|
Django question time: I'm doing some sort of galactic model, and I have the following classes in a models.py: code:
edit: would planets = self.satellites.filter(orbital>0) work in Star?
|
# ? Oct 10, 2009 02:23 |
|
Baruch Obamawitz posted:Django question time: It looks like I should put something like the following in Star: code:
WhiskeyJuvenile fucked around with this message at 03:16 on Oct 10, 2009 |
# ? Oct 10, 2009 03:00 |
|
Baruch Obamawitz posted:Just have to figure out _set_planets(self) now, I guess. code:
edit: apparently not! WhiskeyJuvenile fucked around with this message at 03:26 on Oct 10, 2009 |
# ? Oct 10, 2009 03:17 |
|
in Starcode:
code:
edit: Or this? in Planet: code:
WhiskeyJuvenile fucked around with this message at 04:26 on Oct 10, 2009 |
# ? Oct 10, 2009 04:20 |
|
Baruch Obamawitz posted:in Star Uhh, this is terrible. Why would assignment append to something....
|
# ? Oct 10, 2009 04:23 |
|
king_kilr posted:Uhh, this is terrible. Why would assignment append to something.... yes, it is terrible (and it actually validates but doesn't create any sort of data structure so I guess it doesn't work!)
|
# ? Oct 10, 2009 04:26 |
|
code:
edit: babby's first time using python
|
# ? Oct 10, 2009 04:32 |
|
My webhost (webfaction) has python 2.6 installed, but the apache instance they provide uses python 2.5. They provide instructions on how to compile your own version of apache that uses 2.6, but it's a pain in the rear end. Is it possible to use virtualenv instead to use 2.6 with apache?
|
# ? Oct 10, 2009 05:00 |
|
nbv4 posted:My webhost (webfaction) has python 2.6 installed, but the apache instance they provide uses python 2.5. They provide instructions on how to compile your own version of apache that uses 2.6, but it's a pain in the rear end. Is it possible to use virtualenv instead to use 2.6 with apache? This doesn't make sense, a virtualenv controls the enviroment it's python executable runs in, it can't make apache use a different python version.
|
# ? Oct 10, 2009 05:01 |
|
Baruch Obamawitz posted:failures You had the right idea with your original models and it all falls apart because you need to make Satellite an abstract model, look it up.
|
# ? Oct 10, 2009 11:35 |
|
jupo posted:You had the right idea with your original models and it all falls apart because you need to make Satellite an abstract model, look it up. I don't think that will fix the Star.planets issue though, will it? I was thinking of a type = CharField(max_length=10) where the subclass save() functions do type = type(self).__name__
|
# ? Oct 10, 2009 13:18 |
|
Milde posted:<snip> All those itemized complains are very cogent, though the last two are the only ones that haven't been improved upon, at least to my satisfaction. Certainly, when I was trying to decide on a framework ~2 years ago they were all more or less problems. Django just isn't flexible enough for the things I'm doing with my web framework, especially in the area of the model. The first system I wrote in Pylons is up to ~7.5 million records in the main table; if I hadn't been able to apply some database foo with triggers and stored procedures performance would be in the crapper. At the time, I didn't get the impression that the Django model could handle that sort of thing well; hell, Pylons has some limitations in that respect.
|
# ? Oct 10, 2009 23:58 |
|
Doesn't python do some sort of weird nested for loop thing? edit: something like code:
|
# ? Oct 12, 2009 18:50 |
|
Baruch Obamawitz posted:Doesn't python do some sort of weird nested for loop thing? List Comprehension? http://docs.python.org/tutorial/datastructures.html#list-comprehensions
|
# ? Oct 12, 2009 18:57 |
|
No, Python doesn't do anything like that. You can choose one of the following: 1. Nested for loops. code:
code:
code:
|
# ? Oct 12, 2009 18:58 |
|
Yay, I solved the earlier problem:code:
|
# ? Oct 12, 2009 19:58 |
|
Milde posted:
If anyone else is ever going to read your code #1. List comprehension is really nice but, nested for is so much easier to debug and read.
|
# ? Oct 12, 2009 23:03 |
|
I am using python 2.6 on the Mac and running in to a bit of trouble in getting a fresh install of python26 + pylab to work. I use Macports to manage the python install and packages, and for some reason I cannot import pylab in my standard python shell. But the weird thing is that it works fine when using the spyder python IDE that I recently came across, in which the python shell looks identical. Here's what I get when I import pylab in the spyder interactive shell: code:
code:
PATH from spyder: code:
code:
This is driving me crazy! What else should I be looking at here?
|
# ? Oct 12, 2009 23:33 |
|
VirtuaSpy posted:File "/opt/local/Library/Frameworks/Python.framework/Versions/2.6/lib/... Python not finding wxpython is your problem. Check to make sure that you have installed wxpython properly with macports. Edit: Also worth noting that you need version 2.8+ code:
Modern Pragmatist fucked around with this message at 23:50 on Oct 12, 2009 |
# ? Oct 12, 2009 23:47 |
|
Modern Pragmatist posted:Python not finding wxpython is your problem. Check to make sure that you have installed wxpython properly with macports. I see. So py26-wxpython doesn't currently build on Snow Leopard (per http://trac.macports.org/ticket/20952), and I guess that is where my error is originating, since it can't find wxpython. I'll just keep tracking that bug. I am just stumped as to why it is working okay in spyder. Thanks for the help!
|
# ? Oct 13, 2009 00:00 |
|
ATLbeer posted:If anyone else is ever going to read your code #1. List comprehension is really nice but, nested for is so much easier to debug and read. List comprehensions are faster.
|
# ? Oct 13, 2009 03:58 |
|
sink posted:List comprehensions are faster. Worrying about speed in Python is a great way to waste your time.
|
# ? Oct 13, 2009 04:04 |
|
Avenging Dentist posted:Worrying about speed in Python is a great way to waste your time. I recently switched to using Python for my project Euler problems and I've run into some speed issues. Although they can usually be fixed by using python's bad rear end iterators instead of list comprehension.
|
# ? Oct 13, 2009 04:12 |
|
I just do the performance-sensitive stuff in C.
|
# ? Oct 13, 2009 04:13 |
|
Avenging Dentist posted:Worrying about speed in Python is a great way to waste your time. I think they look nicer than for loops, too.
|
# ? Oct 13, 2009 04:16 |
|
sink posted:I think they look nicer than for loops, too. They don't necessarily serve the same purpose. Using list comprehensions implies that you're transforming your input in some manner. For loops don't have to build up anything or do anything to any list - they can have side effects, and you have more control flow options. That said, I absolutely love list comprehensions. They're so concise and they're easy to read. I must admit, though, I sometimes secretly lust for a universe where Python has Ruby-style iteration with anonymous functions.
|
# ? Oct 13, 2009 04:31 |
|
If only Guido didn't hate functional programming
|
# ? Oct 13, 2009 04:39 |
|
oh what the christ is this bad python or bad django? code:
|
# ? Oct 13, 2009 06:56 |
|
Baruch Obamawitz posted:oh what the christ is this foo is a queryset, it just pretty-prints like a list just check foo.count() I think
|
# ? Oct 13, 2009 06:58 |
|
if foo/if not foo work. I think it's because len(foo) returns 0 when it's empty and empty sequences evaluate to false. Someone correct me otherwise. Ninja edit: Actually it probably isn't since you're not supposed to call len(foo) because it fetches the whole QuerySet but the logic was still sound
|
# ? Oct 13, 2009 17:02 |
|
Design question: which is more "Pythonic" (or "which do you prefer")? And before someone says "don't use camel-case", I'm (mostly) replicating an interface from another language, so it's staying that way. Here's the common stuff: specify some input coordinates in the source basis (XYZ by default) and return the coordinates converted into the destination basis (XYZ by default). This version infers the dimension of the basis from the dimension of the entities (i.e. edges => U, faces => UV). code:
(A) code:
code:
|
# ? Oct 13, 2009 19:07 |
|
I would say go for A, if only because to me it seems MORE readable. You know that all the variables in the tuple are required so you won't have to find out the hard way when the function throws back a TypeError or silently uses a default keyword argument that you might not intend. To me it seems more explicit in A, and explicit is usually better than implicit in python, if that makes any sense.
|
# ? Oct 13, 2009 19:14 |
|
Why not just support both? PIL, matplotlib, and a few others that I know of have similar issues where they let you enter arguments either individually, or in tupled groups.
|
# ? Oct 14, 2009 01:02 |
|
Milde posted:I must admit, though, I sometimes secretly lust for a universe where Python has Ruby-style iteration with anonymous functions. The past few weeks I've been really starting to warm up to some of Ruby's ways of doing things, both the extra syntactical sugar and the blocks/emphasis on message-passing. And RubyGems kicks easy_install's rear end (though their answer to virtualenv is still pre-alpha.) This is part Stockholm Syndrome (I work in a Rails shop) and part legitimate "you know that does look a bit nicer / is a bit easier to write than the equivalent Python". If only the community wasn't so loud, noisy and busy tripping over itself in its haste to out-douchebag everyone else. For every legitimately cool person (like most of the Github team) there's at least a hundred people who describe every. single. project of theirs as "The most awesomeness of awesome hotness since sliced sexy! brought to you by a Rockstar Programmer " And then there's the fact that testing is huge -- which is great -- but non-API documentation (or non barebones API documentation, even) is like the bottom of everybody's loving list So compared to all that, Python -- even with the Philip J Ebys and the Massimo DiPierros -- is a huge whiff of fresh air. Good job, guys bitprophet fucked around with this message at 05:15 on Oct 15, 2009 |
# ? Oct 15, 2009 05:12 |
|
nbv4 posted:Why not just support both? PIL, matplotlib, and a few others that I know of have similar issues where they let you enter arguments either individually, or in tupled groups. I wouldn't exactly use a library whose primary purpose is "maintaining Matlab's interface" as the basis for design. Besides, that would go against Python's "there's only one way to do it" philosophy. EDIT: to be fair, this is mostly an excuse because I don't like (B). Avenging Dentist fucked around with this message at 19:40 on Oct 15, 2009 |
# ? Oct 15, 2009 18:40 |
|
bitprophet posted:"The most awesomeness of awesome hotness since sliced sexy! brought to you by a Rockstar Programmer " It's a good general rule that "rockstar programmers" don't write web stuff, which is what makes the Rails community all the more sad.
|
# ? Oct 15, 2009 19:42 |
|
Avenging Dentist posted:It's a good general rule that "rockstar programmers" don't write web stuff, which is what makes the Rails community all the more sad. god
|
# ? Oct 16, 2009 03:49 |
|
I need some help for a project Euler question. It's question 8:Find the greatest product of five consecutive digits in the 1000 digit number. it is only my first day learning a programming language so sorry if my code is retarded or inefficient. But this is what I have wrote. code:
TypeError: can't multiply sequence by non-int of type 'str'. where am I going wrong?
|
# ? Oct 18, 2009 16:45 |
|
|
# ? May 27, 2024 12:41 |
|
made of paper posted:But I get an error at 'k=f*g*h*i*j' which says: Just as the message says, you're trying to multiply single character strings together. Use the int() function to interpret the value of the string. There are other things you should try before moving on to another problem. First, try to get rid of some variables -- you could use a single variable as the index in the array and then add an offset when accessing the array: string[a], string[a+1], string[a+2], etc. 'f' and on aren't used except to temporarily hold values before multiplying. Why not start by checking out the *= operator? I realize you're just learning the language, but there's a couple really awesome python features that you should know about. Really, you ought to check out the section of your tutorial on the for loop, slicing and list comprehensions.
|
# ? Oct 18, 2009 17:44 |