|
Janin posted:From http://code.google.com/p/unladen-swallow/wiki/Releases And Q1 doesn't reflect current benchmarks - and more patches, which have not been pushed upstream have been applied to unladen swallow trunk. This quarter's release has focused on LLVM support, and next quarter's will be an optimization free-for-all. Again - run pypy through real world benchmarks - which unladen-swallow's are (they range from Django ones, to others) and you'll get a better idea of pypy's performance. I'm not denying it could/can be faster than CPython, or even unladen swallow - I'm saying that the benchmarks they've done have been very selective, and not representative of real applications.
|
# ? Jun 28, 2009 02:56 |
|
|
# ? May 9, 2024 18:20 |
I am looking to start learning Python and have had a book for years on it. The book was written when Python 2.0 was around. Is it too outdated to use? I just saw that a new 3.1 release came out not too long ago. What is considered the most used/versatile Python release? Should I start fresh with the newest 3.1?
|
|
# ? Jun 28, 2009 04:02 |
|
buttcheekwarrior posted:I am looking to start learning Python and have had a book for years on it. The book was written when Python 2.0 was around. Is it too outdated to use? I just saw that a new 3.1 release came out not too long ago. I really, REALLY wanted to just start with 3.0 / 3.1, but if you intend on using anything outside the included libraries within at least the next year, you should use 2.6. Python's download page posted:The current production versions are Python 2.6.2 and Python 3.1. You should start here if you want to learn Python or if you want the most stable versions. Note that both Python 2.6 and 3.1 are considered stable production releases, but if you don't know which version to use, start with Python 2.6 since more existing third party software is compatible with Python 2 than Python 3 right now. Here are some quick download links.
|
# ? Jun 28, 2009 04:19 |
|
buttcheekwarrior posted:The book was written when Python 2.0 was around. Is it too outdated to use?
|
# ? Jun 28, 2009 05:48 |
|
Scaevolus posted:Pretty much. Try the official tutorial, it's really good. As is http://diveintopython.org/
|
# ? Jun 28, 2009 05:51 |
|
king_kilr posted:As is http://diveintopython.org/ I read this book cover-to-cover electronically, and then purchased a copy. Definitely a fantastic resource to learn the language.
|
# ? Jun 28, 2009 07:49 |
|
Ferg posted:I read this book cover-to-cover electronically, and then purchased a copy. Definitely a fantastic resource to learn the language. Seconded. It is a really great book if you have some prior development knowledge in any other language.
|
# ? Jun 28, 2009 08:29 |
|
Hey, more newbness here. I am trying to make a little program that will do some phonological analysis. Basically, get the phonetic representation of a word and return the phonological representation. So, to keep it simple just work with assimilation right now. So the user gives something like "umty" and return "umdy". so if "t", "p" or "k" appear right after "m" or "n" they turn into "d", "b", and "k" respectively. so we set up some string sets and a dictionary (ignoring uppercase for now) nasal = "mn" stops = {"t":"d","p":"b","k":"g"} what I am trouble figuring out is how to say if a string has a series of nasal immediately followed by a stop, then replace the stop with the associated value.
|
# ? Jun 29, 2009 14:15 |
|
Balam posted:Hey, more newbness here. and here's a simple implementation of it: http://code.activestate.com/recipes/52213/
|
# ? Jun 29, 2009 16:17 |
|
MononcQc posted:http://en.wikipedia.org/wiki/Soundex to not reinvent the wheel You can do a lot better than Soundex.
|
# ? Jun 29, 2009 18:17 |
|
python + natural language process = http://www.nltk.org/code
|
# ? Jun 29, 2009 18:45 |
|
tef posted:python + natural language process = http://www.nltk.org/code I tech-reviewed that book, but they forgot me in the credits. *sad face*
|
# ? Jun 29, 2009 19:06 |
|
if you want simple then just do double metaphone.
|
# ? Jun 29, 2009 19:09 |
|
Zombywuf posted:You can do a lot better than Soundex. Compared to what he was attempting to do (comparing 'p' and 'b', seeing for more general pronounciation), soundex seems to be alright. If he wanted to dig deeper, wikipedia had the links to do so (ie.: http://en.wikipedia.org/wiki/Phonetic_algorithm). If he takes the time to read the entry and needs a more advanced solution, I'm sure he'll be able to dig through the first 2 lines of the article and follow the links. I'm pretty sure the guy is more than 4 years old and I believe he can do some searching. Sometimes a first term is all one needs to be able to go forward. Otherwise, providing links yourself would have been way more helpful (like the one tef posted, which looks really nice).
|
# ? Jun 29, 2009 20:21 |
|
How would I keep printing on the same line (just using the shell), like if I was printing the speed something was downloading at?
|
# ? Jun 30, 2009 06:15 |
|
His Neutralness posted:How would I keep printing on the same line (just using the shell), like if I was printing the speed something was downloading at? print "\r" # carriage return
|
# ? Jun 30, 2009 06:37 |
|
Finish a print statement with a comma
|
# ? Jun 30, 2009 07:14 |
|
I think he means in the same location, not just on the same line. In that case you will probably want to look at curses.
|
# ? Jun 30, 2009 07:19 |
|
Oh, I just use sys.stdout.write(); sys.stdout.flush()
|
# ? Jun 30, 2009 07:31 |
|
king_kilr posted:Oh, I just use sys.stdout.write(); sys.stdout.flush() Stupid sys.stdout!!11 http://bugs.python.org/issue5313
|
# ? Jun 30, 2009 12:40 |
|
His Neutralness posted:How would I keep printing on the same line (just using the shell), like if I was printing the speed something was downloading at? code:
|
# ? Jun 30, 2009 19:39 |
|
another nubby question: let's say i have a dictionary, filled up with int:string lit pairs. I would like to iterate through this dictionary and use the strings as identifers for a series of new lists the problem, obviously, is that string lits can't be used as identifiers i've been reading through the docs for the built-ins for a couple hours, but the best i've got so far is 'cannot assign to operator' is tearing the quotes off a string and using it as an identifier realistic? Possible? Should i just stick to pumping out dictas and lists by hand? Any help appreciated, sorry for the capitalization, phone post
|
# ? Jun 30, 2009 23:55 |
|
I'm not sure if I understand you, but you can do this:code:
edit: If you are doing this inside a class, look at __setattr__. supster fucked around with this message at 00:05 on Jul 1, 2009 |
# ? Jul 1, 2009 00:03 |
|
supster posted:I'm not sure if I understand you, but you can do this: i should have mentioned that this wll be in a class, i'm not out to flood main with a bunch of garbage. I need a method that i can throw a number and class instance at and have it add a series of uniquely-named attribute-dicts to said class instance, representing entities or locations or w/e. setattr appears to be precisely what i needed, thaks mate! i feel like 'your skill in python has increased(10)!' exciting edit: just wanted to show off what i made code:
What it produces given an 8x8 grid from the class it's a part of: ['a00', 'a01', 'a02', 'a03', 'a04', 'a05', 'a06', 'a07', 'a10', 'a11', 'a12', 'a13', 'a14', 'a15', 'a16', 'a17', 'a20', 'a21', 'a22', 'a23', 'a24', 'a25', 'a26', 'a27', 'a30', 'a31', 'a32', 'a33', 'a34', 'a35', 'a36', 'a37', 'a40', 'a41', 'a42', 'a43', 'a44', 'a45', 'a46', 'a47', 'a50', 'a51', 'a52', 'a53', 'a54', 'a55', 'a56', 'a57', 'a60', 'a61', 'a62', 'a63', 'a64', 'a65', 'a66', 'a67', 'a70', 'a71', 'a72', 'a73', 'a74', 'a75', 'a76', 'a77'] 64 uniquely-named dictionaries, hopefully ripe for stuffing full of references to other things. The end-goal is a text-based adventure of sorts, ideally generic enough that I can drop some sprite graphics on top without too much wrangling. I'd like to take it to the internet at some point, although I've only just started looking at Django and TurboGears. Let me know if I'm going in a wrong direction here, or if you'd like to see the class that this method is a part of. Alcohol Kills fucked around with this message at 02:38 on Jul 1, 2009 |
# ? Jul 1, 2009 01:19 |
|
Bumping because I'm and Python has the most amazing morphyness I have yet to encounter in a programming language. Granted, all I've used is C++ and VB, but the rate of learning that python bestows through the magic of the interpreter is just incredible, for one. I didn't learn in a full semester of C++ or VB class to do the things I have learned on my own in Python in the last few days. edit: I totally forgot the best part. Python loads and reloads modules on the loving fly wowwwww it's like I'm playing in twelve dimensional space or something. Am I being silly for being blown away by the implications of that? I mean, the way I'm perceiving it, I can literally have a baby module make a copy of a module it is using as daddy, edit the copy of that module according to whatever parameters, rename the copy to overwrite the original, and then have the baby module reload the daddy module and change behaviors accordingly? Without a break in execution? That's like, fffffffff what? Do I understand that right? Alcohol Kills fucked around with this message at 05:17 on Jul 1, 2009 |
# ? Jul 1, 2009 05:09 |
|
Alcohol Kills posted:Am i doing anything ridiculously stupid? is this way more code than i need? Is there any real reason your program needs to see these as attributes? Could this be accomplished with a simple 2D array? cells = [[{} for x in range(8)]]*8
|
# ? Jul 1, 2009 08:19 |
|
sund posted:Is there any real reason your program needs to see these as attributes? code:
|
# ? Jul 1, 2009 08:25 |
|
Alcohol Kills posted:Bumping because I'm and Python has the most amazing morphyness I have yet to encounter in a programming language. Now go play some Javascript, here's a starter (untested): code:
Zombywuf fucked around with this message at 18:06 on Jul 1, 2009 |
# ? Jul 1, 2009 14:01 |
|
Scaevolus posted:that might give you some unexpected behavior
|
# ? Jul 1, 2009 15:59 |
|
Is there a good way I can see a summary of changes between Python 2.3 and 2.6? I need to evaluate the effort required to make a script targetted to 2.6 work under 2.3.
|
# ? Jul 1, 2009 20:20 |
|
supster posted:Is there a good way I can see a summary of changes between Python 2.3 and 2.6? I need to evaluate the effort required to make a script targetted to 2.6 work under 2.3. 2.3 -> 2.4 = http://docs.python.org/whatsnew/2.4.html 2.4 -> 2.5 = http://docs.python.org/whatsnew/2.5.html 2.5 -> 2.6 = http://docs.python.org/whatsnew/2.6.html
|
# ? Jul 1, 2009 22:10 |
|
I was hoping to avoid going over the entire documents, but I did. If anyone needs this in the future, here's a reference of changes likely to affect day-to-day development:
I'm sure I skipped over some things. edit: \/ fixed, thanks. supster fucked around with this message at 23:52 on Jul 2, 2009 |
# ? Jul 2, 2009 00:08 |
|
supster posted:I was hoping to avoid going over the entire documents, but I did. If anyone needs this in the future, here's a reference of changes likely to affect day-to-day development: I think you got those two pointing at the same place. I think this is what you wanted? http://docs.python.org/whatsnew/2.6.html#pep-371-the-multiprocessing-package Swed fucked around with this message at 05:25 on Jul 2, 2009 |
# ? Jul 2, 2009 05:15 |
|
So, I shortened some code I wrote in a tkinter program from this:code:
to: code:
darknife fucked around with this message at 01:32 on Jul 3, 2009 |
# ? Jul 3, 2009 01:29 |
|
k = [Label(fGrid, text=randice(Dice), font=('Arial Black',80), pady = 10, padx=40).grid(row=x,column=y) for x in range(4) for y in range(4)]
|
# ? Jul 3, 2009 01:35 |
|
Bonus posted:k = [Label(fGrid, text=randice(Dice), font=('Arial Black',80), pady = 10, padx=40).grid(row=x,column=y) for x in range(4) for y in range(4)] List comprehension, right?
|
# ? Jul 3, 2009 01:41 |
|
Yes indeed!
|
# ? Jul 3, 2009 01:45 |
|
Thank you, sir, you reminded me. I didn't get to that in my reading so now I shall learn about it.
darknife fucked around with this message at 02:04 on Jul 3, 2009 |
# ? Jul 3, 2009 01:51 |
|
Bonus posted:k = [Label(fGrid, text=randice(Dice), font=('Arial Black',80), pady = 10, padx=40).grid(row=x,column=y) for x in range(4) for y in range(4)] code:
|
# ? Jul 3, 2009 04:52 |
|
|
# ? May 9, 2024 18:20 |
|
If you're not saving the result of a list comprehension, you probably shouldn't be using one. They don't exist just to win rounds of Python golf, but to provide an elegant alternative to the map(lambda:) pattern. In fundamentally procedural code such as was posted, for-loops are easiest to read. The original poster had it correct: just use two loops. If you're using 2.6 there's a built-in function to separate the loop and index generation: code:
|
# ? Jul 3, 2009 05:23 |