|
Hey guys, I've started learning Python as my start to beginning to learn programming, hopefully I'll have the staying power to learn a thing or two. Is it alright if I post really newbie questions here?
|
# ¿ Jan 16, 2008 09:34 |
|
|
# ¿ Apr 28, 2024 08:07 |
|
Hey, I'm a python and programming newbie, I've been going through some newbie tutorials, just getting a feel for whats going on. I'm just wondering if someone could explain to me how calling a function and using it is working here:code:
|
# ¿ Aug 28, 2008 08:38 |
|
Thanks guys, Grey Area that's an awesome explanation and exactly what I was looking for, much thanks for taking the time to type it
|
# ¿ Aug 28, 2008 10:45 |
|
[st]Newb question, whats the logic behind if __name__ == '__main__'? It seems like some kind of way to test code but I can't quite work it out [/st] cancel that, I've worked it out! LuckySevens fucked around with this message at 09:22 on Oct 17, 2008 |
# ¿ Oct 17, 2008 09:08 |
|
noob question time again, since the last answers I got were pretty darn good I'm trying to write a quick function to sort and return filenames in a directory by order of file extension. I tinkered myself for a little while but couldn't get anything to work cleanly, so I did some google cheating and found this: code:
|
# ¿ Oct 28, 2008 07:24 |
|
At first I read the explanation and I was like "wow programmer guys love talking about how they'd do it", but by breaking the problem down into a different method its helped me think and understand whats going on. I was a little bit clueless on the sorted() function parameters and its starting to click now. Very cool how much versatility (and shortcuts) inbuilt functions can have. Thanks guys, and once again, such a good explanation there may be another q soon
|
# ¿ Oct 28, 2008 12:09 |
|
Pie Colony posted:This may be a stupid question but the one thing I don't like about teaching myself a language vs. taking a class is that you never have an opportunity to make sample programs, something that I feel really helps me in reinforcing the education. Is there like a collection or list or something of small programming assignments designed to test your knowledge? Check out the python forums: http://python-forum.org/pythonforum/index.php My education was just opening up already built programs, trying to understand them, then coding my own additions and seeing if I could get it to work. Its fun, you get to see how other people code, as well as code yourself, and you even get something useful at the end of it.
|
# ¿ Jun 16, 2009 09:09 |
|
tef posted:andLinux? you can run it within windows and it plays reasonably nicely 32bit only though.
|
# ¿ Jun 19, 2009 03:38 |
|
Is there an alternative to mod_python, since I'm running 2.6? I found some vague info from google on how to alter the install, but I can't get it to work.
|
# ¿ Jun 22, 2009 12:42 |
|
Why are people pissed over Tornado?
|
# ¿ Sep 14, 2009 12:04 |
|
Write a .bat file?
|
# ¿ Dec 23, 2009 06:38 |
|
GregNorc, you should try out the python forums beginner section, when I first started programming that's what I did, it allowed me to ask dumber questions and there's a lot of people willing to slowly explain stuff to you. They don't mind if you ask 10 questions a day.
|
# ¿ Jan 3, 2010 01:35 |
|
tef posted:Python by default doesn't care about the death of children:
|
# ¿ Jan 3, 2010 09:12 |
|
I'm using urllib2 to download a rar file, but its coming up as corrupt despite it being the correct size. What's something special I need to do?
|
# ¿ Jan 3, 2010 11:36 |
|
tripwire posted:Are you writing it to a file in binary mode or ascii? Binary, using wb mode.
|
# ¿ Jan 3, 2010 23:27 |
|
yeah good idea, i'll give that a whirl
|
# ¿ Jan 4, 2010 00:45 |
|
if in doubt, just use 2.6 for now, its better supported.
|
# ¿ Jan 12, 2010 10:15 |
|
I'm creating a range of dates for a stock market script, I need a tuple with a date, then another date 10 days back from the original excluding weekends (and ideally any time when the market is closed), another 10 days back from the last date in the tuple, etc. I've been looking at the docs and the only way I can think of to do it is to extract the name of the days between the date ranges and adjusting how many days I go back depending on whether a saturday or sunday turns up, but in my coding so far it doesn't seem very elegant nor would it take into account public holidays (which would probably require a preloaded list of excluded dates to be checked against which make my little method even more cluttered). Is there an easy way to do this or am I doing this the hard way?
|
# ¿ Mar 7, 2010 18:12 |
|
ChiralCondensate posted:The datetime module has some helpful stuff for counting back and forth on the calendar, if you haven't found it already. You could make a date object out of the starting date, and decrement it by a timedelta(days=1) instance, counting off those days that aren't weekends (date.weekday() not in (5,6)) and aren't in a list_of_public_holidays. Nice, what I was looking for, thank you
|
# ¿ Mar 8, 2010 04:45 |
|
Stupid python question, I'm sorting a 2x20 list with a string and a % integer, and I want to sort by the absolute value and put the highest 5 entries into a list. I suck at this but this is what I came up with:code:
|
# ¿ Apr 14, 2010 21:18 |
|
ah, i think its screwing up because my values have % symbols, ill just parse those. duh :P
|
# ¿ Apr 14, 2010 21:41 |
|
I'm having some stupid problem where I installed psycopg2, it said I need mx.datetime which I thought I had, so I re-installed that and now python can't see the module psycopg2 and won't import it. Other modules in my python2.6 folder import, what could cause this? edit: pythonpaths are correct, module is where all the others are LuckySevens fucked around with this message at 00:11 on May 4, 2010 |
# ¿ May 3, 2010 23:54 |
|
Yeah I did that and now it works. Why I don't know
|
# ¿ May 4, 2010 01:00 |
|
uh, don't you have to call a method in Round(), with P1Round() instead of P1Round? edit: you're not assigning the values properly in Round() at all, how does it know what P1Action is?
|
# ¿ Jun 18, 2010 23:53 |
|
systran posted:Thanks guys.. I tried everything you were saying and it still wasn't working, then I noticed my attempt to execute "Round" was written as "Round" instead of "Round()" You're trying to return a value I presume, but that's not what's happening here: code:
|
# ¿ Jun 19, 2010 03:43 |
|
Dicionaries are just lists that are not ordered and accessible by a key, ala { key : value }. Just play with them, they're fairly simple to use and you can do some python tricks to extract the data into lists or get values using a string name etc etc.
|
# ¿ Jun 30, 2010 20:35 |
|
haha I never thought of that
|
# ¿ Jul 9, 2010 21:29 |
|
FredMSloniker posted:I just decided to take a look at this thread because I'm pondering learning a programming language besides BASIC and writing a game with it. However, the OP hasn't been updated since April 2010, and the guy who started the thread hasn't been around September 2010. Anyone willing to volunteer to start a new thread so we can get an up-to-date OP? What exactly needs to be updated? Looks like everything it needs is there.
|
# ¿ Aug 18, 2011 05:31 |
|
FredMSloniker posted:I think not posting since September 29, 2010 constitutes a bit more than 'not posting a lot'. Even if nothing in the OP needs to be changed (and there is at least one change that even my newbie eyes can see: Python's now on versions 2.7 and 3.2), it'd be good to have it in the hands of someone who can make any necessary changes. Programming languages and resources don't change radically, by design. They don't want to break methods/compatibility concerns without fair warning. They try to remain as constant as they can, with meaningful changes taking many years to come through. If you're looking for the most 'up to date' resources, they're all their in the OP; there's nothing that needs changing. The best things for a newbie are all there, download python and start working through it. Even if you looked at a python thread OP from 4-5 years ago, it would still be useful. If you wanted more guides or something, well, us programmers have a phrase: DRY. Don't Repeat Yourself. All the best stuff is in the OP and that's not going to change.
|
# ¿ Aug 18, 2011 23:39 |
|
I stumbled onto m0nk3yz homepage, and lost 3 hours of my life reading his python good to great collection. Exactly the types of topics I was looking to take my python knowledge to the next level.
|
# ¿ Aug 19, 2011 07:30 |
|
|
# ¿ Apr 28, 2024 08:07 |
|
tef posted:Cool links Really good stuff, the sort was particular interesting, I like the way all the considerations are framed, in a 'see: its not so complicated when we break down the problem into smaller, logically separated chunks' kind of way, enlightening to see the thinking itself.
|
# ¿ Aug 19, 2011 11:24 |