|
shrughes posted:I spent much of my former job doing exactly this. Lacking access to this, I'd just use IMAP, which I'm sure Python would have no trouble with.
|
# ? Sep 27, 2010 16:42 |
|
|
# ? May 8, 2024 17:20 |
|
Stabby McDamage posted:Lacking access to this, I'd just use IMAP, which I'm sure Python would have no trouble with. http://docs.python.org/library/imaplib.html
|
# ? Sep 27, 2010 17:33 |
|
I've been putting off learning web programming because it seemed like it was a completely different ballgame. I mean, I decided to learn Python a year or 18 months ago, and while Python is completely awesome, the general ideas weren't much different from when I did lots of QuickBasic programming back in the early 90's. My impression of web programming was that it was a lot different, and I didn't have a firm grasp on how all the pieces fit together. That coupled with the fact that I find any sort of HTML/CSS unfun, just put me off of the whole idea. Well yesterday, I took the plunge and installed Django and started working through the tutorials. I should have done this ages ago! As you can tell, I can't compare it to any other web frameworks, but man...Django is sweet stuff. Just though I'd throw that out there for any other newbish programmers.
|
# ? Sep 27, 2010 21:11 |
|
I've been working with Python for the first time today, and already it feels alot easier than C++ was when I tried starting out with that. Im having an issue though, not sure if its tied to the Python program. Say write the print("Hello, World!") line in IDLE and save it as hello.py The output is supposed to show up on a command line-like screen. Well, it does, but only for a quarter of a second, then it dissapears. I have to relaunch the hello.py program many times just to make out what I'm seeing (obviously "Hello World", but in later lessons its not so easy to see everything. Ideas?
|
# ? Sep 28, 2010 02:31 |
|
Avocadoes posted:I've been working with Python for the first time today, and already it feels alot easier than C++ was when I tried starting out with that. Im having an issue though, not sure if its tied to the Python program. Just hit F5 in IDLE, and it should run in the controlled environment Python shell. Failing that, you could tack a raw_input() onto the end of your code and it'll wait until you hit Enter before it terminates the program. Edit for more detail: When a Python program is run in a standard console, the console closes as soon as the program is finished. So with basic programs, it'll quickly compute everything, and the program will be finished, closing the console window. So you want to make it wait on something, ideally: Human input. So that you, the user, control when it finishes, and thus control when the console window closes. Easiest way to do this is to put the line "raw_input()" where you want it to wait. Jehde fucked around with this message at 03:16 on Sep 28, 2010 |
# ? Sep 28, 2010 03:09 |
|
I believe there's an option somewhere that is basically 'close program when finished'. Uncheck that. Alternatively, add in a user input segment, without actually saving what is inputted. Don't remember off the top of my head, mostly because I'm just starting off myself.
|
# ? Sep 28, 2010 03:10 |
|
I keep getting an invalid syntax error when plugging in like this print("Hello, World!") raw_imput() Maybe I followed your directions wrong. I'm illiterate to python still. And Kgummy I remember seeing that SOMEWHERE. It escapes me where I could find it though.
|
# ? Sep 28, 2010 03:44 |
|
basically raw_input needs to be on the next line, it's a function of it's own.
|
# ? Sep 28, 2010 03:53 |
|
Avocadoes posted:I keep getting an invalid syntax error when plugging in like this
|
# ? Sep 28, 2010 03:54 |
|
m0nk3yz is probably too humble to say so, but in this year's PyCon call for proposals it lists him as co-chair. Congrats and good luck.
|
# ? Sep 28, 2010 16:14 |
|
Congrats, BPTSFL!* *Benevolent Python Thread Starter for Life
|
# ? Sep 28, 2010 21:58 |
|
Lurchington posted:m0nk3yz is probably too humble to say so, but in this year's PyCon call for proposals it lists him as co-chair. Congrats and good luck. You guys better submit kick rear end talk proposals.
|
# ? Sep 28, 2010 22:00 |
|
I've been learning python recently through trying to write some personal projects. I've tried to search for best practices, but I couldn't find much with respect to module layout. One thing I've noticed is that in a class-per-file model that I'm used to using seems a bit redundant. E.g., if I had a Bar class in the file /foo/bar.py, when using it, I would: from foo.bar import Bar Is this redundancy normal? Or are there different ways people tend to accomplish this? I guess I could have it all in foo.py, in which case I could: from foo import Bar Of course, as foo.py got too large, I'd probably want to split it up.
|
# ? Sep 30, 2010 00:24 |
|
Freakus posted:I've been learning python recently through trying to write some personal projects. I've tried to search for best practices, but I couldn't find much with respect to module layout. One thing I've noticed is that in a class-per-file model that I'm used to using seems a bit redundant. E.g., if I had a Bar class in the file /foo/bar.py, when using it, I would: Sometimes you might see an implementation in the __init__.py so that you can just do code:
|
# ? Sep 30, 2010 01:07 |
|
Lurchington posted:m0nk3yz is probably too humble to say so, but in this year's PyCon call for proposals it lists him as co-chair. Congrats and good luck. More like too tired and spinning in too many directions But yeah, what he said!
|
# ? Sep 30, 2010 02:57 |
|
I'm not sure if this is a short question or not... but here goes. I'm a physicist, and coding is generally something we do and not something that we're taught, so I'm hoping that someone with more knowledge of the tools available can tell me whether there's a better way to solve my problem. I have two sets of run numbers, and each run number comes with a list of event numbers. I want to check overlap between the two runs so that I don't look at the same event twice, but I want to look at every event at least once. For example RunStream1 Run 152000 has event numbers (1, 2, 3, 41, 45) Run 152234 has event numbers (1, 2, 14, 15, 20) ..... RunStream2 Run 152000 has event numbers (30, 31, 32, 34, 45) Run 156000 has event numbers (blah blah blah) ..... A single RunStream is guaranteed to not have run/event duplicates, but there is no such guarantee between runstreams; in this short example, run 152000 event 45 is in both sets. I have upwards of billions of events distributed cross hundreds of runs, so checking run/event overlap between the two runstreams becomes a pretty large task. I'm working on a server, not a supercomputer, so memory limitations are a concern. Right now for overlap checking I use a dictionary where the run numbers determine the keys and the value of each key is a set() filled with event numbers. I only fill the dictionary/sets when looking at RunStream1, and I only check for overlap when looking at RunStream2. Dictionaries and sets are both hash lists, so checking for membership is fast and easy, as is appending new runs and events. Is there a more effective way that might use less memory while maintaining at least the speed of a hash list?
|
# ? Sep 30, 2010 03:54 |
|
I'm quite the novice, and self-educated, so apologies if this is some blindingly simple error. That said...code:
code:
code:
code:
But the error message says "'NoneType' object has no attribute 'get_red'" and in that last code box, it's trying to "get_red" from my color_new object. So I guess lighten isn't returning a color-type object? Or am I completely on the wrong track? chinchilla fucked around with this message at 04:08 on Sep 30, 2010 |
# ? Sep 30, 2010 04:04 |
|
if/when you run out of memory - write your program to work out of core by operating on files instead of python data structures ie read the inputs and create/append to files called data/152/000.event where each file contains some lines like: 000 runstream1: 1 2 3 41 45 000 runstream2: 1 2 14 15 20 234 runstream1: 30 31 32 34 45 blah blah blah then, run your existing program over these subsets and write back out to these files with the reduced event numbers create a third program that reads these event files back and spits out the range you want
|
# ? Sep 30, 2010 04:18 |
|
chinchilla posted:8lor(col) [/code] media.lighten(color_old) changes the value of colour_old and returns None
|
# ? Sep 30, 2010 04:23 |
|
Right. I guess that would do it. Thanks!
|
# ? Sep 30, 2010 04:41 |
|
Freakus posted:I've been learning python recently through trying to write some personal projects. I've tried to search for best practices, but I couldn't find much with respect to module layout. One thing I've noticed is that in a class-per-file model that I'm used to using seems a bit redundant. E.g., if I had a Bar class in the file /foo/bar.py, when using it, I would: Nobody does class-per-file. This isn't java. Organize your classes into modules in a logical grouping. Like classes and functions go together.
|
# ? Sep 30, 2010 06:31 |
|
Thats one of the things I like about python. A folder is a package, a file is a module, and a class sits inside a module.
|
# ? Sep 30, 2010 16:26 |
|
Might be a really dumb question, is there anyway to build a python package from source, on windows when i don't have visual studio 2003? Or mingw? I have visual studio 2008, and its the only version i can get my hands on. I looked around online but couldn't find anything definate. Generally i like to just stick to the precompiled binaries to get around this headache, however i don't have that option for this library (http://effbot.org/media/downloads/ftpparse-1.1-20021124.zip). I can't get my hands on visual studio 2003. If i were to use mingw, would the egg be portable to another computer where mingw is not installed, or would i have to install mingw on that computer?
|
# ? Sep 30, 2010 18:12 |
|
You could use cygwin.
|
# ? Sep 30, 2010 18:16 |
|
So this is my first post in here so try to be gentle. Comp Sci major going into Java Development as a job (already have a job lined up). Most of the stuff I am used to is basic code monkey stuff, which is okay, but I am in a Python/Pylons dev class and have been asked to create my own personal "anything" as long as it uses Python. One of the things that came to my mind to create was a simple time killer (others are creating actual applications such as twitter updating from cmd, creating tables by grabbing data from websites [such as weather, allergens], etc) but I wanted to create something more of a casual thing. I had seen a website years ago where a guy created a website where a ball existed in the browser window and if the user moved the window in the OS, the ball reacted as if if the 2D plane had physics. Ergo, shaking the window thus shook the ball around and you could bounce it around. Could this be replicated in python? If not in browser, maybe a standalone application using a GUI such as tkinter? I kind of want to ask more advanced folks as yourself if this seems feasible as a beginner project or if it seems like too of an advanced application and I should aim lower. I should also add that the only python experience I have are creating simple applications that used basic arithmetic and other basic functions like sorting, etc...
|
# ? Sep 30, 2010 18:52 |
|
Habnabit posted:Nobody does class-per-file. This isn't java. I don't necessarily do class per file, but it seems like in most modules I write there tends to be 1 class that is essentially named after the module. Maybe I'm just not grouping my classes and functions by high enough level concepts.
|
# ? Sep 30, 2010 19:46 |
|
tripwire posted:You could use cygwin. Turns out setting up mingw for python is insanely painless now: http://www.develer.com/oss/GccWinBinaries
|
# ? Sep 30, 2010 20:17 |
|
notMordecai posted:So this is my first post in here so try to be gentle. Yes, that doesn't sound especially hard. It's pretty easy to get window coordinates and sizes in tkinter. Just start very simple and work your way up. Don't try to do the entire thing in one go. For example, first just render a window, then add a ball to the window, then make the ball move on its own, then figure out how to track the window position, and so on. None of this has anything to do with web development or browsers, though.
|
# ? Oct 1, 2010 07:51 |
This exercise takes a user-defined integer and prints it out in a "large ascii font", just wondering if someone could help out with the following: a) Any suggestions to improve the code - make it more "pythonic"? The last language I used was like, C, in 2007. b) Currently, each numeral displays on a new line, I'd like to get them all on the same line- any hints? code:
o.m. 94 fucked around with this message at 12:34 on Oct 1, 2010 |
|
# ? Oct 1, 2010 11:37 |
|
I haven't tested this, and I'm a novice myself, but it seems like you could do a dict like {('0':numbers[0]), ('1':numbers[1]), ('2':numbers[2])} etc then print the values using a generator function like print [value for key in dict]. I am on my way to work, was just thinking about it in the shower. Don't have time to test myself.
|
# ? Oct 1, 2010 12:45 |
RobotEmpire posted:I haven't tested this, and I'm a novice myself, but it seems like you could do a dict like That's basically what I'm doing without a dict. I think the idea is to render each element of each number in the string into a "line" variable, and then go through, and render the whole thing bit by bit like an old dot matrix printer.
|
|
# ? Oct 1, 2010 14:56 |
|
oiseaux morts 1994 posted:This exercise takes a user-defined integer and prints it out in a "large ascii font", just wondering if someone could help out with the following: Juse use print(j, end="") and then put a print outside the first loop.
|
# ? Oct 1, 2010 15:08 |
|
You could specify the digits much easier than that, without having to resort to converting them to an awkward list at the top.code:
|
# ? Oct 1, 2010 17:47 |
|
I'm starting from square one in Python and programming. Why is: print 'this word' valid in 2.7, but it's not in 3.1?
|
# ? Oct 1, 2010 17:53 |
|
king_kilr posted:Juse use print(j, end="") and then put a print outside the first loop. That would print all the characters for an input digit on one line, which wouldn't be very readable. Your end goal is to have something that accomplishes this: code:
|
# ? Oct 1, 2010 17:56 |
|
standardtoaster posted:I'm starting from square one in Python and programming. Because in python 3.0 print is now a function: print('this word') You can get the print function in 2.7 by doing from __future__ import print_function (which will also remove the print statement).
|
# ? Oct 1, 2010 17:58 |
|
As stated earlier, you need to iterate on lines before you iterate on the user's digits. There certainly a more pythonic way to do this, but I just did it explicitly with two loops:code:
EDIT: I had to use a comma instead of "as" in the except because I'm stuck on Python 2.5.
|
# ? Oct 1, 2010 18:00 |
Stabby McDamage posted:Also, you should probably use raw_input() instead of input(). The latter takes and evaluates python code, whereas the former just reads the string, which is what I assume you want. I'm using Python 3 - I thought input() was okay to use as raw_input() now?
|
|
# ? Oct 1, 2010 19:27 |
|
Stabby McDamage posted:As stated earlier, you need to iterate on lines before you iterate on the user's digits. There certainly a more pythonic way to do this, but I just did it explicitly with two loops: Haha derp, of course. Iterating over the height is way simpler and clearer than using zip. I like making things harder than they have to be apparently
|
# ? Oct 1, 2010 19:31 |
|
|
# ? May 8, 2024 17:20 |
|
oiseaux morts 1994 posted:I'm using Python 3 - I thought input() was okay to use as raw_input() now? Yes, it is. raw_input doesn't exist anymore in 3.x
|
# ? Oct 1, 2010 21:21 |