FAQ

# Python>python-list>April 2014

## 160 discussions - 1,285 posts

• 108

#### Why Python 3?

Hello Everyone, So I've been working with Python for a while and I'm starting to take on more and more serious projects with it. I've been reading a lot about Python 2 vs Python 3 and the community ...
 Anthony PapillionApr 19, 2014 at 3:28 amMay 8, 2014 at 6:04 am
• 104

Hello, I've been using threading library to run some experiments parallel. There is no message passing between my threads but still it messes up somehow. The results are different than running it ...
 Onder HazarogluApr 7, 2014 at 2:54 amApr 11, 2014 at 7:27 pm
• 57

#### Significant digits in a float?

I'm using Python 2.7 I have a bunch of floating point values. For example, here's a few (printed as reprs): 38.0 41.2586 40.75280000000001 49.25 33.795199999999994 36.837199999999996 34.1489 45.5 ...
 Roy SmithApr 28, 2014 at 4:00 pmMay 8, 2014 at 7:58 pm
• 53

#### Martijn Faassen: The Call of Python 2.8

http://blog.startifact.com/posts/the-call-of-python-28.html so in response to the last line, who *IS* going to do all of the required work? -- My fellow Pythonistas, ask not what our language can do ...
 Mark LawrenceApr 14, 2014 at 12:56 pmApr 16, 2014 at 8:42 am
• 51

#### Unicode 7

Let see how Python is ready for the next Unicode version (Unicode 7.0.0.Beta). [1.4027834829454946, 1.38714224331963, 1.3822586635296261] [5.462776291480395, 5.4479432055423445, 5.447874284053398] ...
 WxjmfauthApr 29, 2014 at 5:37 pmMay 3, 2014 at 2:19 am
• 47

#### Teaching python to non-programmers

Dear List Recently I was requested to teach python to a group of students of GIS (Geographic Information Systems). Their knowledge of programming is zero. The objective is to enable them to write ...
 Lalitha Prasad KApr 10, 2014 at 3:54 pmApr 14, 2014 at 7:32 am
• 40

#### [OFF-TOPIC] How do I find a mentor when no one I work with knows what they are doing?

I'm sure there will be a substantial amount of arrogance perceived from this question, but frankly I don't think that I have anything to learn from my co-workers, which saddens me because I really ...
 James BrewerApr 8, 2014 at 7:07 amApr 13, 2014 at 2:04 pm
• 40

#### python obfuscate

Hi all, Does python has any good obfuscate? Currently our company wanna release one product developed by python to our customer. But dont's wanna others see the py code. I googled for a while but ...
 WesleyApr 11, 2014 at 1:29 amApr 13, 2014 at 4:58 am
• 29

#### Yet Another Switch-Case Syntax Proposal

Hi all. I would proposeto you all a switch-case syntax for Python. I already read PEP 3103 and I'm not completely satisfied by any of the proposed solutions. This is my proposal: switch_stmt ::= ...
 Lucas MalorApr 2, 2014 at 2:53 pmApr 10, 2014 at 9:15 pm
• 26

#### Code style query: multiple assignments in if/elif tree

Personally, I use the sequence of one-line comments. But, hey, Guido [1] himself likes the triple-quoted string as comment feature [2], so feel free to use it yourself if you like. -- ~Ethan~ [1] ...
 Ethan FurmanApr 1, 2014 at 12:30 amApr 1, 2014 at 8:56 am
• 23

#### Keeping track of things with dictionaries

I frequently use this pattern to keep track of incoming data (for example, to sum up sales of a specific brand): ===================================== # read a brand record from a db ... # keep track ...
 Giuliano BertolettiApr 6, 2014 at 7:44 amApr 9, 2014 at 9:51 am
• 15

#### Strange syntax error, occurs only when script is executed directly

I am workin on a solaris 11 machine. The python version is 2.7.6 path to python is /opt/local/bin/python. These are the 15 first lines of the script: #! /opt/local/bin/python class vslice(object) ...
 Antoon PardonApr 22, 2014 at 10:29 amApr 23, 2014 at 1:42 am
• 15

#### Language summit notes

