¡@

Home 

python Programming Glossary: collections.namedtuple

Python hashable dicts

http://stackoverflow.com/questions/1151658/python-hashable-dicts

standard library provides approximately what i'd need collections.namedtuple has a very different syntax but can be used as a key. continuing..

How to solve the “Mastermind” guessing game?

http://stackoverflow.com/questions/1185634/how-to-solve-the-mastermind-guessing-game

found output a little clearer if I used a namedtuple Pegs collections.namedtuple 'Pegs' 'black white' def mastermindScore g1 g2 matching len.. using two more namedtuples again for clarity of code. Node collections.namedtuple 'Node' 'decision branches' Branch collections.namedtuple 'Branch'.. collections.namedtuple 'Node' 'decision branches' Branch collections.namedtuple 'Branch' 'result subtree' def lazySolutionTree G V score endstates..

Dictionary vs Object - which is more efficient and why?

http://stackoverflow.com/questions/1336791/dictionary-vs-object-which-is-more-efficient-and-why

test_namedtuple.py supported in 2.6 import collections Obj collections.namedtuple 'Obj' 'i l' all for i in range 1000000 all i Obj i Run benchmark..

Fast Way to slice image into overlapping patches and merge patches to image

http://stackoverflow.com/questions/16774148/fast-way-to-slice-image-into-overlapping-patches-and-merge-patches-to-image

1 iRow np.reshape indPatch iRow np.newaxis sB iRow 1 pInd collections.namedtuple pInd.patch2img indPatch2Img pInd.img2patch indImg2Patch return..

Curve fitting in Scipy with 3d data and parameters

http://stackoverflow.com/questions/17934198/curve-fitting-in-scipy-with-3d-data-and-parameters

of width 0.3 with centers at 0.65 0.95 ... 3.05 3.35 Param collections.namedtuple 'Param' 'rsp0 rsp1 rsq0 rsq1 rsq2 rmp0 rmp1 rmq0 rmq1 rmq2 rs..

what would be a frozen dict?

http://stackoverflow.com/questions/2703599/what-would-be-a-frozen-dict

hashable dict. I guess it could be something like collections.namedtuple but namedtuple is more like a frozenkeys dict an half frozen..

How to delete files with a Python script from a FTP server which are older than 7 days?

http://stackoverflow.com/questions/2867217/how-to-delete-files-with-a-python-script-from-a-ftp-server-which-are-older-than

2.6 import sys os time ftplib import collections FTPDir collections.namedtuple FTPDir name size mtime tree FTPFile collections.namedtuple FTPFile.. collections.namedtuple FTPDir name size mtime tree FTPFile collections.namedtuple FTPFile name size mtime class FTPDirectory object def __init__..

How do you return multiple values in Python?

http://stackoverflow.com/questions/354883/how-do-you-return-multiple-values-in-python

for a similar builtin example. import collections point collections.namedtuple 'Point' 'x' 'y' p point 1 y 2 p.x p.y 1 2 p 0 p 1 1 2 share..

How to make an immutable object in Python?

http://stackoverflow.com/questions/4828080/how-to-make-an-immutable-object-in-python

get the same behaviour as your original code is Immutable collections.namedtuple Immutable a b It does not solve the problem that attributes..

Is it pythonic for a function to return multiple values?

http://stackoverflow.com/questions/61605/is-it-pythonic-for-a-function-to-return-multiple-values

tuples instead of plain tuples. import collections Point collections.namedtuple 'Point' 'x y' x y Point 0 1 p Point x y x y p 0 1 Point x 0..

SciPy LeastSq Goodness of Fit Estimator

http://stackoverflow.com/questions/7588371/scipy-leastsq-goodness-of-fit-estimator

y0 return y def residuals p x y return y sigmoid p x Param collections.namedtuple 'Param' 'x0 y0 c k' p_guess Param x0 600 y0 200 c 100 k 0.01..