python-3.3

python: Is there a downside to using faulthandler?

python: Is there a downside to using faulthandler? Question: Python 3.3 includes a module named faulthandler that displays helpful traceback information if a segfault occurs. (For Python versions prior to 3.3, the module can be obtained from PyPI.) The module is not enabled by default. It is enabled like this: import faulthandler faulthandler.enable() This feature …

Total answers: 1

Format time string in Python 3.3

Format time string in Python 3.3 Question: I am trying to get current local time as a string in the format: year-month-day hour:mins:seconds. Which I will use for logging. By my reading of the documentation I can do this by: import time ‘{0:%Y-%m-%d %H:%M:%S}’.format(time.localtime()) However I get the error: Traceback (most recent call last): File …

Total answers: 3

whats the difference between python 3.3 and 3.3m

whats the difference between python 3.3 and 3.3m Question: What’s the difference between python 3.3 and 3.3m I’m using Ubuntu 13.04 Raring and on my system I have python2.7 and python3.3 (I know the differences between 2 and 3) But I also have installed python3.3m (and it’s not a symlink to 3.3). So what does …

Total answers: 2

Printing On a Single Line with A While Loop?

Printing On a Single Line with A While Loop? Question: I have an issue I have been trying to overcome for sometime. Firstly, here is my code: quote = input(“Enter a Sentence: “) a = len(quote) counter = 0 counter1 = 0 reverse = len(quote)-1 print(“The Length of the sentence is”,a,”characters long!”) for x in …

Total answers: 4

How to use 2to3 properly for python?

How to use 2to3 properly for python? Question: I have some code in python 2.7 and I want to convert it all into python 3.3 code. I know 2to3 can be used but I am not sure exactly how to use it. Asked By: GhostFrag1 || Source Answers: Install the following module which adds the …

Total answers: 9

How to install pip for Python 3 on Mac OS X?

How to install pip for Python 3 on Mac OS X? Question: OS X (Mavericks) has Python 2.7 stock installed. But I do all my own personal Python stuff with 3.3. I just flushed my 3.3.2 install and installed the new 3.3.3. So I need to install pyserial again. I can do it the way …

Total answers: 16

Using the crypt module in Windows?

Using the crypt module in Windows? Question: In IDLE and Python version 3.3.2, I try and call the python module like so: hash2 = crypt(word, salt) I import it at the top of my program like so: from crypt import * The result I get is the following: Traceback (most recent call last): File “C:noneofyourbusinessadams.py”, …

Total answers: 5

Getting certificate chain with Python 3.3 SSL module

Getting certificate chain with Python 3.3 SSL module Question: I can get the standard certificate information for an SSL connection in Python 3.3 via the getpeercert() method on the SSL socket. However, it doesn’t seem to provide the chain like OpenSSL’s “s_client” tool does. Is there some way I can get this so that I …

Total answers: 4

Import arbitrary python source file. (Python 3.3+)

Import arbitrary python source file. (Python 3.3+) Question: How can I import an arbitrary python source file (whose filename could contain any characters, and does not always ends with .py) in Python 3.3+? I used imp.load_module as follows: >>> import imp >>> path = ‘/tmp/a-b.txt’ >>> with open(path, ‘U’) as f: … mod = imp.load_module(‘a_b’, …

Total answers: 5

Random word generator- Python

Random word generator- Python Question: So i’m basically working on a project where the computer takes a word from a list of words and jumbles it up for the user. there’s only one problem: I don’t want to keep having to write tons of words in the list, so i’m wondering if there’s a way …

Total answers: 6