get site name from a URL in python

I am new to Python and it seems to have a lot of nice functions that I don't know about. What function can I use to get the root site name? For example, how would I get faqs.org if I gave the...

What's wrong with my Python SOAPpy webservice call?

I am playing around trying to call a simple SOAP webservice using the following code in the Python interpreter: from SOAPpy import WSDL wsdl = "http://www.webservicex.net/whois.asmx?wsdl" proxy =...

Defining private module functions in python

According to http://www.faqs.org/docs/diveintopython/fileinfo_private.html: Like most languages, Python has the concept of private elements: Private functions, which can't be called...

Easy way of getting started programming using python

Background I'm trying to learn to program a little & python seems like a good choice for my purpose. I have no ambition of ever being a serious programmer.I already know bits and pieces of html,...

Programming projects website

Does anybody know of a website where they have a listing of interesting projects that one can do to gradually ramp up your skills, and stuff that is actually interesting. This could be language...

Getting started with json

I have never worked with json before. I am trying: http://api.worldbank.org//topics?format=JSON and make things with it, but I don't even know how to get started. Following some manuals, I did...

DiveIntoPython like for Java?

Any Java tutorial that resembles Mark Pilgrim's approach for DiveIntoPython?

How to make this naive python implement of Quicksort more pythonic?

I'm 2 hours into my reading of diveintopython and I implemented a naive version of quicksort. import operator def even(num): return operator.mod(num,2) == 0 def last(list): return...

C++ | Progresssion Path

I know the basic OOP-related topics, RTTI, Templates. Reverting back from Java' Collection Framework, I tried to find such collections in C++ and found STL, and am trying to use it in my projects...

Unresolved Import Issues with PyDev and Eclipse

I am very new to PyDev and Python, though I have used Eclipse for Java plenty. I am trying to work through some of the Dive Into Python examples and this feels like an extremely trivial problem...

Manipulating well-formed xml (in any language running under linux)

I have well-formed xml (open-tags are closed, etc), but there's no dtd, namespaces are not always correct, and there are random entities. I found an error in some of my xml files, and want to fix...

argv listing directory files

this very simple code is driving me nuts. import sys,string,socket maquina = sys.argv[1] texto = string.join(sys.argv[2:], " ") print '['+maquina+']' print '['+texto+']' mysock =...

How do I format code neatly in HTML/CSS ? I especially want to use the numerical circle callouts, with Python Docutils if I can

see: http://diveintopython.net/native_data_types/lists.html#d0e5623 I have a website with code examples on it, generated through docutils, and the CSS is always not quite right. I would like to...

python If statement Syntax error?

new to python, currently reading diveintopython and trying to run the following code from the book: def buildConnectionString(params): """Build a connection string from a dictionary of...

What is the difference between class and data attributes?

To quote diveintopython, "You already know about data attributes, which are variables owned by a specific instance of a class. Python also supports class attributes, which are variables owned by...

raise error vs. return False python3

Hi I have started coding in python lately and I am wondering how to handle errors. I did the tutorial diveintopython and there he uses raise error to give feedback whats going wrong. Here my...

No constructor overloading in Python - Disadvantage?

I was going through DiveIntoPython and came across this: Java and Powerbuilder support function overloading by argument list, i.e. one class can have multiple methods with the same name but...

Print Instance of Class In Python as Built-In DataType?

I am reading DiveIntoPython. I'm wondering why I can directly print the instance of a UserDict as a dictionary. In detail, these codes import UserDict; d = UserDict.UserDict({1:1, 'a':2}); print...

About handling a redirection in python

I am new to python and am trying to learn some new modules. Fortunately or unfortunately, I picked up the urllib2 module and started using it with one URL that's causing me problems. To begin...

The true purpose of init when it comes to class inheritance in Python

As the title suggests, I am struggling to understand the true purpose of the init constructor in Python and specifically when we create a class that inherits from another (parent). Having gone...

the reason: python string assignments accidentally change '\b' into '\x08' and '\a' into '\x07', why Python did this?

Had two answers and some comments, mentioned another question, but all had not provided REASON, why Python did this changes? such as '/b' is '/x08' is just the result, but why? Cheers. I try to...

Using the UserDict module of python

I am learning python from the book diveintopython . Before asking this question, I have consulted the answers given here and read the documentation given here, but they don't clarify exactly what...

Most pythonic way to declare inner functions

I'm writing an program where im using two main functions however those both functions uses same inner functions. I'm wondering how I should write them in most pythonic way? My point is to hide...