![]() |
|
Re: ** Python Support Thread **
Quote:
|
Re: ** Python Support Thread **
Quote:
Manual copy: 9.90991711617 List comprehension: 3.24251699448 Suck it! |
Re: ** Python Support Thread **
You got better than the base model! Nice!
|
Re: ** Python Support Thread **
I got the upgraded model. 'Cause that's how I role!*
* When work pays for it... |
Re: ** Python Support Thread **
Imagine what would happen if I paid $600, huh?
(Yeah, go ahead and pick on my 45pt font and limited color pallet) |
Re: ** Python Support Thread **
Quote:
|
Re: ** Python Support Thread **
Quote:
|
Re: ** Python Support Thread **
dave,
xhad's answer is on the money; your question is kinda weird because functools and lambda are largely orthogonal. i have used functools.partial to get rid of a closure which existed solely to bind an argument from a model (python class) so that the view (template) could call that function without the argument being exposed unnecessarily. the real example is quite a bit more involved (and included some horrific and unreadable lambdas!) but the punch line is the resulting code is a lot easier to read and understand. functool.wraps is also cool. at work we use a lot of python decorators, which is kind of mind-bending at first, but ultimately reduces a ton of code duplication and makes things more readable. you can sort of use lambdas to do these things, but at the expense of readability. |
Re: ** Python Support Thread **
Guido hates lambda and would have removed it from Python 3 if not for the massive amounts of outcry when he announced it.
|
Re: ** Python Support Thread **
What are some good projects to do for a beginner?
In school I had classes in Matlab and C++ but I don't really feel that I learned that much. I've started trying to become competent in a programming language. I'm almost finished with a python book + doing some stuff on the internet. However I have no idea how to apply what I know, I don't really have a certain project that I want to do. Does anyone have some suggestions? Reading a book and doing exercises is only fun for so long. |
Re: ** Python Support Thread **
klior,
necessity is the mother of invention. find an itch and scratch it! |
Re: ** Python Support Thread **
Quote:
I looked it up a bit and found a few threads on Stack Overflow. They seemed pretty divided on this. One case stood out that lambda allows for un-ordered arguments, though I'm not sure why the person believed this is a good thing. |
Re: ** Python Support Thread **
Quote:
Quote:
- being able to just throw a dictionary of name-value pairs at a function instead of remembering "ok it wants foo, bar, baz... or is it foo, baz, bar?" - being able to leave out args you don't care about/don't know about. handy for lots of things, though i'll admit i don't have a great use case for doing this with a lambda -- probably because i don't do a lot of functional programming in python. |
Re: ** Python Support Thread **
What does lambda have to do with unordered arguments?
Code:
def foo(a, b): |
Re: ** Python Support Thread **
Quote:
This is all good answers, but I guess I'm too amateur to see how it is helpful outside of command-line usage, whether you are talking about a named or anon function. Just seems sloppy to think you would need a function that takes so many arguments you can't conceivably run a program without making something out-of-order. Inside a program, I wouldn't want to do this trick, since I can already see it turning into a massive bug unless there is a comment that says: "hey, these are out of order, go look at file xyz to see what the issue is..." or maybe you have the offending function copy/pasted in the comment area, but that's just my initial impression. When I read "out of order arguments," it sounds like there is an issue with a function trying to take way too many arguments to work on many different things and perhaps the function arguments aren't semantic, which I would think is going to be necessary if you have a function with so many arguments it can become confusing. I'm not saying there should be maximum amount of arguments as a rule per se, and there are times I would be able to appreciate this feature during debugging. I'll admit that there a few issues with my logic. don't get me wrong, I do use stuff like: def myFun(one=1, two=2, three=3): pass myFun(one=4) Well, not THAT, of course... Quote:
http://stackoverflow.com/questions/5...tion-vs-lambda Some more links I found on front page of [everyone's favorite search engine]: http://stackoverflow.com/questions/3...tial-necessary funny how this one seques into itertools and then how to use lambda and functools: http://stackoverflow.com/questions/2...ilter-function Anyways, all of this makes me exited to look into functools. |
Re: ** Python Support Thread **
Quote:
|
Re: ** Python Support Thread **
i've started learning python and for the most part it's been rewarding. i can now do useless tasks with 4 or 5 lines of code and that makes me feel like i am learning.
i became very frustrated over the past hour or so trying to install easy_install. if i did it right, then i should be able to run from python cmd line (i think? a lot of the language/terms such as 'shell' are confusing for me...maybe i'm supposed to run from windows cmd line? not that that works either...): >>>>easy_install mypackage but i keep getting SyntaxError: invalid syntax i'm using windows 7 64 bit python 2.7 most tilting part is that it's called easy_install and yet i ended up just installing my packages manually by pasting the right directory in the right folder. the packages are now working like a charm yet after googling and testing several possible solutions, easy_install remains a mystery to me. |
Re: ** Python Support Thread **
you are meant to use the "windows cmd line".
|
Re: ** Python Support Thread **
ok thanks tyler cracker. i got a different error message using windows command line and i tried a few different solutions. it involved typing in "cd" which is probably one of the most basic things but i've never done before which probly illustrates the extent of my cluelessness.
but now it works! :) so glad i figured it out now to figure out how to use my new packages |
Re: ** Python Support Thread **
I'm relatively new to python, but not to programming, and I'm certainly new to pypoker-eval which I'm trying to use.
It all works well, except I was getting suspciously low equity, and discovered that summing all the ['ev'] entries in each hand consistently had the total equity at around 997. I couldn't find any known bugs related to this, could it be a symptom of my implementation rather than a bug in pypoker-eval? |
Re: ** Python Support Thread **
rounding error? chop equity being left out?
|
Re: ** Python Support Thread **
Quote:
Quote:
sometimes you need to do weird things because you're stuck interoperating with a component you can't control and want to do something it wasn't strictly designed for. unit/integration testing is one place where this can happen. heh, i know amber, author of the accepted answer. i think it's no coincidence that in all three of your SO links, someone points out that a list comprehension or generator expression is way shorter and easier to read. functional programming in python is like commuting on a unicycle: every once in a while it will be the most elegant solution, but mostly you look ridiculous and there are far easier ways to get the job done. [1] in before debate about whether GOSUB or some kind of GOTO pattern constitute "functional programming". also in before "my programs are functional... barely :rimshot:". |
Re: ** Python Support Thread **
trying to learn about the IDLE debugger. trying to watch videos like this:http://www.youtube.com/watch?v=bZZTeKPRSLQ
but it looks like they are on linux. cant even get the first line import buggy to run. any good ways to learn? also i heard WinPBD is pretty good so i might look into that over pdb |
Re: ** Python Support Thread **
we use ipdb at work. that's all i can tell ya.
|
Re: ** Python Support Thread **
Quote:
Thanks for these answers. They're really interesting a excellent food for thought. The decorators stick out for me as well. I've been meaning to see how they function, but I haven't gotten around to it. Quote:
Funny quote I found in some not-python wiki on some not-python functional programming language: Quote:
|
| All times are GMT -4. The time now is 12:19 PM. |
|
Powered by vBulletin®
Copyright ©2000 - 2026, Jelsoft Enterprises Ltd.
Copyright © 2008-2020, Two Plus Two Interactive