Re: (test) ? a:b

2014-10-25 Thread Dan Stromberg
On Sat, Oct 25, 2014 at 1:45 PM, Ben Finney wrote: > Steven D'Aprano writes: >> title = ('Mr', 'Ms')[person.sex == 'F'] >> >> which should be clear to anyone who understands indexing in Python and >> that True == 1 and False == 0. > > I consider it an accident of history, and one which should not

Re: Status of side-effecting functions in python

2014-10-26 Thread Dan Sommers
d unlikely now. A simple success flag was sufficient; as functions grew, often did their failure modes. Dan -- https://mail.python.org/mailman/listinfo/python-list

id == vs is

2014-10-26 Thread Dan Stromberg
Are the following two expressions the same? x is y Id(x) == id(y) ? I ported some Java code to Python, and it was using Java's idea of equality (via ==) in some places. Right now, I have a suite of unit tests working using the second expression above, but I'm thinking about switching to the fi

Re: checking whether a string is text or binary

2014-10-28 Thread Dan Stromberg
On Tue, Oct 28, 2014 at 3:21 PM, Rick Dooling wrote: > I tried to convert the code using 2to3 and it broke. > > The error I get when using Python 3 is on this line: > > _null_trans = string.maketrans("", "") > > and the error reads > > AttributeError: 'module' object has no attribute 'maketrans' >

Re: Classes

2014-11-02 Thread Dan Sommers
On Mon, 03 Nov 2014 03:12:32 +, Denis McMahon wrote: > Quadrilateral > Parallelogram > Square > Rectangle > Rhombus > Diamond (4 sides eq) > Trapezoid > Arrowhead What's the difference between a Diamond and a Rhombus? > Is an arrowhead a trapez

Re: [OFF-TOPIC] It is true that is impossible write in binary code, the lowest level of programming that you can write is in hex code?

2014-11-05 Thread Dan Stromberg
On Tue, Nov 4, 2014 at 10:39 PM, Cameron Simpson wrote: > Bah! He asked if there were lower levels than binary. Ergo: chip design! > (And microcode, the intermediate layer. Or one of the layers, depending > where you draw the line.) Should we stop before we reach the quantum foam of > spacetime?

Re: I love assert

2014-11-11 Thread Dan Stromberg
On Tue, Nov 11, 2014 at 11:40 AM, Peter Cacioppi wrote: > I get the impression that most Pythonistas aren't as habituated with assert > statements as I am. Is that just a misimpression on my part? If not, is there > a good reason to assert less with Python than other languages? > > As far as I c

Re: Efficient Threading

2014-11-15 Thread Dan Stromberg
On Fri, Nov 14, 2014 at 10:42 AM, Empty Account wrote: > Hi, > > I am thinking about writing a load test tool in Python, so I am interested > in how I can create the most concurrent threads/processes with the fewest OS > resources. I would imagine that I/O would need to be non-blocking. > > There

Re: fileno() not supported in Python 3.1

2014-11-15 Thread Dan Stromberg
On Thu, Nov 13, 2014 at 3:48 PM, wrote: > import sys > for stream in (sys.stdin, sys.stdout, sys.stderr): >print(stream.fileno()) > > > io.UnsupportedOperation: fileno > > Is there a workaround? > -- > https://mail.python.org/mailman/listinfo/python-list Works for me, although it's a

Re: import os

2014-11-16 Thread Dan Stromberg
On Sun, Nov 16, 2014 at 5:10 PM, Abdul Abdul wrote: > Thanks for your reply. Yes, I came across this page, but didn't understand > what is meant by the operating system dependent functionality. What does > that mean? Is importing that module that serious? The os module has mostly lower level OS i

Re: Using map()

2014-11-16 Thread Dan Stromberg
On Sun, Nov 16, 2014 at 4:09 PM, Steven D'Aprano wrote: > Pavel Volkov wrote: > >> I checked my modules with pylint and saw the following warning: >> >> W: 25,29: Used builtin function 'map' (bad-builtin) >> >> Why is the use of map() discouraged? >> It' such a useful thing. > > That's a bug in py

Re: Different behaviour in list comps and generator expressions

2014-11-17 Thread Dan Stromberg
On Mon, Nov 17, 2014 at 3:30 PM, Steven D'Aprano wrote: >> The following list comprehension and generator expression are almost, but >> not quite, the same: >> >> [expr for x in iterable] >> >> list(expr for x in iterable) >> >> >> The difference is in the handling of StopIteration raised inside t

Re: Recurring Task

2014-11-23 Thread Dan Stromberg
On Sun, Nov 23, 2014 at 7:23 AM, wrote: > Hi All > Looking for some advice. I'm creating a small netwok poller and wondered what > people recommend to use? Will be polling up to 100 hosts every ten reconds or > so > > Options I can see > > Home grown using worker threads with Queue and dispatch