Today in Montreal Canada, there was a Language Summit to discuss the future of Python. Some highlights: PyPy is only three bug fixes away from shipping support for Python 3.2! Guido confirms that ...
 Steven D'ApranoApr 10, 2014 at 12:07 pmApr 14, 2014 at 8:03 am
• 14

#### Moving to an OOP model from an classically imperitive one

Hello, I am currently writting a program called subuser(subuser.org), which is written as classically imperative code. Subuser is, essentially, a package manager. It installs and updates programs ...
 Tim ThelionApr 23, 2014 at 8:57 pmApr 25, 2014 at 5:21 pm
• 14

#### Python, Linux, and the setuid bit

For anyone in the unenviable position of needing [1] to run Python scripts with the setuid bit on, there is an suid-python wrapper [2] that makes this possible. When I compiled it I was given a ...
 Ethan FurmanApr 14, 2014 at 9:13 pmApr 15, 2014 at 3:05 pm
• 13

#### Simple question

Hi, all. I've just started to learn Python (I'm reading Mark Lutz's 'Learning Python' from O'Reilly) & I'm confused as to this part: ' 0.1 + 0.1 + 0.1 - 0.3 5.55111.....' Using 'import Decimal' you ...
 Phil DobbinApr 15, 2014 at 6:18 pmApr 16, 2014 at 6:03 am
• 13

#### Unicode Chars in Windows Path

Hi All, I'm in need of some encoding/decoding help for a situation for a Windows Path that contains Unicode characters in it. ---- CODE ---- import os.path import codecs import sys All_Tests = ...
 SteveApr 2, 2014 at 11:27 pmApr 4, 2014 at 7:07 am
• 12

#### Help with changes in traceback stack from Python 2.7 to Python 3.x

I wrote the following code that works in Python 2.7 that takes the variables passed to the function into a dictionary. The following call: strA = 'a' intA = 1 dctA = makeDict(strA, intA) produces the ...
 Andrew KonstantarasApr 26, 2014 at 5:50 amApr 28, 2014 at 10:41 pm
• 11

#### Proper deletion of selected items during map iteration in for loop

What is the proper way to delete selected items during iteration of a map? What I want to do is: for (k, v) in m.items(): if f(k): # do some processing of v and save result elsewhere del m[k] But ...
 Charles HixsonApr 25, 2014 at 5:53 pmApr 28, 2014 at 10:48 am
• 11

#### Mutable objects inside tuples - good or bad?

I find this programming pattern to be useful... but can it cause problems? Python 3.3.2+ (default, Feb 28 2014, 00:52:16) [GCC 4.8.1] on linux Type "help", "copyright", "credits" or "license" for ...
 John LadaskyApr 6, 2014 at 6:53 amApr 8, 2014 at 2:53 am
• 11

#### How can I parse this correctly?

Hello Everyone, I'm working with historical earthquake data and I have a tab delimited file. I'm using the csv module with the \t delimiter to denote it's tab separated and it's working fine. I've ...
 Anthony PapillionApr 6, 2014 at 3:52 amApr 6, 2014 at 12:42 pm
• 11

#### converting strings to hex

Hello, I am taking a cryptography class and am having a tough time with an assignment similar to this. Given plain text message 1 and cipher 1 compute cipher 2 for message 2 Work flow will be: - ...
 Dave emApr 4, 2014 at 2:10 amApr 4, 2014 at 11:00 pm
• 10

#### how to split this kind of text into sections

I have a long text, which should be splitted into some sections, where all sections have a pattern like following with different KEY. And the /n/r can not be used to split I don't know whether this ...
 OysterApr 25, 2014 at 1:07 pmApr 27, 2014 at 2:49 am
• 10

#### MemoryError in data conversion

The code attached below produces in one of the two IMHO similar cases (excepting the sizes of the lists involved) MemoryError. Could experts kindly tell why that's so and whether there is any ...
 Mok-Kong ShenApr 14, 2014 at 1:46 amApr 15, 2014 at 12:08 pm
• 10

#### Unpacking U-Boot image file

How to extract files from U-Boot image file, LZMA-compressed? Is there a Python script that can do this properly?
 TrewioApr 9, 2014 at 4:06 pmApr 11, 2014 at 4:02 pm
• 9

#### module and namespace

