Forum: Python 11 Days Ago |
| Replies: 7 Views: 404 This should help you out. It's written in C++, but the Xlib wrapper for python is very light so it shouldn't be hard to translate.
Have fun. |
Forum: Python Oct 11th, 2009 |
| Replies: 7 Views: 334 locals_dict = locals()
for i in range(1, 10):
var_name = "POS" + str(i)
if i == POS:
locals_dict[var_name] = "->"
else:
locals_dict[var_name] = " "
discalimer:... |
Forum: Python Oct 8th, 2009 |
| Replies: 4 Views: 452 If you a using a GUI/event-driven framework, then yes, it's possible. If you are using console python, then no. |
Forum: Python Sep 12th, 2009 |
| Replies: 6 Views: 380 bytes, as they exist in Python 3.1 are conceptually new to Python (starting with version 3). This isn't to say that 8-bit strings didn't exist before in the form of regular text strings. Note the... |
Forum: Python Sep 12th, 2009 |
| Replies: 6 Views: 380 I happen to think this behavior is consistent (with indexing and slicing rules).
Here's why it makes sense:
bytes and str are not the same. They aren't even conceptually the same.
A bytes... |
Forum: Python Sep 11th, 2009 |
| Replies: 5 Views: 1,042 You actually think that is more exotic? Wow. |
Forum: Python Sep 11th, 2009 |
| Replies: 6 Views: 380 No. b'\x01\x02' Is a byte string in python. The expression bs[x] means that you want the byte at position x in the bytestring x, while bs[a:b] means that you want the part of the byte string from a... |
Forum: Python Sep 6th, 2009 |
| Replies: 12 Views: 726 Sigh.
No, python doesn't have clear screen. |
Forum: Python Sep 6th, 2009 |
| Replies: 15 Views: 591 (emphasis mine)
No, they won't. You see, there's no good reason anybody would want to do that. I guarantee you that anybody wanting to do this has a totally different underlying problem to which... |
Forum: Python Sep 6th, 2009 |
| Replies: 12 Views: 726 Python.org supposedly loves spam anyway, so long as you include some eggs. |
Forum: Python Sep 6th, 2009 |
| Replies: 4 Views: 296 Look, not to be harsh or anything, but given you previous posts I think you would be better off reading a book or a wiki or even just a tutorial on Python OOP and maybe Python in general. Really. |
Forum: DaniWeb Community Feedback Sep 6th, 2009 |
| Replies: 74 Views: 5,105 Huh. Now I can see profiles again. |
Forum: DaniWeb Community Feedback Sep 6th, 2009 |
| Replies: 74 Views: 5,105 Whenever I try to view anyone's profile I get: (see attachment) |
Forum: Python Sep 5th, 2009 |
| Replies: 15 Views: 591 Okay, I will, but first give me one reasonable use for this technique. |
Forum: Python Aug 27th, 2009 |
| Replies: 6 Views: 495 Well they actually really are dlls. It's just that the routines inside are built on the python C API.
To use them, just import them like any other module. |
Forum: Python Aug 26th, 2009 |
| Replies: 5 Views: 386 What vegaseat said.
And if you're trying to optimise your program by using the most "efficient" of these, you have issues. |
Forum: Python Aug 23rd, 2009 |
| Replies: 12 Views: 1,435 No, please don't do that.
That is okay if the page you are reading is encoded in ascii or utf-8. But if it is encoded in latin-1 (a fairly common encoding in its own right), you can run into... |
Forum: Python Jul 21st, 2009 |
| Replies: 3 Views: 215 1. You control the way your Car class prints by adding an __str__ method to it. Here is an example:
def __str__(self):
s = self.brand, self.name +": $", self.price #eg: Dodge Viper: $80000
... |
Forum: Python Jul 18th, 2009 |
| Replies: 14 Views: 565 I'm not even going to lecture you about why that is just horrible UX. If you want to put your users through that kind of torture, it's your call. The principle of what you're trying to achieve is the... |
Forum: Python Jul 15th, 2009 |
| Replies: 2 Views: 283 Well, I'm not Dan, but here's a little hack adapted from http://www.dotnetspider.com/resources/15834-eject-close-cd-tray.aspx for Python. It's only two lines of code!
To open:
import ctypes... |
Forum: Geeks' Lounge Jul 15th, 2009 |
| Replies: 31 Views: 2,078 That's one reason not to sign. |
Forum: Python Jul 12th, 2009 |
| Replies: 2 Views: 155 This method is probably a bit less efficient than other suggestions you'll get, but it's just one line:
new_list = [item[:1] for item in old_list]
Question. Why don't you use tuples instead... |
Forum: Geeks' Lounge Jul 9th, 2009 |
| Replies: 43 Views: 2,846 |
Forum: Geeks' Lounge Jul 7th, 2009 |
| Replies: 15 Views: 870 You wouldn't happen to be Indian by any chance? |
Forum: Python Jul 5th, 2009 |
| Replies: 4 Views: 275 |
Forum: Python Jul 5th, 2009 |
| Replies: 4 Views: 275 Line four didn't get you anything? You should've gotten an IO error; you're not supposed to read from files you open for writing. If even you had opened the file as w+, you still should've gotten... |
Forum: Python Jun 28th, 2009 |
| Replies: 17 Views: 831 Linux is by a good extent a "python OS". Okay that's misleading because the kernel itself isn't written in Python, but most distros would break if you remove it. |
Forum: Python Jun 26th, 2009 |
| Replies: 7 Views: 460 That's not a real key logger and you know it. Fail to the OP for accepting it as a solution without the most obvious test. Goes to show just how lazy he is. |
Forum: Geeks' Lounge Jun 23rd, 2009 |
| Replies: 16 Views: 1,170 William, I wasn't trying to put you down; this is practically how everyone I know (not just programmers) feels about their work. There is never enough time, and we're always tired. They don't teach... |
Forum: Python Jun 23rd, 2009 |
| Replies: 6 Views: 356 Hey jlm699, how come you called random.seed()? |
Forum: Geeks' Lounge Jun 22nd, 2009 |
| Replies: 16 Views: 1,170 Stop being a wimp. And sleep 6 hours a day if you need more time. |
Forum: Python Jun 17th, 2009 |
| Replies: 8 Views: 861 Sure.. Whatever actually works is probably fine. You can always optimize from there. |
Forum: Python Jun 17th, 2009 |
| Replies: 8 Views: 354 You're going to have to post the code for do_stuff_with_var. Otherwise we'd just be guessing. |
Forum: Python Jun 17th, 2009 |
| Replies: 8 Views: 861 What you need to do is read one word at a time from the file and check that word for capitalization. Here's an example:
word = ""
char = fobj.read(1)
while char:
if char == " ":
... |
Forum: Python Jun 15th, 2009 |
| Replies: 5 Views: 258 Except I don't think he meant i there, but rather 1 (the number one). I can never be sure though. |
Forum: Python Jun 15th, 2009 |
| Replies: 7 Views: 317 Of course, just about anything can (and it has nothing to do with python)! |
Forum: Python Jun 15th, 2009 |
| Replies: 9 Views: 1,022 Just in case you don't fine wxGlade or BoaConstructor to be quite what you need (or if you just can't get past how ugly they are), you can try QtDesigner for pyQT (comes with the pyQT package). |
Forum: Geeks' Lounge Jun 11th, 2009 |
| Replies: 75 Views: 5,046 |
Forum: Geeks' Lounge Jun 10th, 2009 |
| Replies: 75 Views: 5,046 I don't remember any of my favorite movies at all. I do remember noting however, that whenever I say to myself "Hey I really adore this movie", that movie had a good score. Maybe there's some kind of... |
Forum: Geeks' Lounge Jun 10th, 2009 |
| Replies: 75 Views: 5,046 |