Re: Recurring Task

2014-11-23 Thread Dan Stromberg
On Sun, Nov 23, 2014 at 10:35 AM, Dennis Lee Bieber wrote: > On Sun, 23 Nov 2014 07:23:43 -0800 (PST), t...@timothyarnold.co.uk declaimed > the following: > >>Hi All >>Looking for some advice. I'm creating a small netwok poller and wondered what >>people recommend to use? Will be polling up to 10

Re: "**" in python

2014-11-23 Thread Dan Stromberg
On Sun, Nov 23, 2014 at 5:00 PM, Cameron Simpson wrote: > On 23Nov2014 18:43, Tim Chase wrote: >> >> On 2014-11-24 01:33, Abdul Abdul wrote: >>> >>> Wxy**2 >>> >>> What do ** mean here? >> >> >> "to the power of", so your code squares the value of "Wxy", or "Wxy * >> Wxy" >> >> https://docs.pytho

Re: I have no class

2014-11-24 Thread Dan Sommers
(one common convenstion is that all member variables begin with "m_"). IMO, that's a concession that all that implicitness and convenience just causes confusion. In Python, the names of all instance attributes begin with "self." Dan -- https://mail.python.org/mailman/listinfo/python-list

Re: Comprehension with two variables - explanation needed

2014-11-24 Thread Dan Stromberg
On Sun, Nov 23, 2014 at 8:42 PM, Steven D'Aprano wrote: > On Sun, 23 Nov 2014 08:45:39 -0800, Rustom Mody wrote: >> First a one-line solution in haskell >> >> sieve (p:xs) =p:sieve [x | x <- xs, x `mod` p /= 0] > > Don't use that! That is a horribly inefficient way to generate primes. > > Ma

Python 2.x vs 3.x survey - new owner?

2014-12-02 Thread Dan Stromberg
Last year in late December, I did a brief, 9 question survey of 2.x vs 3.x usage. I like the think the results were interesting, but I don't have the spare cash to do it again this year. I probably shouldn't have done it last year. ^_^ Is anyone interested in taking over the survey? It's on Su

Re: Python, C++ interaction

2014-12-03 Thread Dan Stromberg
On Wed, Dec 3, 2014 at 12:29 AM, Michael Kreim wrote: > Hi, > I did some googleing on extending Python by C++ code but I did not find > something that satisfies me. I gave SWIG a try, but several webpages > disadvised me of using it. Also my small experiments did not work. Now, I > read about cty

Re: dict turn to list unexpected at runtime???

2014-12-04 Thread Dan Sommers
] > for tmp_kind in kinds: > orderaddrtimes() The print statement runs twice because you're calling orderaddrtimes twice, once for "a" and once for "b." addrnum_dict becomes a list when you bind it to the return value from sorted on the first call to orderaddrtimes; you get the error on the second call. HTH, Dan -- https://mail.python.org/mailman/listinfo/python-list

Re: [Python-Dev] Python 2.x and 3.x use survey, 2014 edition

2014-12-11 Thread Dan Stromberg
On Thu, Dec 11, 2014 at 11:35 AM, Mark Roberts wrote: > I disagree. I know there's a huge focus on The Big Libraries (and wholesale > migration is all but impossible without them), but the long tail of > libraries is still incredibly important. It's like saying that migrating the > top 10 Perl lib

Re: How to make subprocess run for 60 sec?

2014-12-12 Thread Dan Stromberg
On Fri, Dec 12, 2014 at 12:48 AM, Robert Clove wrote: > Hi All, > > I have the following python script that runs. > I want is to run the subprocess to run for 60 sec and then send the SIGINT > signal to subprocess and write the output in file. > > #!/usr/bin/python > import os > import subprocess

Re: suggestions for VIN parsing

2014-12-25 Thread Dan Stromberg
On Thu, Dec 25, 2014 at 4:02 PM, Vincent Davis wrote: > I would like to parse the VIN, frame and engine numbers found on this page > (below). I don't really know any regex, I have looked a little at pyparsing. > I have some other similar numbers to. I am looking for suggestions, which > "tool" sho

Re: Logger not logging

2015-01-01 Thread Dan Sommers
uot;credits" or "license" for more information. >>>> import logging >>>> logger = logging.getLogger() >>>> logger.setLevel(logging.INFO) >>>> logger.info("hello") >>>> logger.warn("hello") > hello >&g

Re: Socket programming