If I use the interpreter I get: Python 3.3.5 (default, Apr 12 2014, 23:34:20) [GCC 4.6.3] on linux Type "help", "copyright", "credits" or "license" for more information. <module 'mptt' from ...
 Egon FrerichApr 16, 2014 at 10:38 amApr 19, 2014 at 2:55 pm
• 9

#### Retrieve item deep in dict tree?

I have a big hairy data structure which is a tree of nested dicts. I have a sequence of strings which represents a path through the tree. Different leaves in the tree will be at different depths ...
 Roy SmithApr 2, 2014 at 5:58 pmApr 3, 2014 at 4:46 pm
• 8

hi all, i have simple programming task: [quot] If we list all the natural numbers below 10 that are multiples of 3 or 5, we get 3, 5, 6 and 9. The sum of these multiples is 23. Find the sum of all ...
 Ivan IvanivichApr 20, 2014 at 6:43 pmApr 21, 2014 at 1:43 pm
• 8

#### Python streaming media server

Hi, Anyone knows open source streaming media server written by Python? I am trying to setup a streaming media server in python, wanna find an existing one and have a look. Thanks. Wesley
 WesleyApr 5, 2014 at 10:11 amApr 7, 2014 at 3:32 am
• 8

#### Two Questions about Python on Windows

Normally my Python development is done on FreeBSD and Linux. I know that on *ix I simply have to make foo.py executable (the shebang line is present, of course) to make it runnable. For my son's ...
 Walter HurryApr 3, 2014 at 5:06 pmApr 5, 2014 at 9:57 pm
• 8

#### Default mutable parameters in functions

Hi all, So I was reading about default values for functions and spied this: Important warning: The default value is evaluated only once. This makes a difference when the default is a mutable object ...
 FbicknelApr 3, 2014 at 6:49 pmApr 5, 2014 at 2:21 am
• 7

#### MacOS 10.9.2: threading error using python.org 2.7.6 distribution

I've run into a threading error in some code when I run it on MacOS that works flawlessly on a *BSD system running the same version of python. I'm running the python 2.7.6 for MacOS distribution from ...
 Matthew PounsettApr 25, 2014 at 1:43 pmApr 28, 2014 at 11:00 pm
• 7

#### possible bug in re expression?

Whilst translating some javascript code I find that this A=re.compile('.{1,+3}').findall(p) doesn't give any error, but doesn't manage to find the strings in p that I want len(A)== 0, the correct ...
 Robin BeckerApr 25, 2014 at 4:30 pmApr 28, 2014 at 1:06 pm
• 7

#### object().__dict__

There are some basics about Python objects I don't understand. Consider this snippet: ... ['__class__', '__delattr__', '__dict__', '__dir__', '__doc__', '__eq__', '__format__', '__ge__', ...
 Pavel VolkovApr 23, 2014 at 5:39 amApr 23, 2014 at 8:25 pm
• 7

#### which book to read next??

Hi, I have read the book 'a byte of python' and now I want to read another book. But I just get confused about which one to read next. There is a book list below? 1, pro python 2, python algorithms ...
 LeeApr 21, 2014 at 2:13 pmApr 21, 2014 at 9:32 pm
• 7

#### TeX $\times$ symbol not working in matplotlib?

Hi, I am trying to understand how to get the TeX "\times" symbol to work. It is in the title() string in the code I pasted in. The "\circ" symbol seems fine, by comparison. "\times" ends up as "imes" ...
 GwhiteApr 18, 2014 at 4:18 pmApr 19, 2014 at 2:26 pm
• 7

#### random.seed question (not reproducing same sequence)

Hi guys, (Python 2.7, Windows 7 64-bit) Here's a bit of code stress-testing a method addUpdate_special_to_cart. The test adds and updates random "specials" (multiple products bundled at an ...
 Nick MellorApr 15, 2014 at 3:54 pmApr 16, 2014 at 4:32 am
• 7

#### Learner looking for assistance

Hi All I am probably doing something wrong but don't know what Any help would great Code below the calc_total does not return a estimated_total_weight if add the estimated_total_weight the rest of ...
 Anthony SmithApr 14, 2014 at 7:43 amApr 15, 2014 at 8:44 am
• 7

