scru 909

[QUOTE=jephthah;913371]there are plenty of people with more rep points than me who haven't been featured. and rep points are just as subjective and arbitrary as being selected to get a "featured poster" bubble. i mean, look at you: you were "featured". that proves how meaningless it is.

it is you who miss the point. this is not a democracy. and featured poster is not some "American Idol"-like popularity contest that you get to vote on. the owners of this site can run this place any way they choose to do so, without soliciting your opinion or asking your approval.

Why'd they pick essentials? The real question is: why should you even care? What is it about essentials that makes you lose sleep at night? Personally, i dont care who gets featured or not. All i care about is becoming Super Mod.

yeah okay, don't let the door hit you in the ass on the way out :)

.[/QUOTE]
Oh snap!

scru 909

[QUOTE=Menster;910528]Whats the general opinion here: Are all programmers stoners?
(If my colloquialism is lost across borders i'm talking about marijuana)

Some two-bit sales person came and chirped me the other day that sales will always be the more powerful branch of the industry because they're the deal makers, they're more presentable and confident and they don't spend their time smoking [B]as much weed as possible...[/B]

Now I've met many programmers, and [b]most[/b] of them do smoke, but I'm just curious what the stats are the world over.[/QUOTE]
You wouldn't happen to be Indian by any chance?

scru 909

Is everything okay now?

scru 909

Line four didn't get you [I]anything[/I]? 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 that blank line, because of the position you are in the file (past what you have written). Files are sequential.

As to that junk text, I have no idea what's going on there.

scru 909

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.

scru 909

[QUOTE=sneekula;898994]If you use the Windows OS:
[code=python]# get the character of a key pressed (no return key needed)

works only in the command window and with Windows OS
msvcrt.dll is the MS C library containing most standard C functions

from msvcrt import getch

print "press a char key (escape key to exit)"

while True:
z = getch()

escape key to exit
if ord(z) == 27:
    break
print z,

[/code][/QUOTE]
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.

scru 909

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 stuff like time-management in school because they need syllabus filler.

HFLE maybe...

scru 909

Hey jlm699, how come you called random.seed()?

scru 909

Stop being a wimp. And sleep 6 hours a day if you need more time.

William Hemsworth commented: Meh, I just don't wanna end up like Serkan. -2

scru 909

Sure.. Whatever actually works is probably fine. You can always optimize from there.

scru 909

You're going to have to post the code for do_stuff_with_var. Otherwise we'd just be guessing.

scru 909

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:

[code=python]
word = ""
char = fobj.read(1)
while char:
if char == " ":
if word.istitle():
print word
word = ""
else:
word += char
char = fobj.read(1)
[/code]

Note: I haven't tested this.

scru 909

I wouldn't worry too much about space usage. On a typical 32bit python installation using slots, your class uses 16 bytes per instance, not counting the storage for the data within the class, and you shouldn't (8 of these are mandatory for a base python object, so in reality it uses 8 bytes for your data; two 32-bit pointers, which is what the struct would use in C).

Slots are easy:
[code=python]
class MyClass(object):
slots = ("first", "rest")
def init(self, f, r):
...
[/code]

I just assigned a sequence of attribute names that the instances will use. That way, python doesn't create a dict for each instance, but allocates just enough extra space for pointers to the names in the sequence.

Also, note that I have used new style classes(subclassing from object). You really shouldn't be using old style classes anymore.

scru 909

Except I don't think he meant i there, but rather 1 (the number one). I can never be sure though.

scru 909

[QUOTE=evstevemd;890138]Embedding image? Yes possible but sound? Not sure![/QUOTE]

Of course, just about anything can (and it has nothing to do with python)!

scru 909

For named tuple you need >= python26 (that includes python30). Note that if you intend to use it for calling into C code, namedtuple won't work.

scru 909

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).

scru 909

[code=python]
from ctypes import *

class Trie(Structure):
fields = [("foo", c_char,
("bar", ARRAY(c_char, 10))]

[/code]

Don't have a testing machine in front of me so that code might be slightly off.

scru 909

Of all the dumb, shallow requests I've seen on this site, this has to be the dumbest and shallowest.

scru 909

Try:

[code=python]
import urllib
import os
import time

open_file=open('html.html','r')
file=open_file.read()

def shutdown():
os.system('shutdown -s')

value=[]
for item in file:
value.append(item)
test=''.join(value)
if test=='shutdown_now':
shutdown()
[/code]

sravan953 commented: Great +1

scru 909

Not sure what you mean...
[code=python]
import urllib
import string

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

value=str(read_site)

print value
[/code]

scru 909

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.

scru 909

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 python gui. On the file menu choose New Window and type your code there. Save it and then press F5 to run it.

scru 909

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 need to go into Window's vista command prompt, navigate to the folder where you saved the script (cd command), and then type [icode]script.py[/icode].

Note, if you have >>> that means you are in the python interpreter and not command prompt.

scru 909

If you want to just find out if one string is contained inside another:
[code=python] strvalue1 in strvalue2[/code]

If you want to find out how many occurrences of one string there are in another:
[code=python]num = strvalue.count(strvalue2)[/code]

If you want to find the index of the first occurrence of one string in another:
[code=python]ind = strvalue1.find(strvalue2)[/code]

vegaseat commented: nice help +12

scru 909

Have a look at easy bcd (google it). Use it to reset your mbr to use the vista loader, and then once you have verified that your mbr is in tact (and on the correct partition!), you may delete/recover the partition that you gave to 7.

scru 909

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 stuck with a retarded editor comes to mind) and won't matter if you use them consistently for indentation throughout. If code that you produce is known to use tabs throughout for indentation, it wouldn't be too much trouble for someone wanting to use spaces instead to just convert them to the appropriate amount.

That said if you're going to go with spaces, then you're better off just using 4, since most python code out in the wild would use 4 spaces for indentation anyway.

scru 909

Aw that's cute.

You think you're so significant (or that your opinions are so special) that everybody [I]must[/I] give you a reason for disagreeing with you. It makes me wonder how you even get along in the real world. Do you stop every adversary and annoy them into giving you a detailed reason for their feelings of disdain (I'm surprised you still find time to come do it on the internet too)?

Seriously though, grow up.

iamthwee commented: Briiiiiiiiiiiiiiiiiillliant. +20
jephthah commented: i disagree, but i dont really have a reason. -2

scru 909

Yeah:

[code=python]
print " ".join(hints.hint())
[/code]

Which should combine the list into a string, separated by a space. But you knew that before, didn't you?

scru 909

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?