tripwire posted:You too huh? Using pyopengl? Right on.
|
|
# ? Feb 21, 2009 05:19 |
|
|
# ? May 14, 2024 00:05 |
|
code:
I dunno I'm just really happy with this language's accessibility so far and I wanted to say so. I feel like I'll be able to do things of substance towards my ultimate goal of making a roguelike within a few short weeks.
|
# ? Feb 23, 2009 08:55 |
|
fnordcircle posted:
Beware the blub paradox. http://www.paulgraham.com/avg.html
|
# ? Feb 23, 2009 13:54 |
|
fnordcircle posted:I'm psyched that after just a couple hours I feel like I'm getting a grasp of this language that quickly despite never having come close to mastering any of the other languages I've toyed around with (C/C++, Perl, VB and Java.) That's Python for you. I went from "Python sounds like a cool language, I should check it out" to "I never want to write code in any other language ever again" over the span of days (if not hours). It really does just 'click' unlike a lot of other languages. m0nk3yz posted:Beware the blub paradox. http://www.paulgraham.com/avg.html Very true. I'm still honeymooning with Python (and work 45 hours a week with not-Python) -- so I've consciously let myself put on the Blub blinders and get a little carried away, at least for the time being. wrok fucked around with this message at 14:11 on Feb 23, 2009 |
# ? Feb 23, 2009 14:07 |
|
wrok posted:That's Python for you. I went from "Python sounds like a cool language, I should check it out" to "I never want to write code in any other language ever again" over the span of days (if not hours). It really does just 'click' unlike a lot of other languages. My background is primarily as a test-engineer, some scripting in various languages but not a lot of coding - about 7 years ago, I had a task which called for me to start writing a fair amount of code. I ended up picking up python as it was approachable, and let me simply get a lot of things done. I had exposure to Java and C prior - but not enough to be competent, after I got started with python, I ended up writing an amazing amount of code in it, and really picked up a passion for coding. I've spent about a year doing Java coding since then (off and on) and I've been doing some C work as well, but it's hard - Python fundamentally spoiled my brain. Everything from the syntax, to the language constructs itself and the standard library has simply sucked me in. I miss things that are python givens.
|
# ? Feb 23, 2009 15:02 |
|
fnordcircle posted:
You think that's cool? code:
|
# ? Feb 23, 2009 16:00 |
|
Lord Uffenham posted:You think that's cool? I was huffing paint this morning code:
|
# ? Feb 23, 2009 16:06 |
|
^^^^ LORD UFFENHAM fnordcircle posted:
Maybe I'm missing something, since nobody else corrected you on this, but you don't need to do that i=i+1 there. Python for loops iterate over some sort of collection, and thus rarely need any sort of counter variable. In fact, Python strings are themselves iterable objects (returning single-character strings -- there's no "char" type), so your code can be simply rewritten as: code:
|
# ? Feb 23, 2009 16:09 |
|
I was code:
code:
wrok fucked around with this message at 16:35 on Feb 23, 2009 |
# ? Feb 23, 2009 16:30 |
|
wrok posted:I was It's sadistic code golf.
|
# ? Feb 23, 2009 16:47 |
|
wrok posted:
3.0 snob... 2.6 fo lyfe This is hysterical code though.. Reminded me about a turned down consulting gig back in my PHP days where there were "stored procedures" of code that were stored as text in a DB which was called and eval()'d. I couldn't find anywhere in the code where the stored data ("function") was altered.. The originally programmer just used the DB to store code as opposed to just creating a new file. It was more than I wanted to try to peel apart for what they were willing to spend.
|
# ? Feb 23, 2009 19:06 |
|
ATLbeer posted:3.0 snob... 2.6 fo lyfe Reminds me of another weird urge I had the other day; given stackless tasklets are picklable (as well as the channel), you could serialize them and put them into a database, and in theory, a SQL query of the objects in the database could actually dictate the "program structure". You just need an ORM that auto-depickles the objects and adds them to the scheduler. Store your channels in another table, and select those with the query too. Yeah, no.
|
# ? Feb 23, 2009 19:10 |
|
bitprophet posted:Maybe I'm missing something, since nobody else corrected you on this, but you don't need to do that i=i+1 there. Python for loops iterate over some sort of collection, and thus rarely need any sort of counter variable. Yeah I'm sure you're not missing anything, I'm ridiculously new to python, maybe 4 hours in at this point, I was just proud of myself for figuring out a way to access a string's elements without knowing the length of the string beforehand. I had no doubts there was a simpler, more elegant solution. Good to know about the iteration thing, though. Thanks.
|
# ? Feb 23, 2009 20:11 |
|
m0nk3yz posted:Reminds me of another weird urge I had the other day; given stackless tasklets are picklable (as well as the channel), you could serialize them and put them into a database, and in theory, a SQL query of the objects in the database could actually dictate the "program structure". You just need an ORM that auto-depickles the objects and adds them to the scheduler. Store your channels in another table, and select those with the query too. Isn't that part of the seaside framework, it pickles poo poo, stores it in the session or something like that, maybe I need to stop reading reddit while tired.
|
# ? Feb 23, 2009 21:40 |
|
m0nk3yz posted:Reminds me of another weird urge I had the other day; given stackless tasklets are picklable (as well as the channel), you could serialize them and put them into a database, and in theory, a SQL query of the objects in the database could actually dictate the "program structure". You just need an ORM that auto-depickles the objects and adds them to the scheduler. Store your channels in another table, and select those with the query too. I had a similar thought a while ago (and I wasn't the first one, there are modules out there that people have written already for it) to pickle python functions and send them over the wire with parameters to "workers" to have a distributed work farm in processing large amounts of information. I don't recall what the modules that actually did it were called as my need for such a system disappeared. But, you can do all sorts of fun things with that type of "meta" Python
|
# ? Feb 23, 2009 22:33 |
|
ATLbeer posted:I had a similar thought a while ago (and I wasn't the first one, there are modules out there that people have written already for it) to pickle python functions and send them over the wire with parameters to "workers" to have a distributed work farm in processing large amounts of information. I don't recall what the modules that actually did it were called as my need for such a system disappeared. But, you can do all sorts of fun things with that type of "meta" Python Oh, that's common/widespread. That's essentially RPC of a sort. As long as you can pickle it (and you could even pickle threads + threadpools) you can send them over the wire for farming out to a group of boxes. My particular insanity was making something that let you construct an application from a series of SQL queries. I call it WTF driven development, or SOLIDPOOP. PS: Multiprocessing can be used to farm out jobs m0nk3yz fucked around with this message at 02:50 on Feb 24, 2009 |
# ? Feb 23, 2009 22:43 |
|
ATLbeer posted:I had a similar thought a while ago (and I wasn't the first one, there are modules out there that people have written already for it) to pickle python functions and send them over the wire with parameters to "workers" to have a distributed work farm in processing large amounts of information. http://discoproject.org/ ? quote:Disco is an open-source implementation of the Map-Reduce framework for distributed computing. As the original framework, Disco supports parallel computations over large data sets on unreliable cluster of computers.
|
# ? Feb 24, 2009 02:24 |
|
Ok, I'm making GBS threads bricks. I am making a site with Django and I have to present data according to the user's timezone. Basically, what I need is an easy way to convert a time between a non UTC timezone and a user's timezone, and I need it to compensate for daylight saving, if applicable. I know it doesn't sound that hard, but there are several ways to do it. This is my first time using timezones in Python. What would be the best way to go about it so that I don't shoot myself in the foot? The way I see it, my options are: * Use the pytz module (looks promising) * Use the built in time module (I have a feeling I'll run into problems with this one). * Keep python naive about the timezone and use timedeltas to calculate localised time (might be complex with the DST). Thanks in advance.
|
# ? Feb 24, 2009 17:58 |
|
http://code.google.com/p/django-timezones/ may be just what you're looking for.
|
# ? Feb 24, 2009 18:07 |
|
That's just a django wrapper around pytz. pytz is most certainly what you should be using, though. It works in conjunction with the stdlib datetime module. There's really no reason to be using the time module for this; it would be a lot of extra work that would just be duplicating what's already been done in datetime and pytz. Doing it all naïve is even stupider. pytz is rather easy to use as long as you read the documentation.
|
# ? Feb 24, 2009 20:31 |
|
Lord Uffenham posted:You think that's cool? Why does this not work when I type it in? 2.6: code:
Or did I miss some kind of joke, with a whoosh over my head? Edit: monk3yz, that article about Lisp was really interesting. Kire fucked around with this message at 23:07 on Feb 24, 2009 |
# ? Feb 24, 2009 22:57 |
|
Are you sure that's the exact code? Thiscode:
|
# ? Feb 24, 2009 23:11 |
|
Kire posted:Why does this not work when I type it in? 2.6: code:
No Safe Word posted:I'm guessing he has a space before "for" and it's giving an indentation error. That would be a IndentationError: unexpected indent VVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVV tripwire posted:It could also be mixing tabs and spaces. On a single line inside the for loop? deimos fucked around with this message at 23:56 on Feb 24, 2009 |
# ? Feb 24, 2009 23:53 |
|
I'm guessing he has a space before "for" and it's giving an indentation error.
|
# ? Feb 24, 2009 23:54 |
|
It could also be mixing tabs and spaces.
|
# ? Feb 24, 2009 23:55 |
|
Maybe he's running it with the perl command, haha.
|
# ? Feb 25, 2009 00:00 |
|
Habnabit posted:That's just a django wrapper around pytz. pytz is most certainly what you should be using, though. It works in conjunction with the stdlib datetime module. There's really no reason to be using the time module for this; it would be a lot of extra work that would just be duplicating what's already been done in datetime and pytz. Doing it all naïve is even stupider. pytz is rather easy to use as long as you read the documentation. Cheers, I'll go with pytz and sacrifice a lamb...
|
# ? Feb 25, 2009 01:00 |
|
So I trying to write a short script to determine if a triangle is a right triangle given the three vertices. First I have to find the distances. Done: code:
Possibly using < or > but I think that would be too much of a hassle.
|
# ? Feb 25, 2009 04:37 |
|
darknife posted:So I trying to write a short script to determine if a triangle is a right triangle given the three vertices. code:
|
# ? Feb 25, 2009 04:54 |
|
wrok posted:
Works! Thanks! code:
darknife fucked around with this message at 05:23 on Feb 25, 2009 |
# ? Feb 25, 2009 05:12 |
|
I have a simple list that has pairs of directory names and file names. So for example: ['/etc/apache2/', 'apache2.conf'] or something like that, over and over. I want to perform an action on each item in the list, but only if the first list[0] is unique. If a directory is in the list more than once, I don't want to muck with it. Googling about I have figured out I may want to do something with sets? I don't quite understand what a set is. Lists have always worked for me. As a side note, there is something wrong with my browser or the python web site. The documentation pages are using some horrendous font. I had to tell firefox to not let web pages define their own fonts. Is this just me? edit: I am trying to do something like: code:
other people fucked around with this message at 06:07 on Feb 25, 2009 |
# ? Feb 25, 2009 05:44 |
|
Kaluza-Klein posted:edit: I am trying to do something like: Haven't tried this, but I think it would work... code:
|
# ? Feb 25, 2009 06:11 |
|
such a nice boy posted:Haven't tried this, but I think it would work... Ha, I just came here to edit my post with this: code:
|
# ? Feb 25, 2009 06:15 |
|
Kaluza-Klein posted:Googling about I have figured out I may want to do something with sets? I don't quite understand what a set is. Lists have always worked for me. Set is an unordered collection of unique objects. There is no particular order for the objects in the set and all the members of the set have to be different from each other. It's quite handy sometimes. uncleTomOfFinland fucked around with this message at 10:07 on Feb 25, 2009 |
# ? Feb 25, 2009 10:05 |
|
Kaluza-Klein posted:Ha, I just came here to edit my post with this: For what it's worth, here's what I came up with: code:
Mostly, I wanted to introduce the idea of using "sorted" and "groupby" to solve your problem. In this case, they're a lot like using the UNIX utils, "sort | uniq" only instead of just deleting multiples, groupby gives you all the values in the list where the key function (in this case "lambda item: item[0]") evaluates to be equal.
|
# ? Feb 25, 2009 17:31 |
|
A question about IDLE: When I type something in the shell and hit enter, is there a conveienent way to re-enter the same thing? Like how at the DOS prompt the user can push up-arrow to get back the last thing entered. I hate typing in a few lines with a small error, and having to cut-and-paste to get it all back to edit it.
|
# ? Feb 26, 2009 17:02 |
|
Kire posted:A question about IDLE: When I type something in the shell and hit enter, is there a conveienent way to re-enter the same thing? Like how at the DOS prompt the user can push up-arrow to get back the last thing entered. By default Alt-P goes back in history and Alt-N goes forward. You can change that in the options.
|
# ? Feb 26, 2009 17:43 |
|
Okay this may be a stupid question but I don't know the correct terminology to be able to google it. I have a loop where I store something in a variable, and append that variable to a list. The problem is that every time I change this variable in the loop, it changing all the values in the list ( since they were all assigned to the same variable at one point ) Is there a correct way to accomplish what I want to do?
|
# ? Feb 27, 2009 06:01 |
|
Python variables are references, not values. You want to copy the variable before adding it to the list in this instance. Can you post some code? Also: http://docs.python.org/library/copy.html Here is an example of references - both b and a refer to the *same* list. = does not copy the value. code:
code:
tef fucked around with this message at 06:10 on Feb 27, 2009 |
# ? Feb 27, 2009 06:07 |
|
|
# ? May 14, 2024 00:05 |
|
tef posted:Python variables are references, not values. You want to copy the variable before adding it to the list in this instance. Can you post some code? Sure. This isn't all of the code, but I'm certain it's the relevant part. code:
EDIT: I changed the following line code:
pankus fucked around with this message at 06:19 on Feb 27, 2009 |
# ? Feb 27, 2009 06:13 |