#### imaplib: how to specify SSL/TLS protocol version?

Connecting to Exchange server fails like this: File "/usr/lib64/python2.7/imaplib.py", line 1148, in __init__ IMAP4.__init__(self, host, port) SSLError: [Errno 1] _ssl.c:1419: error:1408F10B:SSL ...
 Grant EdwardsApr 9, 2014 at 8:12 pmApr 10, 2014 at 7:57 pm
• 7

#### "Latching" variables in function

I've probably used the wrong term - I'm thinking of what I do when writing PLC code - so I can't find how to do this in my reference books. This is part of a project I'm working on with a Raspberry ...
 GrawburgApr 8, 2014 at 8:09 pmApr 9, 2014 at 3:43 pm
• 6

#### Sorting list alphabetically

Hi, ALL, I need to perform a subj. Looking at the Google I found following thread with explanation: http://stackoverflow.com/questions/36139/how-do-i-sort-a-list-of-strings-in-python However, doing ...
 Igor KorotApr 27, 2014 at 9:38 amApr 29, 2014 at 6:02 am
• 6

#### Soap list and soap users on this list

Seems the soap list is a little quiet and the moderator is mia regardless. Are there many soap users on this list familiar with Spyne or does anyone know the most optimal place to post such ...
 Joseph L. CasaleApr 17, 2014 at 5:58 pmApr 28, 2014 at 9:59 pm
• 6

#### how to make ["a","b",["c","d"],"e"] into ['a', 'b', 'c', 'd', 'e'] ?

['c', 'd'] ['a', 'b', 'c', ['c', 'd'], 'e'] ['a', 'b', 'c', 'd', ['c', 'd'], 'e'] ['a', 'b', 'c', 'd', 'e'] maybe there is a more smart way to do. An HTML attachment was scrubbed... URL ...
 Length powerApr 10, 2014 at 5:14 amApr 10, 2014 at 5:36 pm
• 6

#### Plotting the integer-and-fraction remainder of a function value modulo 360

How can I get Python to represent a value of a function in degrees, i.e., with values between 0 and 360, by taking the (non-integer) function expression mod 360? That is, I have a function with ...
 Kim PlofkerApr 10, 2014 at 4:32 amApr 10, 2014 at 7:25 am
• 6

#### Python to be replaced by the new language called Cookie !

April Fools =D Bye, Skybuck =D
 Skybuck FlyingApr 1, 2014 at 8:20 amApr 2, 2014 at 2:20 pm
• 5

#### how to build and install multiple micro-level major.minor versions of Python

I have built and installed Python on AIX as well as installed a stack of Python tools. The version I installed is 2.7.2. Everything is working fine but I want to install Python 2.7.6 and the tool ...
 Brent S. Elmer Ph.D.Apr 29, 2014 at 3:28 pmApr 29, 2014 at 7:57 pm
• 5

#### why i have the output of [None, None, None]

['', 'x1', 'x2', 'x3', ' '] ok ok ok [None, None, None] i understand there are three 'ok' in the output,but why i have the output of [None, None, None] An HTML attachment was scrubbed... URL ...
 Length powerApr 10, 2014 at 1:54 pmApr 10, 2014 at 6:00 pm
• 5

#### change spacing to two instead of four with pep8 or flake8?

Hi, In Pylint you can change the spacing multiplier from 4 spaces to two in its pylintrc, but for the life of me I cannot find a way to do this with the flake8 / pep8 utilities. I want to avoid ...
 DennisApr 8, 2014 at 3:06 amApr 8, 2014 at 2:06 pm
• 4

#### Convert numpy array to single number

I have a numpy array consisting of 1s and zeros for representing binary numbers: e.g. array([ 1., 0., 1., 0.]) I wish the array to be in the form 1010, so it can be manipulated. I do not want to use ...
 Mboyd02255Apr 28, 2014 at 1:04 pmMay 1, 2014 at 1:26 pm
• 4

#### pyodbc connect string

I am having a problem building a connect string for pyodbc. It works when everything is hard coded, but if I build the connect string it fails. This works: pyodbc.connect('DRIVER=FreeTDS;' ...
 Larry MartellApr 30, 2014 at 12:57 amApr 30, 2014 at 1:25 am