Python Forum
Search Results
Post Author Forum Replies Views Posted [asc]
    Thread: How would you test this module?
Post: How would you test this module?

How can I write unit tests for this module. I know very little about writing tests. #-*-coding:utf8;-*- #qpy:3 #qpy:console SINGLETONS = [ 'area', 'base', 'br', 'col', 'command...
RickyWilson General Coding Help 2 2,816 Dec-26-2017, 04:49 PM
    Thread: Code review needed for a basic repl implementation
Post: Code review needed for a basic repl implementation

Here is a very basic object orientated implementation of a read evaluate print loop AKA REPL. I encluded REShell to demonstrate how one could use Reple. I would like to know the quality of this code....
RickyWilson Code sharing 2 2,891 Dec-23-2017, 09:57 PM
    Thread: A. very basic micro web framework.
Post: A. very basic micro web framework.

I'm looking for some insight on a prototype micro web framework I'm working on. #!/usr/bin/env python from http.server import BaseHTTPRequestHandler, HTTPServer import sys import socket DEFAULT_...
RickyWilson Web Scraping & Web Development 2 3,176 Dec-22-2017, 06:30 AM
    Thread: How to use BeautifulSoup to parse google search results
Post: RE: How to use BeautifulSoup to parse google searc...

The search results are generated with JavaScript and bs4 can't render JavaScript.
RickyWilson Web Scraping & Web Development 16 21,379 Dec-22-2017, 06:19 AM
    Thread: Why is my crawler not recording 404s I think it may be an error in the logic
Post: RE: Why is my crawler not recording 404s I think i...

(Dec-18-2017, 06:04 AM)Larz60+ Wrote: It looks like your trying to save in a set. This is a list of url's, so use a list. self.not_found = [ ] ...   if status_code == 404:    self.not_found.appen...
RickyWilson General Coding Help 3 3,389 Dec-18-2017, 06:30 AM
    Thread: Why is my crawler not recording 404s I think it may be an error in the logic
Post: Why is my crawler not recording 404s I think it ma...

I got bored today so I started coding up this little web crawler. Not knowing much about the standard library's HTMLParser I figured a web crawler would be a good way to learn the API. I was surpri...
RickyWilson General Coding Help 3 3,389 Dec-18-2017, 05:46 AM
    Thread: Port scanner needs review.
Post: Port scanner needs review.

Code
RickyWilson General Coding Help 1 2,887 Dec-12-2017, 02:43 AM
    Thread: A simple web crawler that does nothing special.
Post: A simple web crawler that does nothing special.

I wrote this on my android using qpython3 #-*-coding:utf8;-*- #qpy:3 #qpy:console import urllib.request from urllib.parse import urlparse import re seed = 'http://www.google.com' tocrawl = set([se...
RickyWilson Code sharing 0 2,092 Dec-05-2017, 05:51 PM
    Thread: Convert file sizes: will this produce accurate results?
Post: Convert file sizes: will this produce accurate res...

Any suggestions on how to improve this script would be awesome. def convert_size(size_bytes): if size_bytes == 0: return "0B" size_name = ("B", "KB", "MB", "GB", "TB", "PB", "EB"...
RickyWilson General Coding Help 2 8,115 Dec-04-2017, 10:30 AM
    Thread: What should I name these vars
Post: What should I name these vars

import os import os.path import sys import readline def modcmd(arg): # I want to declare the the sys.executable+" "+sys.prefix+"/bin/" # as a constant but don't know what to name it. os.syst...
RickyWilson General Coding Help 1 2,217 Dec-02-2017, 07:36 PM
    Thread: Pig Latin Translator
Post: Pig Latin Translator

def translate(text): return ' '.join('{}{}{}'.format(word, word[0], 'say')[1:] for word in text.split()) while 1: word = input('Enter some words: ') if word == 'quit': break ...
RickyWilson General Coding Help 1 3,195 Dec-02-2017, 08:16 AM
    Thread: Very basic programming help needed: pig latin program
Post: RE: Very basic programming help needed: pig latin ...

def translate(text): return ' '.join('{}{}{}'.format(word, word[0], 'say')[1:] for word in text.split()) while 1: word = input('Enter some words: ') if word == 'quit': break p...
RickyWilson General Coding Help 2 8,002 Dec-02-2017, 08:12 AM
    Thread: How can i store a refreshing data
Post: RE: How can i store a refreshing data

If your able to extract the value of the counter convert it to an int and keep checking it. then = 0 while 1: now = int(check_timer()) if now > then: then = now # do stuff ...
RickyWilson General Coding Help 2 2,682 Dec-01-2017, 06:59 PM
    Thread: help with While method
Post: RE: help with While method

s = 'foo bar baz' print('\n'.join(s.split()))Outputs: foo bar baz
RickyWilson General Coding Help 5 4,237 Dec-01-2017, 06:41 PM
    Thread: Variable Scope for Scripts
Post: RE: Variable Scope for Scripts

To prevent the global namespace from getting messy you can encapsulate your globals in a class thus giving them there own namespace. Example: class Config(object): timeout = 0.5 url = 'http://...
RickyWilson General Coding Help 6 4,272 Dec-01-2017, 06:26 PM
    Thread: Help Formatting Print Statement (input from 3 lists) X 2
Post: RE: Help Formatting Print Statement (input from 3 ...

product, price, quantity = 'Hydro', 120.0, 65535 message = '{product} ${price} {quantity}' print(message.format(product=product, price=price, quantity=quantity)) Hydro $120.0 65535Am I on ...
RickyWilson Homework 11 6,322 Dec-01-2017, 02:29 AM
    Thread: Help Formatting Print Statement (input from 3 lists) X 2
Post: RE: Help Formatting Print Statement (input from 3 ...

Could you post the rest of the code?
RickyWilson Homework 11 6,322 Dec-01-2017, 12:59 AM
    Thread: Python:How to read a recived message that idinfies the client Byte by Byte using UDP
Post: RE: Python:How to read a recived message that idin...

Why not follow PEP8?
RickyWilson Networking 2 5,956 Dec-01-2017, 12:43 AM
    Thread: Help Formatting Print Statement (input from 3 lists) X 2
Post: RE: Help Formatting Print Statement (input from 3 ...

Use use the format method of the str obj. Example: fmstr = '{scheme}://{host}/{path}' scheme = 'http' host = 'smegma.com' path = '/spam' print(fmstr.format(scheme=scheme, host=host, path=path))will re...
RickyWilson Homework 11 6,322 Dec-01-2017, 12:25 AM
    Thread: How can python handle a stdout from bash shell by using Popen()
Post: RE: How can python handle a stdout from bash shell...

I would use the tarfile and gzip modules that come built-in to python. What is the purpose of the script if you don't mind me asking?
RickyWilson General Coding Help 3 4,423 Dec-01-2017, 12:09 AM

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020