|
Check out http://www.rmunn.com/sqlalchemy-tutorial/tutorial.html where it says "Transactions". I think that might be what you're looking for.
|
# ¿ May 24, 2008 19:01 |
|
|
# ¿ May 13, 2024 00:27 |
|
Hey m0nk3yz, congratz on the PEP, I read it and it looks real good, I hope it gets accepted!
|
# ¿ May 29, 2008 01:18 |
|
Also, it might do you good to use the named string formatting for more readability.code:
|
# ¿ May 30, 2008 19:58 |
|
code:
|
# ¿ Jun 2, 2008 23:47 |
|
From the commandline, try navigating to the code:
code:
|
# ¿ Jun 4, 2008 01:03 |
|
I found that Java-ish static methods are best translated to module top level functions in Python.
|
# ¿ Jun 4, 2008 17:06 |
|
AWESOME!!!!!
|
# ¿ Jun 6, 2008 13:10 |
|
What qualifies a duplicate entry? What's that column where it's mostly zeroes but one 36 and a 3? Is that the counter?
|
# ¿ Jun 17, 2008 22:36 |
|
Yeah. Also watch that you don't fall into an infinite loop within the __getattr__ or __setattr__ methods. Manipulate the __dict__ directly.
|
# ¿ Jun 23, 2008 20:15 |
|
Milde: Ah, yeah, right, I always consfuse get/setattr with get/setattribute. Those are really awkward names. HatfulOfHollow: try timestamp = oracle.Timestamp(*date). You can also call keyword arguments in that way by using ** with any dict-like object. e: beaten
|
# ¿ Jun 24, 2008 13:28 |
|
http://docs.python.org/tut/node6.html#SECTION006700000000000000000 It's really simple, when defining functions, *args have to come after any other arguments and **kwargs have to come after any *args. Also, quick demo: code:
|
# ¿ Jun 24, 2008 16:09 |
|
Yeah there is. It seems like the best solution here would be Django. It's a web framework for Python. It features a very good templating engine, database abstraction and is generally very easy to use. I'd go so far as to say it's one of the most well planned out and best programming tools today. There's a Django thread here in CoC, so I'd suggest starting there.
|
# ¿ Jun 30, 2008 19:55 |
|
You can try code:
code:
|
# ¿ Jul 1, 2008 00:24 |
|
|
# ¿ Jul 1, 2008 00:27 |
|
Watch out .... in your first example, you're modifying the arguments in place and then returning a copy. So if someone passes a list to that function and tries to use the same list later on, they'll find it's been mysteriously changed. Why not just do code:
Also, it's generally not cool to just use catch-all except clauses because then they also catch KeyboardInterrupt exceptions and whatnot. hey mom its 420 fucked around with this message at 00:35 on Jul 1, 2008 |
# ¿ Jul 1, 2008 00:32 |
|
Sure, it's section 5.1.4 here http://docs.python.org/tut/node7.html It's quite simple actually, this is how list comprehensions behave: code:
|
# ¿ Jul 1, 2008 00:39 |
|
I don't think there's a really idiomatic way of doing that. But you can do it recursively in this manner. - For every element in the list, check if it's a list. --- If it is a list, call the function recursively on it. --- If it's not a list, apply whatever transformations you want to it.
|
# ¿ Jul 1, 2008 23:13 |
|
That doesn't say anything positive about mod_python, only something negative about JSP and PHP. If you develop for WSGI, you can deploy your application on any WSGI-compilant server. There's also a WSGI wrapper for mod_python that makes it possible to run WSGI apps on mod_python.
|
# ¿ Jul 2, 2008 11:49 |
|
How about you just write it into a dict in Python syntax and then import the dict? edit: or just set variables and then import the module. You know, like if you have test_settings.py and then in it you do code:
hey mom its 420 fucked around with this message at 22:15 on Jul 7, 2008 |
# ¿ Jul 7, 2008 22:08 |
|
No, __getslice__ is deprecated, don't use that. Make sure that you have a new-style object there. So if you havecode:
code:
|
# ¿ Jul 8, 2008 18:54 |
|
Your awesomeproject directory should have an __init__.py file, even if it's empty. That makes it a python package. Doing from something import * is generally always considered a bad idea because you can get all kinds of name clashes. What you could do is mimic what PyGame did — you could define a file called, say, locals.py in your root package. Then in locals.py import everything you need: code:
hey mom its 420 fucked around with this message at 20:49 on Aug 18, 2008 |
# ¿ Aug 18, 2008 20:46 |
|
Yeah, in base/__init__.py do:code:
Basically, if you put stuff into a package's __init__.py, it acts like the package was the script. So, for instance, if you have a file foo/__init__.py and in that file you have code:
|
# ¿ Aug 19, 2008 03:11 |
|
code:
|
# ¿ Aug 21, 2008 02:52 |
|
Check out this video http://video.google.com/videoplay?docid=-6459339159268485356&ei=CEOtSMOwHZCuigKD_qjpDg&q=python+3000+guido at approximately 50 minutes and 30 seconds where Guido talks about turning print into a function, how most people hated it at first, but he gives a nice reasoning as to why it's being done.
|
# ¿ Aug 21, 2008 11:32 |
|
The best thing is though, you won't even have to run a search and replace to change it to logging or whatever. You can just do something like print = Logging.log
|
# ¿ Aug 22, 2008 11:26 |
|
I'll never get why people make their own style guidelines when there's good old PEP 8.
|
# ¿ Sep 3, 2008 18:13 |
|
Just use a generator.code:
|
# ¿ Sep 13, 2008 02:44 |
|
Use generator expressionscode:
|
# ¿ Sep 26, 2008 13:24 |
|
Yeah, that's perfect for the next method of generators.code:
|
# ¿ Sep 26, 2008 16:13 |
|
Also a great way to do it would be to use lazy slicing from the itertools module.code:
|
# ¿ Sep 27, 2008 12:03 |
|
2.6 is out, w00t!
|
# ¿ Oct 2, 2008 12:30 |
|
Use generators! (What a surprise! )code:
|
# ¿ Oct 2, 2008 16:10 |
|
Then you can just implement normal bisection on the list that you have, only instead of doing your_list[x], you do your_list[x]['DxY'].
|
# ¿ Oct 2, 2008 16:19 |
|
One way to do it:code:
code:
hey mom its 420 fucked around with this message at 00:32 on Oct 13, 2008 |
# ¿ Oct 13, 2008 00:30 |
|
Ugh, I've been in Haskell land for too long, that reduce was uncalled for.
|
# ¿ Oct 13, 2008 00:36 |
|
code:
|
# ¿ Oct 16, 2008 12:54 |
|
Python supports functions as first-class objects. So one way to do it would be this.code:
|
# ¿ Oct 23, 2008 06:03 |
|
Yeah, that's true.
|
# ¿ Oct 23, 2008 07:52 |
|
code:
|
# ¿ Oct 23, 2008 11:23 |
|
|
# ¿ May 13, 2024 00:27 |
|
He could, but somehow I feel the Python mantra of explicit is better than implicit should be taken into account here.
|
# ¿ Oct 23, 2008 21:57 |