2015-01-03 Thread Dan Stromberg
On Sat, Jan 3, 2015 at 3:43 AM, pramod gowda wrote: > Hi i am learning socket programming, This "works" on Linux Mint 17.1. Server: #!/usr/local/cpython-3.4/bin/python import socket server_socket = socket.socket() #server_name = '192.168.2.2' server_socket.setsockopt(socket.SOL_SOCKET, socket.

Re: surprise - byte in set

2015-01-03 Thread Dan Stromberg
On Sat, Jan 3, 2015 at 10:50 AM, patrick vrijlandt wrote: > Hello list, > > Let me first wish you all the best in 2015! > > Today I was trying to test for occurrence of a byte in a set ... In the last case, the set has integers in it. Try: b'b'[0] in set(b'abc') -- https://mail.python.org/mail

Re: Help with map python 2

2015-01-04 Thread Dan Stromberg
I'm partial to: #!/usr/local/cpython-3.4/bin/python def gen_series(top=None): ''' Generate the numbers from 2 to top, with alternating signs. If top is None, generate forever. If top is an integer, generate from 2 to top. ''' sign = 1 if top is None: number = 2

Re: If you were starting a project with XML datasource using python

2015-01-05 Thread Dan Stromberg
On Mon, Jan 5, 2015 at 3:54 AM, flebber wrote: > Hi > > I need some advice on managing data in the form of xml. I will have to > repeatedly import a small xml file but with many complex attributes. If I have a choice, I choose JSON over XML. If stuck with XML, I like xmltodict: https://pypi.pyt

Re: Generate jpg files using line length (pixels) and orientation (degrees)

2015-01-09 Thread Dan Sommers
> Unfortunately getting a new error. > > Traceback (most recent call last): > File "C:\Users\Owner\Desktop\Stimuli Generation\Coordinates\Generate_w > corr.py", line 68, in > makeimg(length, orientation) > File "C:\Users\Owner\Desktop\Stimuli Generation\Coordinates\Generate_w > corr.py

Re: PyWart: Poor Documentation Examples

2015-01-11 Thread Dan Sommers
; expresses "automaton accepts string s" > > Should that go into the doc?? Absolutely. :-) If the docs had explained that reduce is actually a finite state machine framework, then I wouldn't have written my such framework. > I'll leave that to somebody else whose

Re: DICOM to jpg

2015-01-11 Thread Dan Stromberg
On Sun, Jan 11, 2015 at 5:01 AM, Abdul Abdul wrote: > Hello, > > Is there a way to convert a DICOM file to an image using Python? > > Thanks. Does GDCM do what you need? http://gdcm.sourceforge.net/wiki/index.php/Main_Page -- https://mail.python.org/mailman/listinfo/python-list

Re: How can i use a dictionnary

2015-01-13 Thread Dan Sommers
data is not a Python dictionary, nor is it a JSON object. You > will probably need to code your own conversion function to make it a > Python dictionary. This looks like the str (or maybe it's the repr) of an object returned by the suds library. If so, then that object has appropriate attributes for accessing the data; please see the documentation. What happens when you print object.sName (assuming that your element is named "object")? HTH, Dan -- https://mail.python.org/mailman/listinfo/python-list

Re: Compiling multiple python scripts into an exe file

2015-01-14 Thread Dan Stromberg
On Tue, Jan 13, 2015 at 10:53 PM, dieter wrote: > no nein writes: > >> Basically, is it possible to compile multiple unrelated python scripts into >> a single exe file, so when execute it several python programs are run at >> once. > > These are two distinct problems: > > * for doing things

Re: lambdak: multi-line lambda implementation in native Python

2015-01-17 Thread Dan Sommers
but I have never described it quite so succinctly. > There was lot's of quiet swearing. "Quiet" is *not* one of my strong points. -- Dan -- https://mail.python.org/mailman/listinfo/python-list

Re: Concerning Dictionaries and += in Python 2.x

2015-01-19 Thread Dan Stromberg
On Mon, Jan 19, 2015 at 4:12 PM, Luke Tomaneng wrote: > I have been having a bit of trouble with the things mentioned in the title. I > have written the following script for a Codecademy course: > stock = { > "banana": 6, > "apple": 0, > "orange": 32, > "pear": 15 > } > > prices =

Re: Trees

2015-01-19 Thread Dan Stromberg
On Mon, Jan 19, 2015 at 2:06 PM, Zachary Gilmartin wrote: > Why aren't there trees in the python standard library? Trees are kind of specialized datastructures; no one type of tree solves all tree-related problems suitably well. I think probably the most common need for a tree is implementing a

Re: Trees

2015-01-19 Thread Dan Stromberg
On Mon, Jan 19, 2015 at 6:46 PM, Mark Lawrence wrote: > On 20/01/2015 00:49, Dan Stromberg wrote: >> >> On Mon, Jan 19, 2015 at 2:06 PM, Zachary Gilmartin >> wrote: >>> >>> Why aren't there trees in the python standard library? >> >> >

Re: Trees

2015-01-20 Thread Dan Stromberg
On Tue, Jan 20, 2015 at 5:22 PM, Joshua Landau wrote: > On 20 January 2015 at 04:21, Dan Stromberg wrote: >> On Mon, Jan 19, 2015 at 6:46 PM, Mark Lawrence >> wrote: >>> >>> I don't know if you've seen this http://kmike.ru/python-data-structures/ bu

Re: Check for running DHCP daemon?

2015-01-21 Thread Dan Stromberg
On Wed, Jan 21, 2015 at 3:06 PM, Jason Bailey wrote: > So I've got this python 3 script that needs to know if there is a running > DHCP daemon (ISC DHCP server) on the local system. Is there a clean way to > do this that (1) doesn't require me to do syscalls to local utilities (like > ps, top, etc

Benchmarking some modules - strange result

2015-01-24 Thread Dan Stromberg
Hi folks. I've been benchmarking some python modules that are mostly variations on the same theme. For simplicity, let's say I've been running the suite of performance tests within a single interpreter - so I test one module thoroughly, then move on to the next without exiting the interpreter. I

Re: Benchmarking some modules - strange result

2015-01-24 Thread Dan Stromberg
On Sat, Jan 24, 2015 at 6:24 PM, Chris Angelico wrote: > On Sun, Jan 25, 2015 at 1:11 PM, Dan Stromberg wrote: >> For simplicity, let's say I've been running the suite of performance >> tests within a single interpreter - so I test one module thoroughly, >> t

Re: Benchmarking some modules - strange result

2015-01-24 Thread Dan Stromberg
On Sat, Jan 24, 2015 at 6:37 PM, Chris Angelico wrote: > On Sun, Jan 25, 2015 at 1:36 PM, Dan Stromberg wrote: >> On Sat, Jan 24, 2015 at 6:24 PM, Chris Angelico wrote: >>> On Sun, Jan 25, 2015 at 1:11 PM, Dan Stromberg wrote: >>>> For simplicity, let's

Re: Benchmarking some modules - strange result

2015-01-25 Thread Dan Sommers
On Sun, 25 Jan 2015 13:24:40 +0100, Peter Otten wrote: > Dan Stromberg wrote: > >> I've been benchmarking some python modules that are mostly variations >> on the same theme. >> >> For simplicity, let's say I've been running the suite of performanc

Re: Python is DOOMED! Again!

2015-01-26 Thread Dan Sommers
didn't use the header files, what were they for? The compiler did use the header files, but only for functions' return types and other non-function-signature things (like macros and type definitions). Dan -- https://mail.python.org/mailman/listinfo/python-list

Re: What behavior would you expect?

2015-02-19 Thread Dan Sommers
Errors should never pass silently. In the face of ambiguity, refuse the temptation to guess. (Wow! I knew I could turn to the Zen for support, but I didn't realize just how much support I would get!) See also <http://en.wikipedia.org/wiki/Void_safety>. Dan -- https://mail.python.org/mailman/listinfo/python-list

Re: What behavior would you expect?

2015-02-19 Thread Dan Sommers
On Fri, 20 Feb 2015 16:16:50 +1100, Chris Angelico wrote: > On Fri, Feb 20, 2015 at 3:54 PM, Dan Sommers wrote: >> if there are no >> values to return, then return an empty collection. > > That one makes sense only if you were going to return a collection > anyway, thou

Re: What behavior would you expect?

2015-02-19 Thread Dan Sommers
On Thu, 19 Feb 2015 22:51:57 -0700, Jason Friedman wrote: >> >> I'd still advise using my_list.sort() rather than sorted(), as you >> don't need to retain the original. >> >> > Hmm. > > Trying to figure out what that looks like. > If I understand correctly, list.sort() returns None. > What would

Re: Python programming

2014-02-12 Thread Dan Sommers
On Wed, 12 Feb 2014 22:56:56 -0500, William Ray Wing wrote: > OK, and how many of you remember the original version of the > tongue-in-cheek essay "Real Programmers Don't Use Pascal" from the > back page of Datamation? And the April issue of Compubyte (or something like that) with a cover showing

Re: Turning an AST node / subnodes into something human-readable

2014-02-19 Thread Dan Goodman
or series of mathematical statements (no control conditions, loops, array notation, etc.), but it would be pretty easy to add those. It also puts too many parentheses in outputted expressions, e.g. 1+2+3 would come back as (1+2)+3, etc. Dan -- https://mail.python.org/mailman/listinfo/python-list

Re: exec and locals

2014-02-26 Thread Dan Sommers
On Thu, 27 Feb 2014 00:25:45 +, Steven D'Aprano wrote: > By the way, if anyone cares what my actual use-case is, I have a > function that needs to work under Python 2.4 through 3.4, and it uses > a with statement. With statements are not available in 2.4 (or 2.5, > unless you give a from __fut

Re: ANN: Python Job Board - Call for volunteers

2014-03-05 Thread Dan Stromberg
I hope this means there'll soon be an option to restrict ads seen by some form of postal code or phone area code (with telecommute hopefully being an optional wildcard). On Thu, Feb 27, 2014 at 6:59 AM, M.-A. Lemburg wrote: > [Please help spread the word by forwarding to other relevant mailing li

Re: Python programming

2014-03-05 Thread Dan Sommers
On Wed, 05 Mar 2014 20:19:56 -0800, Beowulf wrote: > Once you master one language it is easy to understand other ... Once you master one language, the next one is hard. After that, they get easier. -- https://mail.python.org/mailman/listinfo/python-list

Re: Assertions are bad, m'kay?

2014-03-07 Thread Dan Stromberg
On Fri, Mar 7, 2014 at 3:11 AM, Steven D'Aprano wrote: > > Assertions are not bad! They're just misunderstood and abused. > You should read this guy's blog post on when to use assert: > > http://import-that.dreamwidth.org/676.html Nice article. BTW, what about: if value >= 3: raise Asserti

Re: Balanced trees (was: Re: Tuples and immutability)

2014-03-08 Thread Dan Stromberg
On Sat, Mar 8, 2014 at 12:34 AM, Marko Rauhamaa wrote: > Ian Kelly : > >> I already mentioned this earlier in the thread, but a balanced binary >> tree might implement += as node insertion and then return a different >> object if the balancing causes the root node to change. > > True. > > Speaking

Re: Balanced trees

2014-03-08 Thread Dan Stromberg
On Sat, Mar 8, 2014 at 1:21 PM, Marko Rauhamaa wrote: > If I had to choose between a hash table and AVL (or RB) tree in the > standard library, it would definitely have to be the latter. It is more > generally usable, has fewer corner cases and probably has an equal > performance even in hash tabl

How is unicode implemented behind the scenes?

2014-03-08 Thread Dan Stromberg
OK, I know that Unicode data is stored in an encoding on disk. But how is it stored in RAM? I realize I shouldn't write code that depends on any relevant implementation details, but knowing some of the more common implementation options would probably help build an intuition for what's going on i

Re: How is unicode implemented behind the scenes?

2014-03-08 Thread Dan Sommers
n a PDP-11. See <http://www.catb.org/jargon/html/M/middle-endian.html>. But you knew that. ;-) Pedantic'ly yours, Dan -- https://mail.python.org/mailman/listinfo/python-list

Re: Balanced trees

2014-03-09 Thread Dan Stromberg
On Sun, Mar 9, 2014 at 1:27 AM, Marko Rauhamaa wrote: > Dan Stromberg : > >> On Sat, Mar 8, 2014 at 1:21 PM, Marko Rauhamaa wrote: >>> If I had to choose between a hash table and AVL (or RB) tree in the >>> standard library, it would definitely have to be the la

Re: Balanced trees

2014-03-09 Thread Dan Stromberg
On Sun, Mar 9, 2014 at 2:32 PM, Marko Rauhamaa wrote: > Dan Stromberg : > >> This is not just a detail: O(1) tends to be beat O(logn) pretty easily >> for large n. > > There is no O(1) hash table. http://stackoverflow.com/questions/2771368/can-hash-tables-really-be-o1 --

Re: Balanced trees

2014-03-09 Thread Dan Stromberg
On Sun, Mar 9, 2014 at 2:43 PM, Marko Rauhamaa wrote: > Dan Stromberg : > >> On Sun, Mar 9, 2014 at 2:32 PM, Marko Rauhamaa wrote: >>> There is no O(1) hash table. >> >> http://stackoverflow.com/questions/2771368/can-hash-tables-really-be-o1 > > Please elab

Re: Balanced trees

2014-03-10 Thread Dan Stromberg
On Mon, Mar 10, 2014 at 6:59 AM, Roy Smith wrote: > On the other hand, log n, for n = 1 million, is just 20. It's not hard > to imagine a hash function which costs 20x what a node traversal does, > in which case, the log n lookup is ahead for all n < 1 million. FWIW, both the hash table and the

Re: What does gc.get_objects() return?

2014-03-12 Thread Dan Stromberg
On Wed, Mar 12, 2014 at 12:34 PM, Jurko Gospodnetić wrote: > Hi all. > > I was wondering if someone could explain gc.get_objects() in a bit more > detail to me. > > Does it return a list of 'all objects known to Python'? Only some of them? > Which does it return? Which it does not? > > For

Re: Balanced trees

2014-03-13 Thread Dan Stromberg
On Thu, Mar 13, 2014 at 4:57 PM, Steven D'Aprano wrote: > On Mon, 10 Mar 2014 19:34:48 +0200, Marko Rauhamaa wrote: > >>> With a high level language like Python, using the provided hash table >>> will almost always cream any hand-built tree, no matter how >>> advantageous the data is to the tree.

Thread is somehow interfering with a while loop called after the thread is started

2014-03-16 Thread Dan McInerney
Coming back to this a long time later. I figured it out a little bit after I posted this. I wasn't aware that q.try_run() within the nfqueue module was a blocking call https://www.wzdftpd.net/redmine/projects/nfqueue-bindings/wiki/Examples. I'm not sure I was even aware of what it meant to be block

Re: Balanced trees

2014-03-18 Thread Dan Stromberg
On Mon, Mar 17, 2014 at 3:05 PM, Marko Rauhamaa wrote: > Joshua Landau : > >> The thing we really need is for the blist containers to become stdlib >> (but not to replace the current list implementation). > > Very interesting. Downloaded blist but didn't compile it yet. It *could* > be the missing

Re: Balanced trees

2014-03-18 Thread Dan Stromberg
On Tue, Mar 18, 2014 at 1:55 PM, Marko Rauhamaa wrote: > Dan Stromberg : > >> The results are at >> http://stromberg.dnsalias.org/~strombrg/python-tree-and-heap-comparison/2014-03/ > > Unfortunately I'm having a hard time understanding the results. > > The 50/5

Re: Balanced trees

2014-03-18 Thread Dan Stromberg
On Tue, Mar 18, 2014 at 3:03 PM, Marko Rauhamaa wrote: > Dan Stromberg : > For a proper comparison, I'd like a fixed, identical dataset and set of > operations run against each data structure. > > How about this test program: I used to do essentially this, but it was

Re: Controlling buffer alignment in file.read()

2014-03-18 Thread Dan Stromberg
On Tue, Mar 18, 2014 at 1:23 PM, Haralanov, Mitko wrote: > Hi all, > > I am using Python to read from a binary device file which requires that all > read sizes are in 8byte multiples and the user's buffer is 8byte aligned. > > I am currently using a file object and the file.read() method. However

Re: Balanced trees

2014-03-19 Thread Dan Stromberg
On Wed, Mar 19, 2014 at 7:16 PM, Rhodri James wrote: > 65536 is a suspiciously round number. You might want to double- > check that there's no 16-bit overflow causing something unexpected. It's because I'm using powers of 2. All the numbers in the report are round in hex. -- https://mail.pytho

Re: running python 2 vs 3

2014-03-20 Thread Dan Stromberg
On Thu, Mar 20, 2014 at 8:21 AM, Marko Rauhamaa wrote: > notbob : > >> I've installed python 3.3 on my Slack box, which by default comes with >> python 2.7. I know how to fire up the different IDLE environments, but >> how do I differentiate between the scripts? IOW, up till now, I've >> used .py

Re: Github down?

2014-03-21 Thread Dan Sommers
On Fri, 21 Mar 2014 14:51:54 +0100, Chris “Kwpolska” Warrick wrote: > (though GitHub could qualify as social media for some…) +1 QOTW -- https://mail.python.org/mailman/listinfo/python-list

Re: YADTR (Yet Another DateTime Rant)

2014-03-26 Thread Dan Sommers
; and for an event that occurred approximately 350 days ago, I might say "a little less than a year ago." Or did you forget to put the winky there, and I fell for it? 11 years, 2 months, 26 days, 9 hours, 3 minutes, 27.4 seconds'ly yours, Dan -- https://mail.python.org/mailman/listinfo/python-list

Re: Explanation of this Python language feature? [x for x in x for x in x] (to flatten a nested list)

2014-03-27 Thread Dan Stromberg
On Fri, Mar 21, 2014 at 1:42 PM, vasudevram wrote: > Can anyone - maybe one of the Python language core team, or someone with > knowledge of the internals of Python - can explain why this code works, and > whether the different occurrences of the name x in the expression, are in > different sco

Re: Python to be replaced by the new language called Cookie !

2014-04-01 Thread Dan Sommers
On Wed, 02 Apr 2014 02:19:38 +1100, Chris Angelico wrote: > These improvements are absolutely critical to the language, and should > be made in Python 2.5.7, 2.6.9, and 3.0.2. Anyone using a newer > version of Python is paying the price for early adoption, and should > back-level immediately to a

Re: Recording instruction/data flow for a python script/program.

2014-04-02 Thread Dan Stromberg
Google is your friend: https://docs.python.org/2/library/trace.html On Wed, Apr 2, 2014 at 4:02 PM, Skybuck Flying wrote: > Hello, > > Is there a way for a python script's execution to be capture in an > instruction/data flow log ? > > Since python is an interpreter this should be easy to do ? >

Re: how to insert the elements in a list properly?

2014-04-09 Thread Dan Sommers
27;, 'x3', 'x4'] > why i can't write it as: > > [words.append(words.pop(2)) for i in range(0,2)] > >>>> [words.append(words.pop(2)) for i in range(0,2)] > [None, None] You can, but you don't want to. At this point, even though the comprehension returned something else, words contains what you want. HTH, Dan -- https://mail.python.org/mailman/listinfo/python-list

Re: random.seed question (not reproducing same sequence)

2014-04-15 Thread Dan Stromberg
You could easily provide your own random number generator, if you don't need cryptographic-strength random numbers. EG: http://stromberg.dnsalias.org/svn/lcgrng/trunk/lcgrng.py That way you can be certain nothing else is using it. On Tue, Apr 15, 2014 at 8:54 AM, Nick Mellor wrote: > Hi guys,

Re: The “does Python have variables?” debate

2014-05-07 Thread Dan Sommers
of opening another can of worms, C's typing is sufficiently weak that it can be way more dynamic than many programmers want. It's this |↔| close to assembly language (ChrisA's example of the combination of dynamic typing and fixed locations). Dan -- https://mail.python.org/mailman/listinfo/python-list

Re: hashing strings to integers

2014-05-27 Thread Dan Sommers
On Tue, 27 May 2014 17:02:50 +, Steven D'Aprano wrote: > - rather than "zillions" of them, there are few enough of them that > the chances of an MD5 collision is insignificant; > (Any MD5 collision is going to play havoc with your strategy of > using hashes as a proxy for the real string

[OT] Re: Is MVC Design Pattern good enough?

2014-06-01 Thread Dan Sommers
which usually translates to "persistence") from your business logic, then that's what it means. HTH, Dan -- https://mail.python.org/mailman/listinfo/python-list

Re: new to While statements

2013-08-06 Thread Dan Sommers
you see it, but way more informative than the other way to the next one who comes along and reads it. -- Dan -- http://mail.python.org/mailman/listinfo/python-list

Re: new to While statements

2013-08-06 Thread Dan Sommers
On Tue, 06 Aug 2013 22:42:42 -0700, snakeinmyboot wrote: > I wish I understood half of what you posted Dan. Time to hit the books So think about the "while" statement: it takes an expression (the part before the colon) and a suite (the part after the colon and before the next sta

pydoc vs. non-def'd methods

2013-08-21 Thread Dan Sommers
help(Spam1.ham). So is there a clean way to define SpamN such that help(SpamN), help(SpamN.ham), and help(SpamN.eggs) all do the Right Thing, and the symmetry of ham and eggs is perfectly obvious to the most casual observer? Thanks, Dan -- http://mail.python.org/mailman/listinfo/python-list

Re: pydoc vs. non-def'd methods

2013-08-22 Thread Dan Sommers
On Thu, 22 Aug 2013 06:39:48 +, Steven D'Aprano wrote: > On Thu, 22 Aug 2013 05:13:03 +0000, Dan Sommers wrote: >> class Spam1: >> >> def eggs(self): >> '''Return the Meaning of Life.''' >> return 42 >

Re: user interfaces python3.x

2013-09-02 Thread Dan Sommers
And talking, becuase sometimes, I have something to say, too. With all due respect, if I spent 99% of my programming time writing, I'd be a pretty lousy programmer! ;-) That said, most of the best programmers I know (or have known) have excellent written communication skills. -- Dan --

Re: Database engine bindings for Python (was: Database statements via python but database left intact)

2013-10-05 Thread Dan Sommers
opg worked with Python3, I tried pg8000, and I could access my local databases, but I never got further than that. - Dan [0] http://wiki.postgresql.org/wiki/Python -- https://mail.python.org/mailman/listinfo/python-list

Re: using smtp in python

2013-10-22 Thread Dan Stromberg
On Tue, Oct 22, 2013 at 11:00 AM, wrote: > I'm trying to send an email using python. The mail content is taken from > file and subject of the mail is name of the file. The program is invoked as > ./mailclient.py -f -d > -i -s > . > How to i use server ip address and the mail id to send th

Re: Will Python 3.x ever become the actual standard?

2013-10-23 Thread Dan Stromberg
On Wed, Oct 23, 2013 at 4:57 AM, wrote: > I am starting to have doubts as to whether Python 3.x will ever be > actually adopted by the Python community at large as their standard. Years > have passed, and a LARGE number of Python programmers has not even bothered > learning version 3.x. Why am I

Re: Python Front-end to GCC

2013-10-25 Thread Dan Sommers
tain static (in the technical sense) values were initialized to 0, or NULL, or something like that, on program startup, before any user-level code executed. Dan -- https://mail.python.org/mailman/listinfo/python-list

Re: Algorithm that makes maximum compression of completly diffused data.

2013-10-30 Thread Dan Stromberg
xz compression is pretty hard, if a little bit slow. Also, if you want really stellar compression ratios and you don't care about time to compress, you might check out one of the many paq implementations. I have a module that does xz compression in 4 different ways: http://stromberg.dnsalias.org/

Re: "Backward"-Iterator - Beginners question

2013-10-31 Thread Dan Stromberg
On Thu, Oct 31, 2013 at 2:29 PM, Ulrich Goebel wrote: > Hallo, > > I'm locking for an "iterator" type with not only the .next() method, but > with a .previous(), .first() and .last() method, so that I can through it > from the beginning or from the end, and in both directions, even > alternately

Re: Automation

2013-11-03 Thread Dan Stromberg
On Sun, Nov 3, 2013 at 8:19 AM, Renato Barbosa Pim Pereira < renato.barbosa.pim.pere...@gmail.com> wrote: > I have one .xls file with the values of PV MV and SP, I wanna to calculate > Kp Ki Kd with python from this file, can anyone give me any suggestion > about how can I do this? From now, thank

Re: Python Worst Practices

2015-02-27 Thread Dan Sommers
On Sat, 28 Feb 2015 12:09:31 +1100, Steven D'Aprano wrote: > There's no harm in calling a local variable "id", if you don't use the > built-in id() inside that function. That's one of the reasons why functions > exist, so that the names you use inside a function are distinct from those > outside.

Re: Python Worst Practices

2015-02-27 Thread Dan Sommers
On Sat, 28 Feb 2015 17:36:44 +1100, Steven D'Aprano wrote: > Dan Sommers wrote: >> And thank goodness for that! I've been writing Python code since >> 1997 and version 1.5.,¹ and I still do a double take when >> emacs colors all my ids that faint blue that means &

Re: Newbie question about text encoding

2015-03-07 Thread Dan Sommers
On Sun, 08 Mar 2015 04:59:56 +1100, Chris Angelico wrote: > On Sun, Mar 8, 2015 at 4:50 AM, Marko Rauhamaa wrote: >> Correct. Linux pathnames are octet strings regardless of the locale. >> >> That's why Linux developers should refer to filenames using bytes. >> Unfortunately, Python itself viola

Re: Newbie question about text encoding

2015-03-07 Thread Dan Sommers
On Sun, 08 Mar 2015 05:13:09 +1100, Chris Angelico wrote: > On Sun, Mar 8, 2015 at 5:02 AM, Dan Sommers wrote: >> On Sun, 08 Mar 2015 04:59:56 +1100, Chris Angelico wrote: >> >>> On Sun, Mar 8, 2015 at 4:50 AM, Marko Rauhamaa wrote: >> >>>> Correct. Li

Re: Newbie question about text encoding

2015-03-07 Thread Dan Sommers
On Sat, 07 Mar 2015 19:00:47 +, Mark Lawrence wrote: > Isn't pathlib > https://docs.python.org/3/library/pathlib.html#module-pathlib > effectively a more recent attempt at smoothing or even removing (some > of) the bumps? Has anybody here got experience of it as I've never > used it? I almos

Re: Auto-completion of Unicode names [was why not module name?]

2015-03-17 Thread Dan Sommers
t; There are currently somewhere in the vicinity of 110 thousand such > names. I think you just made my point about the completion being fuzzy. ;-) Dan ¹ Okay, so that's just an *opinion*. -- https://mail.python.org/mailman/listinfo/python-list

Re: Brilliant or insane code?

2015-03-17 Thread Dan Sommers
On Wed, 18 Mar 2015 00:35:42 +, Mark Lawrence wrote: > I've just come across this > http://www.stavros.io/posts/brilliant-or-insane-code/ as a result of > this http://bugs.python.org/issue23695 > > Any and all opinions welcomed, I'm chickening out and sitting firmly > on the fence. According

Re: Brilliant or insane code?

2015-03-17 Thread Dan Sommers
On Wed, 18 Mar 2015 13:25:45 +1100, Steven D'Aprano wrote: > On Wednesday 18 March 2015 12:14, Dan Sommers wrote: >> According to the article itself, "it relies in an implementation >> detail (the order the zip function iterates over the arrays) to >> work."

<    9   10   11   12   13   14   15   16   17   18   >