- Upvotes Received
- 19
- Posts with Upvotes
- 12
- Upvoting Members
- 17
- Downvotes Received
- 11
- Posts with Downvotes
- 7
- Downvoting Members
- 9
108 Posted Topics
daniweb is like a great discusion, while stack overflow is like, "Just take this code"
import string,sys def reverse(s): return s[::-1] encode = {' ':' '} for l,revl in zip(string.letters,reverse(string.letters)): encode[l]=revl decode = {' ':' '} for l,revl in zip(string.letters,reverse(string.letters)): decode[l]=revl while True: what = raw_input("Decode or encode").lower() if what == "decode": current = decode elif what == "encode": current = encode else: print "What?" …
Granted. All books are garbled. I wish I had infinite wishes.
Because the games mean to be slow(like pausiing the program on purpose) Why am I epic?
other sites have html errors. daniweb only didn't close there <daniweb> tag* *</m> didn't start his <m> tag
Spotty showers, one minute it's sunny, the next it's raining.
How would I use [web.py](http://www.webpy.org) to execute ASP/PHP server files? Or can web.py not do that and can someone provide me a python script that can execute ASP/PHP server files? Should I try posting this in the PHP forum, Web Design, html, and css fourm, or the Web development forum …
Web.py outputs 0.0.0.0:8080. On windows, localhost and 0.0.0.0 work. But on mavericks, localhost doesn't work! 0.0.0.0 works, though. Can someone explain what 0.0.0.0 is? Why does web.py say you can enter a ip and port in command line and it will run there? (You can't run on someone else's ip,can …
import web,re,traceback urls=( "/","displaythreads" "/viewthread","displaythreads", "/viewthread/(.*)","displaythread", "/viewthread/(.*)/Vote/(Up|Down)","vote", "/newthread/(.*)","newthread", "/newthread","newthread" ) entries={}###{entryname:{property:value}} entrylength=0 class displaythreads: pass class newthread: template=web.template.frender("newthread.html") default=template("DEFAULT",0) def initialize(): pass def GET(): return default def POST(): data = web.input() try: username,threadname = data.username,data.threadname except: return template(mode) if threadname in entries: return template("Exists") entries[threadname]={"creator":username,"points":0,"totvotes":0} class displaythread: template=web.template.frender('Thread Viewer Template.html') …
lolpython I FUTURE CAT WITH print_function SO IM LIKE main OK? VISIBLE LOL Hello world /LOL IZ __name__ KINDA LIKE "__main__"? main THINGZ
class Timerange{ public: Start_time start; End_time end; Timerange(string initstring){ //initstring xx:xx X, x:x //X->weekday string current=""; unsigned short mode=0; string timeA; string weekday; string timeB; for(unsigned short i = 0; i<initstring.length(); i++) { char c = initstring[i]; if (c==' '){ if (mode==0) timeA = current; else if (mode==1) weekday = …
THIS IS DANGEROOUS CODE, if it fails, it may prevent yu frome editing it. also, you can use the functions to do crazy stuff. Look at [this refrence](http://msdn.microsoft.com/en-us/library/windows/desktop/dd375731(v=vs.85).aspx) and change the `0x12` to what you want. (This one hold alt, so typing r will actibvate the menu that starts with …
import os import web import traceback import datetime from functools import wraps ### Url mappings urls = [ '/', 'index', ] def addfolderhandler(f,root): u = os.path.join(root,f) u=u.strip("/").strip("\\") ident=u.lstrip("C:/Users/James/Desktop/it").replace("/","SLASH").replace("\\","SLASH").replace(".","DOT").strip() #replace invalid python expressions with valid ones globals()[ident] = "<h1>Directory listing for:%s</h1><hr>"%u+''.join(["<a href="+i+">"+i.lstrip(root)+"</a><br/>" for i in os.listdir(u)])+"<i>Python Server</i>" if ident=="": return try: …
When You delete something, the data IS STILL THERE! It will be replaced, but the only way to 100% sure to get rid of it, is to fill up your hard drive.
print("hell\*!".replace("\*","o")) daniweb has no bad words.
a list of spam posts to delete. Here's the first: http://www.daniweb.com/hardware-and-software/pc-hardware/storage/threads/465744/child-smokeing-habit
Traceback (most recent call last): File "C:\Users\James\Desktop\pvz.py", line 64, in <module> Pea((10,20)) File "C:\Users\James\Desktop\pvz.py", line 48, in __init__ Projectiles.add(self) File "C:\Python27\lib\site-packages\pygame\sprite.py", line 319, in add sprite.add_internal(self) File "C:\Python27\lib\site-packages\pygame\sprite.py", line 147, in add_internal self.__g[group] = 0 AttributeError: 'Pea' object has no attribute '_Sprite__g' import pygame,traceback width = 480 height = 640 …
340.49588359180547578020294849703 bugs consumed per day, since 1.5.2
Whoa, whoa whoa, you'll have to redesign it. First, rename your vars, I haven't, but you should. Second, have `Math` return, then print, I've done this for you Third, lowecase your vars, that's style. import math def Math(x1,y1): a = x1+y1 b = x1-y1 c = x1*y1 d = x1/y1 …
> Why are there no C++ libraries to deal with those needs? There are. [From the docs.](http://docs.python.org/2/extending/extending.html)
import os import web ### Url mappings urls = [ '/', 'index', '/.*','notfound' ] for root, dirs, files in os.walk("C:/Users/James/Desktop/server"): for f in files: u = os.path.join(root,f) u=u.strip("/").strip("\\") ident=u.lstrip("C:/Users/James/Desktop/server").replace("/","slash").replace("\\","SLASH").replace(".","DOT") globals()[ident] = open(u,mode='rb').read() exec(""" class %(classname)s: def GET(self): global %(data)s return %(data)s """%{"classname":ident+"server","data":ident}, globals(), globals()) #create a class as if were …
It writes the output to the screen, so you'll have to somehow read the screen an then clear it (try doing this for clearing the screen: import subprocess import platform def clear(): subprocess.Popen( "cls" if platform.system() == "Windows" else "clear", shell=True) clear() )
Congrats! But how does a junior poster in training become one? (I'm just curious)
`range(2,10)` generates a list, `[2,3,4,5,6,7,8,9]` `for n in range(2,10)` assigns `n` to the next element in the result from `range(2,10)` and then executes the code, repeat `range(2,n)` takes n and generates `[2,3,4....,n-1]`
Try making a `main()` function inside a `Game` object, setting every variable to `self`, and using pickle to save/load it.(and Creating and instance of Game if not loadable)
I tried downloading the file and playing it using `winsound` to play it with the flag `SND_MEMORY`, but it only accepts `str` instead of the `bytes` object I got from `urllib.request.urlopen`. Using `decode()` needs a valid encoding, but I don't have one. CLARIFICATION:downloading the file I mean as using `urllib.request.urlopen` …
@dani pickle is for turning objects\* into text,to write to a file so you can save variables \*Most objects, including user-defined, If not, you can customize to do it. It can even do recusive lists!
`raw_input` is actually a convience function for `sys.stdin.readline()`
you didn't INITIALIZE it toa empty list
s = "hi!" for i in s: #do something pass #put pass if no code
class stdout(object): def __init__(self,realout,prefix): self.file = realout self.at_start_of_line = True self.prefix=prefix def write(self, text): if len(text): if self.at_start_of_line: text = self.prefix + text self.file.write(text) self.at_start_of_line = (text[-1] == '\n') sys.stdout=stdout(sys.stdout,"OUT ["+f+"]> ") File "C:\Users\James\Desktop\run.py", line 13, in write self.file.write(text) File "C:\Users\James\Desktop\run.py", line 10, in write if self.at_start_of_line: AttributeError: 'stdout' object …
def GenContent(address,what): return urllib.urlopen("http://www.yelp.com/search?find_desc="+what+"&#find_loc="+address).read() I am using python to do this. It works prefectly in my browser.
Try connecting with sqlite3!
def mu_cache(func,maxsize=128): "Most Used Cache decorator" cname = "__"+func.__name__+"_Cache" rname = "__"+func.__name__+"_Rankings" exec("global "+cname) exec(cname+" = {}") #here exec("global "+rname) exec(rname+" = {}") def wrap(*args,**kwargs): cache = eval(cname) rankings = eval(rname) try: res = cache[(args,kwargs)] except: res = func(*args,**kwargs) cache[(args,kwargs)] = res else: try: res = rname[(args,kwargs)] except: res=0 rname[(args,kwargs)] …
* The standard library * pygame or the `print` function and `os.system('cls)/os.system('clear')` * This code: def keypress(event): global key_events key_events.append(event.char) def updatefunction(): evnets = key_events key_events = [] os.system('cls') picture = "" #Actual game play code# #set picture to the image you need# print picture from tkinter import * root …
use the `re` module and `os.walk` to compute REs and to find files. "Any Language Can Be Used To Make Anything"* *except for SQL
make a program that beeps every once in a while: import winsound,time while True: winsound.Beep(32767,1) #maximmumm hertz time.sleep(1)
Use for loops and list comprehensions a = [i for i in range(995) if i%5==0] # for every number in 0-995 if it's remainder when divided with 5 equals 0, put it in a list b = [i for i in range(995) if i%3==0] #same print(a+b) #wrong! outputs alist of …
The live posts shows the posting rate is very low.
> import random >x = random.randint(1, 100) >print(x) //I print x >print(x) //x stays the same python comments use `#`
The End.