No one has voted on any posts yet. Votes from other community members are used to determine a member's reputation amongst their peers.
25 Posted Topics
I thought it'd be better to use `JSON` or `YAML` to store lists of dictionaries (a documents-based database) and then create a nice little front-end to wrap the code up, since people claim that `pickle` is insecure against "maliculously constructed data".
Is there any way I can execute a block of code in a loop, like so: [ some code goes here ] Where the delimiters are "[" and "]", and also allowing for nested blocks, i.e.: [the user can create another loop[]] I am creating a parser for a language …
I've been looking for a way to parse a simple XML-like language for use as a type of data storage. I've been through stuff like JSON, XML, etc but I don't want to use them because they are quite slow. I just need a simple way to parse this: [stuff] …
So I have this piece of code in a socket server: def process(self, request, client_address): input_file = request.makefile("rb", 0) output = request.makefile('wb', 0) remote_input = input_file.readline().strip() + b"\n" self.log(remote_input) self.proc.stdin.write(remote_input) self.proc.stdin.flush() self.proc.stdout.flush() while True: line = self.proc.stdout.readline() line = line.decode() if line: line = bytes(line.rstrip() + "\n", 'utf-8') output.write(line) else: …
You can always use the threading module for scheduling such functions trivially. I.e. def worker(self, name): # check if we need to exit while not self._exitflag: time.sleep(self._nap_time) self._threadLock.acquire() if self._need_to_do_job: # perform jobs pass self._threadLock.release() Though when you `.join()` the function, you will need to wait for the time specified …
So I have a code that prints out the `sys.argv` when the program is ran. How can I parse $ python ./arch.py install * to show `["./arch.py","install","*"]` Instead of `["./arch.py","install",#other files in directory]`?
How do you start a SSH server on localhost through executing a shell script? If so, is there any way to restrict the commands performed or use another shell script as it's default console (i.e. Instead of Terminal.app it uses X11)?
> I've started writing a 2d platformer game some days ago, and I'm really enthusiastic about it, but I already failed to live up to my own expectations: I just cannot possibly think of a way I could make my character jump. I used the MVC desing is why, and …
For some reason , my code keeps returning a false reply even if the string is in the file. Here's my code: def check(self): self = str(self) if self in config_file: print ('Account exists') if self not in config_file: print ('Account doesn't exist')
How could I make the return command in Python return a list AS a list, and not as a 'programmer' list? For example, for line in list: return (line) But for some reason it only returns the first element in the list, for example: myList = ['1','2','a','b'] for line in …
> I need help with my facebook page it wont load and my media player wont let me play it This is not considered 'Software Development'. And you can't 'play' a Facebook page.
How do you make Python accept multiple strings and break them down in an input? For example, main = input ('> ') if main == ('ECHO',some_words): print (some_words) But everytime I do that, the some_words string wouldn't be defined. Error Message: Traceback (most recent call last): File "<pyshell#7>", line 1, …
Can someone give a code snippet on how to 'chat' using the XMLRPC library in Python? Here's my server code: from xmlrpc.server import SimpleXMLRPCServer from xmlrpc.server import SimpleXMLRPCRequestHandler import os from os import access, path PATH = 'chatlog.$' class RequestHandler(SimpleXMLRPCRequestHandler): rpc_paths = ('/RPC2',) server = SimpleXMLRPCServer(("localhost", 8000), requestHandler=RequestHandler) server.register_introspection_functions() server.register_function(pow) …
Is it possible (without using any external modules) to make two computers, or Python programs communicate through an Ethernet cable? E.g. Sending messages, numbers, etc. And if so, how?
How do you make Python set an str from a file? For example, my file would contain these pieces of text: username=Eugene password=eugene How do I get Python to return this? >>> print(username) Eugene >>> print(password) eugene Any help is deeply appreciated. Thanks!
How do you make Python delete a specific line of text from a file? For example, delete_input = input ('> ') file = open('blahblah.$','w') #delete the variable delete_input file.delete(delete_input from file) Any form of help would be appreciated. Thanks!
I have a very tough problem- how do you make an icon/character move across a console screen? For example, if I press W, +++++ ++E++ +++++ Then I press D +++++ +++E+ +++++ And I want it to be like the CHOICE command in CMD- Without requiring the user to …
How do you make Python delete a string or a number (in this case, .0) from a file? Example: #Error Fixing if '.0' in open('ship.$','r'): #Delete the '.0'
Guys check out http://cx6-dev.blogspot.com/ for an awesome game coded in Python. It's new but still fun. HIGHLY RECOMMENDED! PS: You'll need to have Python 3.2 or above to install/play it.
I have a code for a game. money_file = open ('money.$','r').read() money_file = str(money_file) money = int(money_file) But everytime I run it, it returns an error: Traceback (most recent call last): File "C:\Users\eeo.j\Desktop\CX6 SDK\CX6 Normal\CX6.py", line 86, in <module> money = int(money_file) ValueError: invalid literal for int() with base 10: …
From what I understand in your post, you can make a variable of the database when you read it. For example, database_file = #your database file and method of IO save_file = open('blahblahcsv','w') save_file.write(str(database_file)) save_file.close() If your database file has more than one line, you could also use the for …
You can also use this method for checking a file: from os import path, access, R_OK PATH='file path' if path.exists(PATH) and path.isfile(PATH) and access(PATH, R_OK): #do something else: open(PATH,'w')
I've been working on Tkinter, and setting a message box. It worked fine, but I didn't really like the fact that the text displayed was in a small position in the window. Take a look at this code and you'll know what I mean. def About(self): text = Message(self, text=''' …
You could also use a more 'Python' way to clear screens- print('\n' *100) #prints 100 newlines Although it seems messy, it works cross platform. You could also consider Tkinter as a way to develop your programs because there's a built in clear screen command. **Links** http://wiki.python.org/moin/TkInter
Is there any way to host several txt files on a computer without having to dive deep into socket programming? I have a few requirements, though: * People could connect when the app is running * No inteference of Windows * Instructions on how to create a client side software …
The End.
3e0jUn