|
MeramJert posted:So even though I posted in this tread about getting into stackless months ago, I got busy and am now trying to get back into it. What I have is a simple program to generate a sine wave in an array and send it through an audio stream to the sound card without the intermediate step of writing a wave file. What I want is a way to play two different waves concurrently. Why are you trying to write two arrays to it? What you want to be doing is adding the two arrays together element-wise and writing the result to audio out. Check this out, it adds two sine waves to make DTMF tones and outputs it using OSSaudiodev code:
|
# ? Feb 5, 2009 11:18 |
|
|
# ? May 14, 2024 20:02 |
|
I am looking for a Python module that will allow me to generate 3D graphics but that allows a great deal of flexibility (more than visual seems to allow). Basically what I want to do is be able to display an image or any other data in 3D space and allow the user to interact with it (rotation etc.) Any suggestions would be appreciated.
|
# ? Feb 5, 2009 22:17 |
|
Modern Pragmatist posted:I am looking for a Python module that will allow me to generate 3D graphics but that allows a great deal of flexibility (more than visual seems to allow). pygame or pyglet, pygame is compiled mostly in C, pyglet is pure python.
|
# ? Feb 5, 2009 22:26 |
|
I'm relatively new to python (and programming in general) and find myself looking for something a tiny bit more complex than IDLE. When I peruse the list of all the editing options out there the features and differences seam daunting. All I'm looking for is basically IDLE but with tabs for multiple files, and a horizontal scroll bar at the bottom. Any suggestions?
|
# ? Feb 6, 2009 03:11 |
|
Modern Pragmatist posted:I am looking for a Python module that will allow me to generate 3D graphics but that allows a great deal of flexibility (more than visual seems to allow). Check out the pyopengl module if you know opengl. Pygame and pyglet can interoperate with it fairly easily. tripwire fucked around with this message at 13:34 on Feb 6, 2009 |
# ? Feb 6, 2009 05:19 |
|
MeramJert posted:
Tripwire addressed the correct way to handle this from a sound perspective, but from a Stackless perspective, there's no reason your code should run concurrently. Remember that Stackless is cooperative multitasking, so in order for one tasklet to continue execution, another must give it up, either by sleeping (and letting the scheduler move on to the next tasklet) or else by blocking on a channel. In your case, you have the Sine class send a single chunk of data over a channel to OutStream.listen, which spawns a tasklet of OutStream.play, which in turn uses a traditional blocking call (if I'm not mistaken) to write to the audio device. Once it's done, OutStream.play completes and only NOW does the Stackless scheduler kick in. And once it comes back around to the OutStream.listen that spawned the play tasklet, it'll block forever on its channel, since the sign only ever writes to that channel once. Try instead making Sine.send_array send chunks of the data interspersed with calls to stackless.schedule() to make sure other tasklets are getting scheduled. Basically, remember that control doesn't pass between tasklets unless you TELL it to (again, by blocking on a read to or write from a channel, sleeping, or calling stackless.schedule directly).
|
# ? Feb 6, 2009 07:03 |
|
Benji the Blade posted:Basically, remember that control doesn't pass between tasklets unless you TELL it to (again, by blocking on a read to or write from a channel, sleeping, or calling stackless.schedule directly). This is the zen of Stackless really. When I started using it I thought I understood this, and knew what I was doing, until I found my program deadlocked (or so I thought). It quickly dawned on me (like a ton of bricks) that there is only explicit yielding and never preemptive yielding (unless you make it so). In that moment I became Stackless enlightened.
|
# ? Feb 6, 2009 15:27 |
|
wrok posted:This is the zen of Stackless really. When I started using it I thought I understood this, and knew what I was doing, until I found my program deadlocked (or so I thought). It quickly dawned on me (like a ton of bricks) that there is only explicit yielding and never preemptive yielding (unless you make it so). In that moment I became Stackless enlightened. Sort of like me with Twisted earlier this week "oh, you have to schedule deferreds". Still:
|
# ? Feb 6, 2009 16:09 |
|
Whatever happened to freeze.py? I see references to it in the documentation, and it supposedly ships with Python, but it's neither on my Mac or on my CentOS test box. I need to freeze something because I wrote a script that depends on 2.6 but we don't want to install 2.6 on the machine it's going to live on. I tried bbfeeze and cxfreeze from PyPI but they produce executables that don't have references to sqlite3.
|
# ? Feb 6, 2009 20:32 |
|
Sock on a Fish posted:Whatever happened to freeze.py? I see references to it in the documentation, and it supposedly ships with Python, but it's neither on my Mac or on my CentOS test box. I need to freeze something because I wrote a script that depends on 2.6 but we don't want to install 2.6 on the machine it's going to live on. I'm not familiar with freeze, but py2app and pyinstaller/etc might work better for you
|
# ? Feb 6, 2009 20:56 |
|
m0nk3yz posted:I'm not familiar with freeze, but py2app and pyinstaller/etc might work better for you Looks like pyinstaller only works up to 2.4 and py2app makes Mac binaries. I need a Linux binary.
|
# ? Feb 6, 2009 21:21 |
|
Sock on a Fish posted:Looks like pyinstaller only works up to 2.4 and py2app makes Mac binaries. I need a Linux binary. What about http://cx-freeze.sourceforge.net/, freeze isn't installed with python - it's in the python svn repo in the tools directory. http://effbot.org/pyfaq/how-can-i-create-a-stand-alone-binary-from-a-python-script.htm has more information
|
# ? Feb 6, 2009 23:50 |
|
Benji the Blade posted:Tripwire addressed the correct way to handle this from a sound perspective, but from a Stackless perspective, there's no reason your code should run concurrently. Remember that Stackless is cooperative multitasking, so in order for one tasklet to continue execution, another must give it up, either by sleeping (and letting the scheduler move on to the next tasklet) or else by blocking on a channel. Thanks a lot! I've already written something like what Tripwire has, but you guessed right and I was looking to do it from a stackless perspective (since the point of this project is to play around with stackless). I'll play around with this.
|
# ? Feb 7, 2009 04:14 |
|
Sock on a Fish posted:Looks like pyinstaller only works up to 2.4 and py2app makes Mac binaries. I need a Linux binary. Do a svn checkout of the PyInstaller trunk, I'm pretty sure it supports both Linux and Python 2.6.
|
# ? Feb 8, 2009 20:41 |
|
I am writing a python script for x-chat, and I have come to a problem I can't for the life of me figure out.code:
Example, if the text file is code:
|
# ? Feb 8, 2009 22:04 |
|
file.readlines leaves line endings intact. Your last line may not have a line ending on leading to it magically working only on that line.
|
# ? Feb 8, 2009 22:22 |
|
I figured it had something to do with the text's formatting. How would I make this work then? I only started learning Python today, so I really don't know what I'm doing. It took me 2 hours to write what I have there and another 3 trying to fix this problem.
|
# ? Feb 8, 2009 22:29 |
|
Why are you iterating with a while and two counters of some sort? Also, you don't have to initialize banwords to a list because it becomes a generator in the next line either way. I'd docode:
code:
hey mom its 420 fucked around with this message at 22:37 on Feb 8, 2009 |
# ? Feb 8, 2009 22:34 |
|
Thanks for the help, that worked. Sorry about the messy code, it's been a while since i've scripted in anything.
|
# ? Feb 8, 2009 22:42 |
|
A few odd questions starting from OSX and stretching beyond: * What state is PyCocoa / Cocoa-Python in? I was thinking about a new project, went to XCode and created a Python application. Normally the boilerplate generated by XCode results in a minimal / trivial application that works (if it does nothing), but this errored out immediately with "uncaught exception". I went to the PyCocoa pages, and they're in a state of long neglect, with apologies for no progress. Is there another up-to-date resource for the Cocoa-Python bridge? * Which leads to another question: PyCocoa obviously calls Cocoa and Foundation libraries from within Python. But I'd like to do that from within a commandline app. (Want to use PDFKit.) Buts there's a dearth of examples. Any pointers? * Finally, what are people using for code documentation? I've used epydoc for a long time, but Sphinx is popular lately, although it seemed to me to be a documentation tool, more than a code documentation tool.
|
# ? Feb 9, 2009 21:05 |
|
outlier posted:A few odd questions starting from OSX and stretching beyond: re pycocoa, you want to look up pyobjc, which ships with leopard and is actually nice: http://lethain.com/entry/2008/aug/22/an-epic-introduction-to-pyobjc-and-cocoa/ http://pyobjc.sourceforge.net/NEWS-2.0.html The website is a wreck. Also, for API docs, I still use epydoc, sphinx is more for prose and less API
|
# ? Feb 9, 2009 21:27 |
|
Note that the developer tools also ship with PyObjC examples. See /Developer/Examples/Python
|
# ? Feb 10, 2009 05:52 |
|
I'm taking a Python class, and one of our assignments is to turn a list into a dictionary. We didn't think this would be hard, but then we discovered said task is listed absolutely nowhere in the book or in the lecture (but that's beside the point). Anyway, after some hard work, I basically figured it out. But here is the problem: whenever you add a new key-value pair to the dictionary, it overwrites the old one. The dictionary we are making has to assign multiple words to letter, i.e. "a" : ["apple", "air"]. So my code will add apple to the dictionary, which is great, but then overwrite it with with air. So I end up with "a" : ["air"]. Note that we've mostly learned simple poo poo, so while I'm sure there is a straightforward function for this (my brother found some poo poo with setdefault and append, but neither of us have any what is going on his program), I can't really use it. Here is my code (for the purpose of not shattering tables, I've made wlist two lines; it's not that way in the code):code:
|
# ? Feb 10, 2009 06:18 |
|
code:
|
# ? Feb 10, 2009 06:25 |
|
tef posted:
Hell yes. See, your code is much better because it's not based on some godawful example from a textbook that doesn't even cover the topic. I thank you, fine sir, and I continue to find it hilarious (well, it's funny now, it was infuriating before), that the only way to solve this problem is to use a function (.append) that we were not taught. Note: I will probably be in here later tonight and tomorrow, because there are two more problems yet to complete and we were taught none of them. wicka fucked around with this message at 06:39 on Feb 10, 2009 |
# ? Feb 10, 2009 06:35 |
|
OK, gently caress it, here's the next one. We need to take a list of numbers and sort them using an insertion sorting algorithm. I kid you not, she told us to read the Wikipedia article and figure it out. This is the fourth loving week. So, basically, if anyone can write an insertion sorting algorithm in Python, that be fantastic.
|
# ? Feb 10, 2009 06:45 |
|
To help your brother out, here's the dict.setdefault function:code:
code:
edit: If you weren't taught list.append(), maybe you've seen the + operator when used with lists which does the same thing as list.extend(): code:
yippee cahier fucked around with this message at 06:57 on Feb 10, 2009 |
# ? Feb 10, 2009 06:52 |
|
wicka posted:OK, gently caress it, here's the next one. We need to take a list of numbers and sort them using an insertion sorting algorithm. I kid you not, she told us to read the Wikipedia article and figure it out. This is the fourth loving week. So, basically, if anyone can write an insertion sorting algorithm in Python, that be fantastic. Have you tried reading the wikipedia article? Use their example of sorting a deck of cards. Get a deck of cards and puzzle out the algorithm. Think about what you're iterating over as you sort the cards. Take a look at the .pop(index) and .insert(index, item) functions. Do your own homework.
|
# ? Feb 10, 2009 07:41 |
|
sund posted:edit: I had an inkling I could so something with the + operator, but I tried one way and it didn't work so I tried other routes. Also, the section of my textbook that covers this literally says "if you add a term to a key that already exists, the old term is overwritten," but offers no way to get around this, or even the suggestion that it is possible. sund posted:Have you tried reading the wikipedia article? Use their example of sorting a deck of cards. Get a deck of cards and puzzle out the algorithm. Think about what you're iterating over as you sort the cards. Take a look at the .pop(index) and .insert(index, item) functions. Do your own homework. I'd love to. I did the other three chapters just by figuring it out on my own. The problem is that they've started giving us problems that aren't even remotely covered in the material. I know you are assuming that I just don't want to do my own work, which is understandable, but it's really quite ridiculous the poo poo they are giving us. If you can think of it like a math class you'd understand how frustrated I am; you wouldn't expect your fourth week in a stats class to be covering hypothesis testing. wicka fucked around with this message at 07:46 on Feb 10, 2009 |
# ? Feb 10, 2009 07:42 |
|
wicka posted:Hell yes. See, your code is much better because it's not based on some godawful example from a textbook that doesn't even cover the topic. I thank you, fine sir, and I continue to find it hilarious (well, it's funny now, it was infuriating before), that the only way to solve this problem is to use a function (.append) that we were not taught. You are the reason I read through a list of resumes looking for the people who taught themselves instead of paying an institution for a piece of paper that certifies, correctly or not, that they are not useless.
|
# ? Feb 10, 2009 07:44 |
|
A A 2 3 5 8 K posted:You are the reason I read through a list of resumes looking for the people who taught themselves instead of paying an institution for a piece of paper that certifies, correctly or not, that they are not useless. Thanks, I appreciate your valuable assertion that I should not expect the motherfuckers I pay thousands of dollars to actually teach me anything. By the way, there were three problems that we weren't taught, I figured out two of them myself. So gently caress you.
|
# ? Feb 10, 2009 07:47 |
|
wicka posted:Thanks, I appreciate your valuable assertion that I should not expect the motherfuckers I pay thousands of dollars to actually teach me anything. So you believe your role as a student is to know only the material that you've been handheld through, and you're "infuriated" by the notion that you were expected to do a small amount of original research instead of regurgitating only that subset of all knowledge that fits in the first four weeks of your syllabus. For your own good, you should know it's going to get harder and the problems you'll need to solve will involve increasingly less of what you've been explicitly taught and more research and creativity.
|
# ? Feb 10, 2009 07:58 |
|
A A 2 3 5 8 K posted:So you believe your role as a student is to know only the material that you've been handheld through, and you're "infuriated" by the notion that you were expected to do a small amount of original research instead of regurgitating only that subset of all knowledge that fits in the first four weeks of your syllabus. The format of our class is basically: read this chapter -> write these programs. The point is to apply the knowledge you've learned, not spend an hour Googling poo poo you don't understand. If you read a chapter of a history textbook and have the answer the questions at the end, the answers can be gleaned from that chapter. They aren't going to talk about Fort Sumter and then ask you when Sherman began his march to the sea; that would be absurd. My problem here is not that I was required to do research to finish a program, but rather that I'm not supposed to have to (except for the case of the insertion sorting, obviously). I have no problem with using .append, it's just that I'm going to get my programs graded and it's going say "good job, except where did you learn .append, you are supposed to do it x way." I've done it, but I haven't done it "the right way," because the right way hasn't been taught. You have to understand, at this stage we aren't just learning how to write a specific program, we're learning how to write a program using what we've learned from the chapter. Early on, when we were learning loops, there were problems that were made much more complicated because you had to use certain kinds of loops. People would search up answers, and while they were much simpler (oh and yaaaay they were creative and did it themselves!) it's still not right because they didn't learn poo poo about loops in the process. You know what? It's a lot like the professor is giving out assignments from the last professor, but using her own slides, so there is a disconnect between the two. wicka fucked around with this message at 08:23 on Feb 10, 2009 |
# ? Feb 10, 2009 08:20 |
|
wicka posted:The format of our class is basically: read this chapter -> write these programs. Why do you pay for both the book and the class if you only need the book? quote:My problem here is not that I was required to do research to finish a program, but rather that I'm not supposed to have to (except for the case of the insertion sorting, obviously). I have no problem with using .append, it's just that I'm going to get my programs graded and it's going say "good job, except where did you learn .append, you are supposed to do it x way." I've done it, but I haven't done it "the right way," because the right way hasn't been taught. In the unlikely case you're right and the homework was impossible given the content of the chapter, you're off the hook on that constraint and free to figure it out yourself instead on relying on others. Which is a much greater approximation of software development, or really, any career. quote:You know what? It's a lot like the professor is giving out assignments from the last professor, but using her own slides, so there is a disconnect between the two. What school do you go to and what's the email address of your professor? I'd be interested to hear her side of why independent study is forbidden.
|
# ? Feb 10, 2009 09:06 |
|
I am a complete noob to Python, but I'm about to start learning it.. I thought my first project would be a GeoIP lookup using the MaxMind GeoIP Organization db, but I cannot figure out how to install the module on winxp Could anyone point me in the right direction on how to do this, since the documentation doesn't say anything about how to do it.
|
# ? Feb 10, 2009 14:37 |
|
A A 2 3 5 8 K posted:Why do you pay for both the book and the class if you only need the book? Unfortunately when you are signing up for a class there isn't a notice saying "warning: lecture is useless." A A 2 3 5 8 K posted:What school do you go to and what's the email address of your professor? I'd be interested to hear her side of why independent study is forbidden. It's not forbidden, it's just pointless because you're supposed to solve problems based on what you've been given. You're not just learning Python, you're learning a class about Python. I could look up all sorts of other ways to finish my programs, but that's not going to help me at all on the midterm.
|
# ? Feb 10, 2009 15:28 |
|
wicka posted:It's not forbidden, it's just pointless because you're supposed to solve problems based on what you've been given. You're not just learning Python, you're learning a class about Python. I could look up all sorts of other ways to finish my programs, but that's not going to help me at all on the midterm. Based on your statements, you are ONLY trying to learn the CLASS about Python. You have to think outside of the box for Python and programming in general. You can look up how to solve your own problems by googling around for hours (that's part of the learning process) and INCORPORATE what you learned in class and not rely solely upon everything that you have been spoon-fed. If you want to come out with both a good grade in the class and a half-rear end understanding of python, I recommend you grow some balls and learn to figure out the tough problems on your own. I would be really interested to know: a) the school you go to b) what year you are EDIT: If you look back at the responses you got to your questions. Nothing was "out of the scope" of your class. You just needed to spend more time thinking through it. Modern Pragmatist fucked around with this message at 16:16 on Feb 10, 2009 |
# ? Feb 10, 2009 16:13 |
|
But us doing your homework will help you on the midterm?
|
# ? Feb 10, 2009 16:18 |
|
Of course I'm trying to learn the class. Learning Python isn't my problem, learning the class is. Like I said, I can easily find lots of ways to write the assigned programs, but that doesn't help me one bit in the class. What I don't think you guys understand is this: we're not trying to write the best program, we're trying to write a program using a specific technique so we understand that technique well. You're not always graded on whether or not you solved the problem, but how you solved the problem. Like that insertion sort algorithm (which I did, by the way); the point of that program is to sort a list. So, I COULD just use the sort function, and it'd be a two line program and the list would be sorted. But I wouldn't get any points because I learned nothing about insertion sorting.Lord Uffenham posted:But us doing your homework will help you on the midterm? Of course it would, because then I would actually know how to do it. I'm not just copying and pasting poo poo here, if someone gives me code I can figure out how it works. vvv Thank christ. wicka fucked around with this message at 17:14 on Feb 10, 2009 |
# ? Feb 10, 2009 16:20 |
|
|
# ? May 14, 2024 20:02 |
|
wicka posted:Of course I'm trying to learn the class. Learning Python isn't my problem, learning the class is. Like I said, I can easily find lots of ways to write the assigned programs, but that doesn't help me one bit in the class. What I don't think you guys understand is this: we're not trying to write the best program, we're trying to write a program using a specific technique so we understand that technique well. You're not always graded on whether or not you solved the problem, but how you solved the problem. Like that insertion sort algorithm (which I did, by the way); the point of that program is to sort a list. So, I COULD just use the sort function, and it'd be a two line program and the list would be sorted. But I wouldn't get any points because I learned nothing about insertion sorting. I understand this pretty well. You're expected to use a method they taught you in class to solve the problem.
|
# ? Feb 10, 2009 16:37 |