Search Results

Showing results 1 to 40 of 113
Search took 0.02 seconds.
Search: Posts Made By: scru ; Forum: Python and child forums
Forum: Python Oct 11th, 2009
Replies: 7
Views: 310
Posted By scru
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: 400
Posted By scru
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: 347
Posted By scru
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: 347
Posted By scru
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: 897
Posted By scru
You actually think that is more exotic? Wow.
Forum: Python Sep 11th, 2009
Replies: 6
Views: 347
Posted By scru
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: 656
Posted By scru
Sigh.

No, python doesn't have clear screen.
Forum: Python Sep 6th, 2009
Replies: 15
Views: 547
Posted By scru
(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: 656
Posted By scru
Python.org supposedly loves spam anyway, so long as you include some eggs.
Forum: Python Sep 6th, 2009
Replies: 4
Views: 284
Posted By scru
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: Python Sep 5th, 2009
Replies: 15
Views: 547
Posted By scru
Okay, I will, but first give me one reasonable use for this technique.
Forum: Python Aug 27th, 2009
Replies: 6
Views: 469
Posted By scru
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: 375
Posted By scru
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,288
Posted By scru
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: 207
Posted By scru
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: 546
Posted By scru
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: 254
Posted By scru
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: Python Jul 12th, 2009
Replies: 2
Solved: lists
Views: 147
Posted By scru
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: Python Jul 5th, 2009
Replies: 4
Solved: File Handling
Views: 268
Posted By scru
Is everything okay now?
Forum: Python Jul 5th, 2009
Replies: 4
Solved: File Handling
Views: 268
Posted By scru
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
Solved: python os?
Views: 792
Posted By scru
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: 453
Posted By scru
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: Python Jun 23rd, 2009
Replies: 6
Views: 350
Posted By scru
Hey jlm699, how come you called random.seed()?
Forum: Python Jun 17th, 2009
Replies: 8
Views: 789
Posted By scru
Sure.. Whatever actually works is probably fine. You can always optimize from there.
Forum: Python Jun 17th, 2009
Replies: 8
Views: 350
Posted By scru
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: 789
Posted By scru
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: 255
Posted By scru
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: 312
Posted By scru
Of course, just about anything can (and it has nothing to do with python)!
Forum: Python Jun 15th, 2009
Replies: 9
Views: 954
Posted By scru
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: Python Jun 10th, 2009
Replies: 5
Views: 334
Posted By scru
Of all the dumb, shallow requests I've seen on this site, this has to be the dumbest and shallowest.
Forum: Python Jun 8th, 2009
Replies: 4
Views: 272
Posted By scru
Try:


import urllib
import os
import time

open_file=open('html.html','r')
file=open_file.read()
Forum: Python Jun 8th, 2009
Replies: 4
Views: 272
Posted By scru
Not sure what you mean...

import urllib
import string

open_site=urllib.urlopen('http://www.sravan953.blogspot.com')
read_site=open_site.read()

value=str(read_site)
Forum: Python May 29th, 2009
Replies: 7
Views: 311
Posted By scru
IDLE is perfect for newbies. The only thing to bear in mind; when you start learning GUIs you shouldn't run them in IDLE as they make it unstable, but for now IDLE is good.
Forum: Python May 29th, 2009
Replies: 7
Views: 311
Posted By scru
Not exactly.

The easiest way is to start IDLE (Python GUI). On the file menu, click open to load your script, and then press F5 to run it.

If you want to write new scripts with it, start the...
Forum: Python May 29th, 2009
Replies: 7
Views: 311
Posted By scru
If you've written the script with IDLE, the best (and easiest) way to run it is by pressing F5 inside IDLE (once you've got the file open).

If you've written it with some other editor, then you...
Forum: Python May 29th, 2009
Replies: 2
Views: 870
Posted By scru
If you want to just find out if one string is contained inside another:
strvalue1 in strvalue2

If you want to find out how many occurrences of one string there are in another:
num =...
Forum: Python May 27th, 2009
Replies: 14
Solved: List problem
Views: 478
Posted By scru
I don't really agree that spaces are the proper way and tabs aren't. I would agree that which ever you choose, you should use it consistently. There are some cases where tabs can be convenient (being...
Forum: Python May 26th, 2009
Replies: 14
Solved: List problem
Views: 478
Posted By scru
Yeah:


print " ".join(hints.hint())


Which should combine the list into a string, separated by a space. But you knew that before, didn't you?
Forum: Python May 26th, 2009
Replies: 5
Views: 340
Posted By scru
Most likely issue is a firewall.

After that there's routers (port forwarding stuff) and proxies. Are you trying to connect over the internet, or on the same subnet?
Forum: Python May 26th, 2009
Replies: 14
Solved: List problem
Views: 478
Posted By scru
return " ".join(hint) creates a string by joining strings in the list, separated by a space. For example, if you have the following list you strings:

["black", "white", "black"]

then you would...
Showing results 1 to 40 of 113

 


About Us | Contact Us | Advertise | DaniWeb | Acceptable Use Policy | RSS Feed

©2003 - 2009 DaniWeb® LLC