|
m0nk3yz posted:That's only partially true: Python can use multiple cores, python threads can not, as shown by effbot's recent wide-finder experiment (http://effbot.org/zone/wide-finder.htm). If you fork processes you can easily make use of multiple cores. Of course, fork/exec means you loose the shared context of pthreads. Another thing that Fredrik's article pointed me towards when I first read it was defaultdicts, which are, in few words, loving awesome. So much so that I went back through all my code looking for places to use them. edit: OP: you might want to add this link up there: Effbot's Python Standard Library book. deimos fucked around with this message at 01:49 on Nov 5, 2007 |
# ¿ Nov 5, 2007 01:42 |
|
|
# ¿ May 3, 2024 12:36 |
|
inveratulo posted:Frameworks like Zope or Django - these seem to have some kind of barrier to entry, lot of gotchas and I'm not sure I want to deal with those headaches just yet. I can tell you this much: django can be as unobtrusive as you want it to be. The only thing you really can't change is the ORM, but it's also unobtrusive since you can do raw SQL with it. Git posted:Really though, Django might be overkill but it makes development fly by. I can't recommend it enough, but if you're absolutely certain that it won't suit, you might do well to look at the smaller frameworks like Pylons or CherryPy. Actually, you've a hell of a lot of frameworks you could choose from if any one doesn't suit. Pylons is nice and very adaptable, but I prefer django since it comes with good standards for everything and if you don't like one aspect you can change it rather easily (I've use cheetah for my templating language, for example).
|
# ¿ Nov 5, 2007 14:27 |
|
Ugg boots posted:So, I'm working on a game for a class, in PyGame, and I had a question about Python: You can't use type(obj)?
|
# ¿ Nov 6, 2007 18:10 |
|
Mr. Heavy posted:Is there any really good standard library reference for Python? Compared to Ruby, the official documentation absolutely sucks, and it's really frustrating me because I absolutely adore the Pylons framework and then doing more menial Python stuff in the framework is comparatively painful. http://effbot.org/librarybook/ I posted it earlier but OP hasn't added it.
|
# ¿ Nov 12, 2007 14:50 |
|
m0nk3yz posted:It was/is added I am blind, sorry. Now more on topic: woop, properties for 2.6 and 3k: http://bugs.python.org/issue1416
|
# ¿ Nov 12, 2007 16:16 |
|
m0nk3yz posted:Dude, gently caress whitespace. http://timhatch.com/projects/pybraces/ from __future__ import braces I actually had someone argue the whole whitespace thing with me in college. I told him I didn't care and that I much prefer the way whitespace is significant in python. Same guy had some problem with his java code on one of our classes and asked me to check it... yep, he did an if, if, else and had it indented wrong and attributed the else to the wrong if. deimos fucked around with this message at 04:17 on Nov 14, 2007 |
# ¿ Nov 14, 2007 04:14 |
|
Has anyone used pyglet yet? I've been playing around with it and it's awesome, I think I am going to see if I can make a Visual Hub wannabe with it.
|
# ¿ Nov 16, 2007 23:25 |
|
Yes, I know I was the last reply to this thread, but I am currently debating a e/n post because I just got bit by one of python's more annoying "features": all directories are modules. Working on setting up my personal dev server, and goddamnit if I didn't have the hardest time setting up my virtual host with fastcgi. Who would've thought /home/lighttpd/vhosts/domain.tld/django was a bad loving idea for putting the django projects for my site. Yep. I just spent about half an hour wondering what the gently caress was wrong. deimos fucked around with this message at 01:44 on Nov 18, 2007 |
# ¿ Nov 18, 2007 01:39 |
|
bitprophet posted:Call me stupid, but I don't get exactly what was wrong there? Never used FCGI, FWIW, always mod_python. Not a problem with fcgi. But it was trying to import stuff in my directory called django, not the actual django stuff in my site-packages.
|
# ¿ Nov 18, 2007 04:48 |
|
m0nk3yz posted:When Django Apps are served up via mod_python within Apache, the model is wildly different (given apache does use multiple cpus/cores). Same with FastCGI and WSGI.
|
# ¿ Nov 19, 2007 14:17 |
|
I would personally rewrite:code:
code:
duck monster posted:Yup. Thats the magic of python. Dictionarys, lists and tuples. So simple, and yet so expressive. Sure you can do it in other languages, but python makes it so elegant. Look into pyglet. OpenGL is pretty much a first class citizen. Not to mention a of a positional sound library. deimos fucked around with this message at 02:40 on Nov 21, 2007 |
# ¿ Nov 21, 2007 02:37 |
|
m0nk3yz posted:The latest edition of Core Python Programming is really good. Covers 2.5 to boot. I second this, I particularly like Core Python's treatment of variables and memory.
|
# ¿ Nov 25, 2007 18:47 |
|
I use VIM. But as far as IDEs go PyDev is best free, Wing is best commercial.
|
# ¿ Nov 28, 2007 15:02 |
|
Git posted:I use nano through Cygwin. Yes, I apparently do hate myself. god, notepad++ is probably 100x better than nano through cygwin.
|
# ¿ Nov 28, 2007 16:41 |
|
Make a manager for entries and use a filter: categories__in=[ list of categories on current entry instance ] and slice it to the first 5, it generates two queries. Actually a manager is not needed for this, but it's the django way. edit: not sure now, you might have to categories__id__in = [ list of category ids on current entry instance ] deimos fucked around with this message at 20:22 on Dec 4, 2007 |
# ¿ Dec 4, 2007 20:14 |
|
xkcd is awesome.
|
# ¿ Dec 5, 2007 06: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 |
|
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 |
|
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 |
|
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 |
|
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 |
|
Lord Uffenham posted:
Yeah but what happens if you call foo(clowns=20)?
|
# ¿ Jan 9, 2008 17:19 |
|
m0nk3yz posted:Interesting you should say this now - Someone just posted an excellent Python reading list here: http://www.wordaligned.org/articles/essential-python-reading-list Ohh and here I thought I was the only one that had this reaction when browsing the library docs: quote:itertools
|
# ¿ Feb 2, 2008 12:02 |
|
PyRXP is probably your best choice.
|
# ¿ Feb 6, 2008 20:46 |
|
epswing posted:On the threading module page, why is it Because he's updating the global value at the same time, seems like a convoluted way of doing it since he's returning it too. ynef posted:Because they're trying to save an extra line. Both the object specific "value" (self.value) and the global variable "value" are affected, and set to "self.value + 1". Yeah but he's returning and assigning to value anyways outside the critical section. You might as well return self.value. deimos fucked around with this message at 19:33 on Feb 10, 2008 |
# ¿ Feb 10, 2008 19:29 |
|
epswing posted:Ok, let me ask this, if I am pretty sure it might be a remnant from the evolution of the example, ie. a previous version might have just used the global value without the return assignment.
|
# ¿ Feb 10, 2008 22:18 |
|
Hey I was wondering, what way do you guys use of getting a class from a string? I've been doing it in a fairly convoluted way and really think there's an easier way.
|
# ¿ Feb 15, 2008 20:50 |
|
No Safe Word posted:You mean serialization? There are a couple of ways: the shelve and pickle modules that are built in will do it for you fairly easy and there are a number of other ways as well. Nah, I am more thinking for settings and class loading. Like storing the name of the class you're supposed to use for a certain task on a settings file as a string then loading the correct class. Right now I use an eval and I really don't like it.
|
# ¿ Feb 15, 2008 22:49 |
|
This is something I threw together last time I needed importing from CSV:code:
code:
deimos fucked around with this message at 14:52 on Feb 25, 2008 |
# ¿ Feb 25, 2008 03:01 |
|
or you can browse django's source and grab SortedDict. edit: Habnabit posted:Oooor you could wrap a sorted around it. for item in sorted(struct): ... that should be for key in sorted(dict): because sorted() on a dict only returns the keys also: oRenj9 posted:The ordering is quite consistent for being magical. It's consistent, but it differs accross implementations, which is exactly what the docs says. Python Library Docs posted:Keys and values are listed in an arbitrary order which is non-random, varies across Python implementations, and depends on the dictionary's history of insertions and deletions. If items(), keys(), values(), iteritems(), iterkeys(), and itervalues() are called with no intervening modifications to the dictionary, the lists will directly correspond. This allows the creation of (value, key) pairs using zip(): "pairs = zip(a.values(), a.keys())". The same relationship holds for the iterkeys() and itervalues() methods: "pairs = zip(a.itervalues(), a.iterkeys())" provides the same value for pairs. Another way to create the same list is "pairs = [(v, k) for (k, v) in a.iteritems()]". deimos fucked around with this message at 15:26 on Feb 28, 2008 |
# ¿ Feb 28, 2008 15:17 |
|
Wedge of Lime posted:Though they're still having issues, I believe the ordering of dicts is what causes the following lovely bug (I believe): Isn't that because they use regular dicts instead of the sorted alternative? I know that's why they're having some tests fail on PyPy. The tests expect CPython ordering.
|
# ¿ Feb 28, 2008 21:11 |
|
VirtuaSpy posted:Newbie Python question: Instead of copy/pasting, read the docs, try: chart_data.read_csv('file','%f,') heck I think chart_data.read_csv('file',',') should work.
|
# ¿ Feb 28, 2008 22:30 |
|
Habnabit posted:I was trying to use the same variable names: My bad. But still, it was worth clarifying.
|
# ¿ Feb 29, 2008 19:25 |
|
outlier posted:Here's something basic, but it might represent a gap in my Python-fu. You can do this with the decimal module and setting precision to 3 on the context I guess. You're probably best served by casting it to an engineering string. ed: forgot link
|
# ¿ Mar 2, 2008 20:57 |
|
So with Sun hiring Leung and Wierzbicki that makes what 3 major companies (Google, Microsoft, Sun) with vested interests in Python?
|
# ¿ Mar 4, 2008 21:47 |
|
porkface posted:Yahoo!, NASA Err yes Yahoo! too, forgot. Who of the big contributors to python development does NASA payroll?
|
# ¿ Mar 4, 2008 23:29 |
|
FrontLine posted:Does anybody know how/where to get the Python language pack for VS2005? AFAIK you can't integrate it, instead you get to use: IronPython Studio
|
# ¿ Mar 6, 2008 21:23 |
|
inveratulo posted:How do I send control characters through either telnetlib or pexpect? Ok, this is a slight case of RTFM, because pexpect has a sendcontrol()
|
# ¿ Mar 15, 2008 15:57 |
|
|
# ¿ May 3, 2024 12:36 |
|
inveratulo posted:hmmm sendcontrol was the first thing I tried actually but I couldn't get it to work. I kept getting an attribute error: update your pexpect
|
# ¿ Mar 15, 2008 18:16 |