|
marcan posted:I can see why that would take forever. The code matches all the a?s first, determines the string to be too short, and then starts trying all combinations for which a?s to consider or not (it isn't smart enough to figure out that they are all equivalent). My guess is the runtine is 2^30.
|
# ? Dec 6, 2007 16:27 |
|
|
# ? May 11, 2024 16:32 |
|
Need some django help... I posted this to the django users group but I have a bad feeling it's not going to get any hits, so I may as well see if anyone has any ideas. Anyways: I've been trying to get django working with a legacy system which I feel could benefit greatly from it, however I've managed to hit a critical snag. Our setup is such that we have tables in multiple schemas, so (for example) there might be one called "app_sys" and another called "app_prod", with tables in each that need to be accessed. Initially I had been working with 0.96 and managed to get things working by specifying db_table values in class Meta with the schema prefix... for example code:
code:
Does anyone have any ideas for a way around this? npe fucked around with this message at 18:43 on Dec 6, 2007 |
# ? Dec 6, 2007 18:40 |
|
Put quotes that will hack around it?code:
|
# ? Dec 6, 2007 21:33 |
|
You're on to me! I actually tried that right after posting about this, and it seems to be working for now, which is letting me continue development in the meantime. But I'm highly embarassed about it... hopefully there's a real solution at some point in the future.
|
# ? Dec 7, 2007 01:16 |
|
LOLLERZ posted:Very astute. There is a better way to match these though. Non recursive regexes are not a panacea and a lot of things that are commonplace on regular backtracking regex engines would have to be emulated and would most likely would run several orders of magnitude slower. If you match a{,30}a{30} instead of that one case which benefits the Thompson method, then you'll get about the same result between the methods. In fact, the Thompson method needs to be modified to emulate the backtracking method.
|
# ? Dec 7, 2007 02:08 |
|
Another Django question from me: I have a comment model I am building (yes I know Django has it's own Free comments, but it's poo poo) and what I want to do is have a template tag that displays the comment form for my entries. Here is the model at the moment, before I clean it up: code:
|
# ? Dec 7, 2007 16:56 |
|
Digital Spaghetti posted:(yes I know Django has it's own Free comments, but it's poo poo) poo poo? Fairly undocumented perhaps, but they have everything, karma, adaptable moderation, akismet integration, what's poo poo about it? Digital Spaghetti posted:Well maybe I'm a bit harsh - but what I mean is it isn't really extensible without having to go in a change some core code as far as I can tell - I want to remove the site field, and add a few other fields in so it's more like wordpress, unless you can tell me otherwise? And I don't see Askimet integration, which is what I am looking for but as you say the docs are pretty poor Err my bad, akismet integration is not out of the box, you can use signals to pretty much make the comment system do whatever you want. Unfortunately some of django's best things are often the worst documented. deimos fucked around with this message at 04:13 on Dec 8, 2007 |
# ? Dec 7, 2007 23:50 |
|
deimos posted:poo poo? Fairly undocumented perhaps, but they have everything, karma, adaptable moderation, akismet integration, what's poo poo about it? Well maybe I'm a bit harsh - but what I mean is it isn't really extensible without having to go in a change some core code as far as I can tell - I want to remove the site field, and add a few other fields in so it's more like wordpress, unless you can tell me otherwise? And I don't see Askimet integration, which is what I am looking for but as you say the docs are pretty poor
|
# ? Dec 8, 2007 00:35 |
|
There's also http://code.google.com/p/django-comment-utils/
|
# ? Dec 8, 2007 04:14 |
|
I don't know how old this is, but it references one of my annoyances with python. There's such a thing as TOO much choice.bitprophet posted:FWIW when anyone asks "What GUI toolkits should I use with Python?" the answer is almost always "Tkinter, which is kind of old and busted, or wxWidgets, which is the new hotness; and Python bindings exist for most platform-specific GUI related setups out there, such as GTK or Cocoa, if you don't care about cross-platform." Not "See this list of a dozen+ toolkits". This I know, but I keep having people point out GUI toolkit of the month to me all the time, that's the real annoyance I guess. Or people telling me "hey check out the cool application I made with <obscure toolkit 876213>". deimos fucked around with this message at 20:12 on Dec 11, 2007 |
# ? Dec 11, 2007 15:43 |
|
deimos posted:I don't know how old this is, but it references one of my annoyances with python. There's such a thing as TOO much choice. Eh, that's generic programming/open source for you, has nothing to do with Python itself IMO. Coders have been reinventing the wheel/working on parallel solutions to the same problem, forever. FWIW when anyone asks "What GUI toolkits should I use with Python?" the answer is almost always "Tkinter, which is kind of old and busted, or wxWidgets, which is the new hotness; and Python bindings exist for most platform-specific GUI related setups out there, such as GTK or Cocoa, if you don't care about cross-platform." Not "See this list of a dozen+ toolkits".
|
# ? Dec 11, 2007 19:51 |
|
I figure it's worth pointing out that PyObjC, which allows you to program native Coacoa apps for OSX ,now comes standard with Leopard and XCode, making Mac Python programming a bigger joy.
|
# ? Dec 13, 2007 07:08 |
|
Casao posted:I figure it's worth pointing out that PyObjC, which allows you to program native Coacoa apps for OSX ,now comes standard with Leopard and XCode, making Mac Python programming a bigger joy. One quick note, if you are running 2.5.1 on Leopard and want to new pyobjc stuff from subversion to compile, you have to edit Python.framework/Versions/2.5/lib/python2.5/config/Makefile and remove the "-isysroot /Developer/SDKs/MacOSX10.4u.sdk" chunk from it. Otherwise, the new pobjc stuff won't compile. code:
|
# ? Dec 13, 2007 23:35 |
|
The Django Book 1.0 is finally online!
|
# ? Dec 17, 2007 04:02 |
|
Mulozon Empuri posted:The Django Book 1.0 is finally online! Wow, that really surprises me. I would have thought that they would have waited until after Christmas at least before releasing it online, to push book sales for the season.
|
# ? Dec 17, 2007 04:33 |
|
Maybe they want to spur sales by putting it up as a preview.
|
# ? Dec 17, 2007 04:37 |
|
I actually half-expected the book release to coincide with the Django 1.0 release, but I have no idea how far away the 1.0 release is, so that may not have been feasible. And in fact, I'm guessing it's probably a little ways away because it'd be a bad idea to release a book and then immediately obsolete it (granted, it'd still be valid for the 0.96 release, but there's a lot of new cool useful stuff in the 1.0 branch).
|
# ? Dec 17, 2007 18:05 |
|
The book has had problems getting out on time, and so has the 1.0 release, so I'm guessing it was released when it was simply because "oh god we're finally done". There's a WROX book out that includes Django in its content and was published like a month ago, but it's WROX, I'm told their quality is Not So Great (never read any myself). There are also at least two or three other Django books that will be released over the next ~6 months or so
|
# ? Dec 17, 2007 18:34 |
|
Not to derail but the latest stuff I've been doing at work has been possible thanks to the help of some Wrox books And for Python-related stuff to get somewhat back on track: here's this!
|
# ? Dec 17, 2007 22:25 |
|
Mulozon Empuri posted:The Django Book 1.0 is finally online! I've made a PDF version of the online book, you can download it from http://digitalspaghetti.me.uk/2007/12/17/django-book-pdf
|
# ? Dec 17, 2007 23:05 |
|
finally, django documentation out I've been waiting, but for now I'm going to focus on building the basic stuff until I fully understand what all's going on. So here's my SQL question: I'm using Gadfly to learn how to access databases from python. I'm building a prototype for a website that will end up storing about 3000-5000 rows. A lot of the information is very similar - 10 columns and maybe only 3 records are slightly different. The problem is that those 3 different records are all I can search on. I'm making this too complicated. Let's say I have 2 records in the database and I do the following: code:
code:
code:
How do I manipulate multiple rows, return the two options, or ask the user for more input?
|
# ? Dec 20, 2007 13:22 |
|
You need to understand SQL more. SQL result sets are explicitly unordered unless you specify an ORDER BY clause. So you should never, ever assume any sort of order in such a result unless you're using ORDER BY. So change your SELECT statement to something like code:
|
# ? Dec 20, 2007 19:28 |
|
okay I guess I should've used my exact codecode:
code:
code:
How do I store multiple rows to different variables so that python/gadfly isn't overwriting them? The problem isn't the select statement, I'm getting the data I want, I just want all of it - it's the fetchall() statement that I'm having a hard time understand
|
# ? Dec 21, 2007 03:55 |
|
politicorific posted:okay I guess I should've used my exact code you just want all the rows? then just assign it, fetchall is a generator. code:
|
# ? Dec 21, 2007 07:09 |
|
To get this back onto the front page where it belongs and to sort of continue the topic at hand, what do people think of the Python ORMs that are out there? I'm mainly a user of the one built into Django, and I think it's pretty awesome (with a few warts but what doesn't have those?). I know some live and die by SQLAlchemy and there are a few others out there which are pretty heavily used as well. Anybody a whiz with several who wants to provide a good comparison of them? I will say that when I was doing some ASP.NET (ugh) training last week, the instructor was all high on LINQ and talking about how in .NET 3.5 they had just introduced all this cool stuff and wow delayed execution and chained querysets and ooh so neat, which really blew the mind of some of the other folks in the training but I was like "yeah, some journalism major wrote the same thing for Django" (I don't know that Adrian actually wrote that part, but it sounds funnier ... though I didn't actually say it). Not to say LINQ isn't pretty cool (it is), but I just forget how cool some of the stuff we've already got in our pet frameworks/languages already is.
|
# ? Jan 7, 2008 23:41 |
|
I too am basically defined as a "Django ORM user". I used some SQLObject before I found Django but hardly remember it, and was at an NYCPython meetup where the author of SQLAlchemy gave a little talk about that, looks pretty neat, and can probably do "more" than Django's ORM at the expense of not being quite as concise. However I haven't actually used it yet so hard to say for sure. I'm currently debugging a PHP project which is basically the purest form of PHP you can find, namely absolutely mind-boggling horrible -inducing shite. Including your standard raw SQL queries up the ying-yang, building them in various ways, with plenty of near-breakage and probably a million potential injection exploits. Makes me appreciate ORMs and Python all the more
|
# ? Jan 8, 2008 02:27 |
|
This thread will be useful. I got Learning Python two days ago and I'm quite amazed at how easy it have been to grasp the language this far. I finished the fifth chapter yesterday and decided that I wanted to try to recreate the creepy checker that Steel Sanitizer posted over in Goon-Made Goodness thread, which took all of 5 minutes, what made it fun was the ease of growing the the little snippet of code to add input validation, different output if you're male or female or the partner is older, adding some def xxx just to try that etc etc. It was just plain fun, and being that my last try at achieving anything with a programming language was Delphi4 in 1999 it great to be able to paste code into the IDLE window to quickly test it.
|
# ? Jan 8, 2008 18:52 |
|
Here's an interesting one. Do you guys think there's a way to pass data from decorators to the functions they're decorating without using those functions' call arguments or keyword arguments? I've given this some thought and I think there is no way, but if anyone can prove me wrong that sure would be great. If you could somehow manipulate the function's namespace before calling it or something, hmmm. Here's an example of what I'm trying to do. code:
I'm not trying to solve a particular problem here (although it would come in handy with something I'm working on, but it's fine without it too), I'm just generally wondering if there's a way to do that in the language. My bets are on "no".
|
# ? Jan 9, 2008 01:54 |
|
Yay, I found the answer! Just do code:
|
# ? Jan 9, 2008 02:28 |
|
I now have this strange urge to start filling my code with clown decorators.
|
# ? Jan 9, 2008 02:37 |
|
Himmit posted:This thread will be useful. Thats one of the biggest joys of python. It really aint hard. I learned python maybe ten years ago , slacking off at work one afternoon doing the tutorial. It was like a huge succession of lightbulbs going off above my head. Then it was straight over to the modules section, and before long I was cranking out all sorts of stuff. Fantastic. The second joy was learning the fine details of the object orientation. Python is such a good language.
|
# ? Jan 9, 2008 02:43 |
|
Haha! Yes, clown coding is the best coding. Eh, it seems that this func_globals is not gonna work since it pollutes the global namespace and I don't want that. code:
I wonder if there's a way to just affect a function's local namespace?
|
# ? Jan 9, 2008 03:00 |
|
Bonus posted:Haha! Yes, clown coding is the best coding. Is there a reason you can't make 'clowns' a global? Unless I'm misunderstanding some implementation-specific need, a global variable should probably do the trick.
|
# ? Jan 9, 2008 03:32 |
|
So why don't you want to edit *args or **kwargs?
deimos fucked around with this message at 06:12 on Jan 9, 2008 |
# ? Jan 9, 2008 05:52 |
|
Bonus posted:Eh, it seems that this func_globals is not gonna work since it pollutes the global namespace and I don't want that. Yeah, func_globals is the set of global variables that the function can see. The closest I can see is to use function attributes: code:
code:
Of course, you can always just make a class with a __call__ method and get lots of flexibility that way.
|
# ? Jan 9, 2008 06:37 |
|
code:
|
# ? Jan 9, 2008 08:29 |
|
Lord Uffenham posted:It prints 1. Booyah. Wow, I can't believe this worked. You realize this is a terrible, terrible hack and I feel dirty for helping you out with it, right?
|
# ? Jan 9, 2008 16:01 |
|
I don't really see the point but if I'm understanding this correctly, then this is nicercode:
|
# ? Jan 9, 2008 17:18 |
|
Lord Uffenham posted:
Yeah but what happens if you call foo(clowns=20)?
|
# ? Jan 9, 2008 17:19 |
|
|
# ? May 11, 2024 16:32 |
|
deimos posted:Yeah but what happens if you call foo(clowns=20)? He didnt want to be able to do that? quote:but I'm wondering if there's a way to do it without having to place the `clowns` argument in the function definition for `bar`. Buffis fucked around with this message at 17:23 on Jan 9, 2008 |
# ? Jan 9, 2008 17:20 |