Re: Red Black Tree implementation?

2013-05-06 Thread Dan Stromberg
On Mon, May 6, 2013 at 5:55 PM, duncan smith wrote: > > What license? >> >> Thanks! >> >> > Here's the text I usually prepend. > > > ##Copyright (c) 2013 duncan g. smith > ## > ##Permission is hereby granted, free of charge, to any person obtaining a > ##copy of this software and associated docume

Re: Making safe file names

2013-05-07 Thread Dan Stromberg
On 5/7/13, Andrew Berg wrote: > Currently, I keep Last.fm artist data caches to avoid unnecessary API calls > and have been naming the files using the artist name. However, > artist names can have characters that are not allowed in file names for most > file systems (e.g., C/A/T has forward slashe

Re: Red Black Tree implementation?

2013-05-08 Thread Dan Stromberg
OK, I've got one copy of trees.py with md5 211f80c0fe7fb9cb42feb9645b4b3ffe. You seem to be saying I should have two though, but I don't know that I do... On 5/8/13, duncan smith wrote: > On 07/05/13 02:20, Dan Stromberg wrote: >> >> On Mon, May 6, 2013

Re: Red Black Tree implementation?

2013-05-11 Thread Dan Stromberg
5 11 False 6 15 11 False 6 15 11 False 6 15 Thoughts? BTW, printing an empty tree seems to say "sentinel". 'not sure if that was intended. Thanks! On Thu, May 9, 2013 at 6:52 AM, duncan smith wrote: > On 09/05/13 02:40, Dan Stromberg wrote: > >> OK, I've got o

Re: Red Black Tree implementation?

2013-05-11 Thread Dan Stromberg
On Sat, May 11, 2013 at 4:24 PM, Dan Stromberg wrote: > > I'm afraid I'm having some trouble with the module. I've checked it into > my SVN at > http://stromberg.dnsalias.org/svn/red-black-tree-mod/trunk/duncan > > I have two versions of your tests in there now

TypeError: unbound method add() must be called with BinaryTree instance as first argument (got nothing instead)

2013-05-18 Thread Dan Stromberg
I'm getting the error in the subject, from the following code: def add(self, key): """ Adds a node containing I{key} to the subtree rooted at I{self}, returning the added node. """ node = self.find(key) if not node: node.key = key

Re: How to write fast into a file in python?

2013-05-18 Thread Dan Stromberg
With CPython 2.7.3: ./t time taken to write a file of size 52428800 is 15.86 seconds time taken to write a file of size 52428800 is 7.91 seconds time taken to write a file of size 52428800 is 9.64 seconds With pypy-1.9: ./t time taken to write a file of size 52428800 is 3.708232 seconds

Ordered dictionaries compared

2013-05-22 Thread Dan Stromberg
What kind of ordered dictionaries? Sorted by key. I've redone the previous comparison, this time with a better red-black tree implementation courtesy of Duncan G. Smith. The comparison is at http://stromberg.dnsalias.org/~strombrg/python-tree-and-heap-comparison/just-trees/ The Red-Black tree g

Re: Modules list-tool

2013-05-22 Thread Dan Stromberg
On Tue, May 21, 2013 at 12:35 PM, Gisle Vanem wrote: > Are anyone aware of a tool that can show me at run-time > which modules (pyd/dll) are loaded into a Python program at a specific > time (or over time)? > > To clarify, e.g. when running a sample from PyQt4 > (examples\tutorials\**addressbook\

Re: Ordered dictionaries compared

2013-05-23 Thread Dan Stromberg
On Thu, May 23, 2013 at 9:41 AM, duncan smith wrote: > > RBT is quicker than Treap for insertion with randomized data, but slower > with ordered data. Randomized data will tend to minimize the number of tree > rotations needed to keep the RBT balanced, whilst the Treap will be > performing rotatio

Re: Help with implementing callback functions using ctypes

2013-05-23 Thread Dan Stromberg
On Wed, May 8, 2013 at 10:54 PM, dieter wrote: > jamadagni writes: > > ... > I cannot help you with "ctypes". But, if you might be able to use > "cython", then calling callbacks is not too difficult > (you can find an example in e.g. my "dm.xmlsec.binding"). > > Note, however, that properly hand

Re: Prepending string "@" to usernames

2013-05-24 Thread Dan Stromberg
On Fri, May 24, 2013 at 3:53 PM, Thomas Murphy wrote: > Hi beloved list, > > I'm having a dumb and SO doesn't seem to have this one answered. I was > sent a long list of instagram usernames to tag for a nightlife > announcement in this format(not real names(i hope)) > > cookielover93 > TheGermanHa

Survey of Python-in-browser technologies

2013-05-24 Thread Dan Stromberg
I'm putting together a spreadsheet about Python-in-the-browser technologies for my local python user group. I've been hitting the mailing lists for the various implementations already, but I thought I should run it by people here at least once. Anyway, here it is: http://stromberg.dnsalias.org/~

Re: Survey of Python-in-browser technologies

2013-05-24 Thread Dan Stromberg
Security is an important topic... but I'm not sure how I could gather info about the security of these implementations. Still, it's an idea worth at least keeping in the back of my mind. On Fri, May 24, 2013 at 4:43 PM, Carlos Nepomuceno < carlosnepomuc...@outlook.com> wrote: > Thanks Dan! All o

Re: Help with implementing callback functions using ctypes

2013-05-26 Thread Dan Stromberg
On Sun, May 26, 2013 at 9:12 AM, Shriramana Sharma wrote: > On Friday, May 24, 2013 8:56:28 AM UTC+5:30, Dan Stromberg wrote: > > Cython is good. So is the new cffi, which might be thought of as a > > safer (API-level) version of ctypes (which is ABI-level). > > Hi -- can you

Re: Python #ifdef

2013-05-28 Thread Dan Stromberg
Here're slides from a presentation about writing code that runs on 2.x and 3.x: http://stromberg.dnsalias.org/~dstromberg/Intro-to-Python/ And in case you still want a preprocessor for Python (you likely don't need one this time), here's an example of doing this using the venerable m4: https://pyp

Re: How clean/elegant is Python's syntax?

2013-05-29 Thread Dan Stromberg
On Wed, May 29, 2013 at 11:13 AM, Ma Xiaojun wrote: > Hi, list. > > For the core language, I have mixed feeling. On one hand, I find that > Python has some sweet feature that is quite useful. On the other hand, > I often find Pyhton snippets around hard to understand. I admit that I > never learn

Re: Python 2-3 compatibility

2013-06-02 Thread Dan Stromberg
From http://stromberg.dnsalias.org/~dstromberg/Intro-to-Python/Python%202%20and%203.pdf: Try/Except: both 2.x and 3.x try: print(1/0) except ZeroDivisionError: extra = sys.exc_info()[1] print('oops') HTH On Sun, Jun 2, 2013 at 7:13 AM, Jason Swails wrote: > Hello Everyone, > > I ha

Re: Arp cache poisoning using scapy

2013-06-02 Thread Dan Stromberg
On Sun, Jun 2, 2013 at 11:19 AM, wrote: > > I am trying to get the arp cache poisoning working with scapy and python > but having problems > > The python script itself is very simple: > root@ubuntu:/home/joker/Downloads/scapy-2.2.0/scripts# cat arp_poison.py > #!/usr/bin/env python > > import sys

Re: Issue converting to string to integer.

2013-06-02 Thread Dan Stromberg
On Sun, Jun 2, 2013 at 6:12 PM, Fdama wrote: > Hi, > > I was following an exercise in a book when I edited the code and came > across something I did not get. Here is the relevant part of the code that > works: > > start=None #initialise > while start !="": > start=input("\nStart: ") > >

Re: How to get an integer from a sequence of bytes

2013-06-03 Thread Dan Stromberg
On Mon, Jun 3, 2013 at 7:31 AM, Grant Edwards wrote: > That's a common assumption, but historically, a "byte" was merely the > smallest addressable unit of memory. The size of a "byte" on widely > used used CPUs ranged from 4 bits to 60 bits. > > Quoting from http://en.wikipedia.org/wiki/Byte > >

Re: How to get an integer from a sequence of bytes

2013-06-03 Thread Dan Stromberg
On Mon, Jun 3, 2013 at 4:18 PM, Carlos Nepomuceno < carlosnepomuc...@outlook.com> wrote: > > > Date: Mon, 3 Jun 2013 15:41:41 -0700 > > Subject: Re: How to get an integer from a sequence of bytes > > From: drsali...@gmail.com > > To: python-list@python.org > [...]

Re: [Python-Dev] Do you consider Python a 4GL? Why (not)?

2013-06-04 Thread Dan Stromberg
On Tue, Jun 4, 2013 at 4:53 PM, Carlos Nepomuceno < carlosnepomuc...@outlook.com> wrote: > Do you consider Python a 4GL? Why (not)? > By the wikipedia definition of 4GL and 5GL, I'd say Python is neither. And it's not a VHLL either, again according to the wikipedia definition. But IMO it is too

Re: Bools and explicitness [was Re: PyWart: The problem with "print"]

2013-06-06 Thread Dan Stromberg
On Thu, Jun 6, 2013 at 9:49 AM, Rick Johnson wrote: > Congrats: Again you join the ranks of most children who make excuses for > their foolish actions along the lines of: > > "Hey, they did it first!" > > Well, the lemmings get what they deserve i suppose. > Lemmings don't really jump off cliffs

Re: Python Game Development?

2013-06-07 Thread Dan Stromberg
On Fri, Jun 7, 2013 at 8:53 AM, wrote: > I also understand that Python isn't exactly the *BEST* choice programming > a game, but I have heard it is possible. Tell me if it's true. Thanks! > One of the Blizzard people told me that it's very common to program game logic in Python, with the 3D stuf

Re: How keep python socket alive for ever by setting Keep alive flag.

2012-06-25 Thread Dan Stromberg
http://www.unixguide.net/network/socketfaq/4.7.shtml It's better to add the ability to recreate a socket if it encounters trouble. SO_KEEPALIVE is there to help you detect if the other end of your connection has disappeared. Network programming has relatively few absolutes - it's best to build in

Re: when "normal" parallel computations in CPython will be implemented at last?

2012-07-01 Thread Dan Stromberg
If something happens with this for CPython, it'll likely come from Pypy developers first. They seem to be interested in doing things in a way that is (or can be made) compatible with CPython. If you want to help them along, they're taking donations to fund the work, or you could donate your own t

Re: when "normal" parallel computations in CPython will be implemented at last?

2012-07-01 Thread Dan Stromberg
On Sun, Jul 1, 2012 at 11:58 AM, Thomas Jollans wrote: > On 07/01/2012 08:44 PM, Dan Stromberg wrote: > > IronPython, sadly, lacks a python standard library. > > > Beg pardon? > > > https://github.com/IronLanguages/main/tree/master/External.LCA_RESTRICTED/Languages/

Re: Best data structure for DFS on large graphs

2012-07-03 Thread Dan Stromberg
On Tue, Jul 3, 2012 at 3:08 PM, Miheer Dewaskar wrote: > On Tue, Jul 3, 2012 at 8:10 PM, Tim Chase > wrote: > I want it to be a generic Game solver.So the number of states depends > on the game. > Keep in mind that it would probably be a generic game solver for games that have simple board evalu

Why site-packages?

2012-07-03 Thread Dan Stromberg
Why is it that so much 3rd party python code gets installed to site-packages? Even for things that are almost certainly going to be used by a single application? Even for things you might only use once? Even for things that might require one version for one app, and another version for another a

Re: Why site-packages?

2012-07-03 Thread Dan Stromberg
On Tue, Jul 3, 2012 at 9:04 PM, Ian Kelly wrote: > On Tue, Jul 3, 2012 at 2:40 PM, Dan Stromberg wrote: > > > > Why is it that so much 3rd party python code gets installed to > > site-packages? > > Because that's what site-packages is for? > Agh. But -why-

Re: Why site-packages?

2012-07-03 Thread Dan Stromberg
On Tue, Jul 3, 2012 at 10:04 PM, Ian Kelly wrote: > > >> The site module has to process any .pth files in the site-packages, > >> but apart from that, I think the actual amount of stuff in > >> site-packages should be irrelevant. > > > > Irrelevant to what? More stuff in site slowing things dow

Re: How to safely maintain a status file

2012-07-09 Thread Dan Stromberg
On Mon, Jul 9, 2012 at 8:24 PM, John Nagle wrote: > On 7/8/2012 2:52 PM, Christian Heimes wrote: > >> You are contradicting yourself. Either the OS is providing a fully >> atomic rename or it doesn't. All POSIX compatible OS provide an atomic >> rename functionality that renames the file atomical

Re: lambda in list comprehension acting funny

2012-07-14 Thread Dan Stromberg
On Sat, Jul 14, 2012 at 4:29 PM, Steven D'Aprano < steve+comp.lang.pyt...@pearwood.info> wrote: > I don't remember whether it is Javascript or PHP that uses dynamic > binding, but whichever it is, it is generally considered to be a bad > idea, at least as the default or only behaviour. > > Bash is

Re: PyPy, is it a 1:1 replacement for CPython?

2012-07-20 Thread Dan Stromberg
On Fri, Jul 20, 2012 at 8:59 PM, Steven D'Aprano < steve+comp.lang.pyt...@pearwood.info> wrote: > On Sat, 21 Jul 2012 13:35:21 +1000, Simon Cropper wrote: > > > Hi, > > > > Can you use PyPy as a direct replacement for the normal python or is it > > a specialized compiler that can only work with li

command line option parsing and pylint?

2012-07-22 Thread Dan Stromberg
Is there such a thing as a Python option parsing module, that plays well with pylint? I've been doing my own option parsing to get working static analysis. -- http://mail.python.org/mailman/listinfo/python-list

default repr?

2012-07-22 Thread Dan Stromberg
If a class has defined its own __repr__ method, is there a way of getting the default repr output for that class anyway? I'm attempting to graph some objects by digging around in the garbage collector's idea of what objects exist, and when I go to format them for the graph node labels, the ones th

Re: howto do a robust simple cross platform beep

2012-07-24 Thread Dan Stromberg
On Sat, Jul 14, 2012 at 1:00 AM, Gelonida N wrote: > > What I do at the moment is: > > For Windows I use winsound.Beep > > For Linux I create some raw data and pipe it into sox's > 'play' command. > > I don't consider this very elegant You may want to get over that. Some software vendors/distr

Re: dict: keys() and values() order guaranteed to be same?

2012-07-26 Thread Dan Stromberg
On Thu, Jul 26, 2012 at 9:06 PM, Ethan Furman wrote: > Chris Angelico wrote: > >> On Tue, Jul 24, 2012 at 1:20 AM, Steven D'Aprano >> > >> wrote: >> >>> (Although if you think about the implementation of dicts as hash tables, >>> it does seem likely that it is trivial to enforce this -- one would

Re: Is Python a commercial proposition ?

2012-07-29 Thread Dan Stromberg
On Sun, Jul 29, 2012 at 5:52 PM, Andrew Berg wrote: > On 7/29/2012 7:12 PM, Rodrick Brown wrote: > > Python is a glue language much like Perl was 10 years ago. Until the > > GIL is fixed I doubt anyone will seriously look at Python as an option > > for large enterprise standalone application devel

Re: Extracting bit fields from an IEEE-784 float

2012-07-30 Thread Dan Stromberg
On Mon, Jul 30, 2012 at 12:44 AM, Steven D'Aprano < steve+comp.lang.pyt...@pearwood.info> wrote: > I wish to extract the bit fields from a Python float, call it x. First I > cast the float to 8-bytes: > > s = struct.pack('=d', x) > i = struct.unpack('=q', s)[0] > > Then I extract the bit fields fr

Re: Linux shell to python

2012-07-30 Thread Dan Stromberg
On Mon, Jul 30, 2012 at 9:26 PM, Barry Scott wrote: > lspci gets all its information from the files in /sys/bus/pci/devices. > > You can use os.listdir() to list all the files in the folder and then open > the files you want to get the data you need. > Gee, wouldn't it be more portable to parse

Re: Linux shell to python

2012-07-30 Thread Dan Stromberg
On Mon, Jul 30, 2012 at 11:14 PM, Emile van Sebille wrote: > On 7/30/2012 3:56 PM Dan Stromberg said... > > >> On Mon, Jul 30, 2012 at 9:26 PM, Barry Scott > > > And of course you can write list comprehensions on as many lines as >> it take to make the code

Re: trying to create simple py script

2012-08-10 Thread Dan Stromberg
CGI's old stuff. Sure it's easy to find doc about it - it's been around longer. I'd recommend either CherryPy or Bottle - because these are the two (that I know of) that support Python 3 today. Here's a nice comparison of Python REST frameworks: http://www.youtube.com/watch?v=AYjPIMe0BhA I'm u

Re: Threads and sockets

2012-08-10 Thread Dan Stromberg
A select() loop should work. On Fri, Aug 10, 2012 at 1:01 PM, loial wrote: > I am writing an application to send data to a printer port(9100) and then > recieve PJL responses back on that port. Because of the way PJL works I > have to do both in the same process(script). > > At the moment I do n

Re: Unable to execute the script

2012-08-10 Thread Dan Stromberg
This sounds like a ScriptAlias thing: http://httpd.apache.org/docs/2.2/howto/cgi.html On Fri, Aug 10, 2012 at 5:14 PM, Smaran Harihar wrote: > Hi, > > I have set executable permissions for my py script (cgi-script) but for > some reason rather than executing it, the browser simply downloads the p

Re: python 6 compilation failure on RHEL

2012-08-20 Thread Dan Stromberg
On Mon, Aug 20, 2012 at 10:25 PM, Cameron Simpson wrote: > I was going to chime in with this anyway had the thread said nothing; I > strongly prefer to specify --prefix explicitly with configure. > > My personal habit to to build with (adjust to match): > > --prefix=/usr/local/python-2.6.4 > >

Reimporting modules, and sandboxing?

2012-08-21 Thread Dan Stromberg
I know I've seen this discussed before, and I came away from observing the discussion thinking "Python doesn't do that very well...", but we have some people here who really would like to do this, and I need to better understand the pros and cons now. Is there a good way of reimporting an _indepen

Static analysis tools

2012-10-11 Thread Dan Stromberg
I'm familiar with pylint, and have recently played with pyflakes and flake8. I've also heard of pychecker. Are there others, perhaps including some that aren't written in Python, but still check Python? We're considering doing static analysis of a large CPython 3.2 project, but so far the traditi

Re: A desperate lunge for on-topic-ness

2012-10-18 Thread Dan Stromberg
On Wed, Oct 17, 2012 at 11:06 PM, Zero Piraeus wrote: > : > > Okay, so, first thing vaguely Python-related that comes to mind [so > probably not even slightly original, but then that's not really the > point]: > > What are people's preferred strategies for dealing with lines that go > over 79 cha

Good debugger for CPython 3.2?

2012-10-19 Thread Dan Stromberg
What's a good debugger for CPython 3.2? I'd prefer to use it on Linux Mint 13, and I'd be happy with something based on X11 or curses. I tried winpdb, but it was cranky that Linux didn't have a spawn callable. Why they didn't use the portable subprocess module escapes me. I also tried ddd, but i

Re: Good debugger for CPython 3.2?

2012-10-19 Thread Dan Stromberg
On Fri, Oct 19, 2012 at 9:26 AM, Dan Stromberg wrote: > > What's a good debugger for CPython 3.2? I'd prefer to use it on Linux > Mint 13, and I'd be happy with something based on X11 or curses. > > I tried winpdb, but it was cranky that Linux didn't have a

Re: bit count or bit set && Python3

2012-10-25 Thread Dan Stromberg
On Thu, Oct 25, 2012 at 9:24 AM, Mark Lawrence wrote: > On 25/10/2012 15:47, Charles Hixson wrote: > >> In Python3 is there any good way to count the number of on bits in an >> integer (after an & operation)? >> Alternatively, is there any VERY light-weight implementation of a bit >> set? I'd pre

Building python, bz2 coming up missing

2012-11-21 Thread Dan Stromberg
I'm attempting to build cpython 2.{5,6,7} and cpython 3.[0,1,2,3}. I find that having them all around facilitates interversion testing and discovering what works in which versions. Anyway, in 3.3, I'm getting a bz2 module, but in 3.2, I'm not - but only when compiling on Linux Mint 14. On Linux

Re: Building python, bz2 coming up missing

2012-11-21 Thread Dan Stromberg
On Wed, Nov 21, 2012 at 12:18 PM, Dan Stromberg wrote: > > I'm attempting to build cpython 2.{5,6,7} and cpython 3.[0,1,2,3}. I find > that having them all around facilitates interversion testing and > discovering what works in which versions. > > Anyway, in 3.3, I'

Re: Where to put data

2012-01-26 Thread Dan Stromberg
I think that /usr/*/python-whatever/site-packages and related directories are very much overused in the python world, and tend to cause problems eventually - EG when you need to install two versions of a program on the same machine, same interpreter. I prefer to provide a configure script that acc

Re: [semi OT]: Smartphones and Python?

2012-02-20 Thread Dan Stromberg
On Wed, Feb 15, 2012 at 3:36 PM, Paul Rubin wrote: > Martin Schöön writes: > > A very quick internet search indicated that this should be no big > > deal if I go for an Android-based phone. What about the alternatives? > > It works pretty well with Maemo, though phones with that are not so easy

Re: lang comparison: in-place algorithm for reversing a list in Perl, Python, Lisp

2012-02-29 Thread Dan Stromberg
On Wed, Feb 29, 2012 at 8:07 PM, Xah Lee wrote: > fun example. > > in-place algorithm for reversing a list in Perl, Python, Lisp > http://xahlee.org/comp/in-place_algorithm.html > > plain text follows > > > What's “In-place Algorithm”? > > Xah Lee, 2012-02

Re: Parse cisco's "show ip route" output in Python 2.7

2012-03-04 Thread Dan Stromberg
I've done little with Ciscos, but what if you use individual things like "show ip ospf", "show ip rip database", etc. instead of "show ip route". Does that makes things a little more consistent? Often big problems are simpler if we can divide them into smaller, more manageable subproblems. On S

Re: Porting Python to an embedded system

2012-03-04 Thread Dan Stromberg
You might check out pymite. http://wiki.python.org/moin/PyMite Oh, but I'm now realizing that's part of the python on a chip project, so in a way it's already been mentioned. Anyway, PyMite, I gather, is a tiny python for microcontrollers. On Sun, Mar 4, 2012 at 2:58 AM, Justin Drake wrote: >

Re: Fast file data retrieval?

2012-03-12 Thread Dan Stromberg
If the ID's are sorted, you could probably rig a binary search using seek. This'll be easier if the records have a constant length, but it's still possible for variable-length, just messier. Otherwise you could stash them all in a dictionary (in memory) or anydbm (on disk) to get indexed access.

Re: cannot open shared object file

2012-03-16 Thread Dan Stromberg
A suggestion: 1) strace it. http://stromberg.dnsalias.org/~strombrg/debugging-with-syscall-tracers.html 2) Show the output to a C programmer, or take some educated guesses yourself. On Thu, Mar 15, 2012 at 11:47 PM, Steven Lo wrote: > ** > > Hi, > > We are getting the following error during a 'm

Re: Does anyone actually use PyPy in production?

2012-03-17 Thread Dan Stromberg
I personally feel that python-list should be restricted to discussing Python the language, not just CPython the implementation. Anyway, there are many kinds of production, no? But I use Pypy for my backups frequently, which is a form of production use. Pypy+backshift pass my automated tests as w

Re: How do I use PyGTK to put text besides clickable buttons?

2012-04-02 Thread Dan Stromberg
You could use an hbox. Or rather, a vbox with a bunch of hbox's in it. On Thu, Mar 29, 2012 at 10:45 PM, Jason Hsu, Mr. Swift Linux < jhsu802...@gmail.com> wrote: > I've decided to use PyGTK instead of gtkdialog for providing > configuration menus/dialog boxes in Swift Linux, the Linux distro I

Re: Python randomly exits with Linux OS error -9 or -15

2012-04-09 Thread Dan Stromberg
You might try running your Python process with: strace -f -s 1024 -o /tmp/script.strace python /path/to/script.py Then you (perhaps with a C programmer) can likely track down what happened right before the crash by examining the system call tracer near the end of the file. http://stromberg.dns

Re: red-black tree data structure

2012-04-11 Thread Dan Stromberg
Bringing this back to Python a bit: http://newcenturycomputers.net/projects/rbtree.html http://pypi.python.org/pypi/bintrees/0.3.0 http://pypi.python.org/pypi/treap/0.995 Red-Black trees are supposed to be slower than treaps on average, but they're also supposed to have a lower standard deviation

Re: Is it possible develop applications in python for android and which IDE could you recommend me (Eclipse, ...)???

2012-04-12 Thread Dan Stromberg
http://code.google.com/p/android-scripting/ However, I've not used it, and I'm told it requires a stub for each new android method exposed to python. I find it a little regrettable that they didn't start frp, jython or pypy for jvm instead of cpython, to avoid all the stubbing. On Thu, Apr 12, 2

Re: Sockets accept() in child processes

2012-04-12 Thread Dan Stromberg
I wonder if this'll do what you need: https://trac.calendarserver.org/browser/CalendarServer/trunk/twext/python/sendfd.py On Thu, Apr 12, 2012 at 2:31 AM, Thibaut DIRLIK wrote: > Hi, > > I'm writing a multiprocess server with Python 3.2 and the multiprocessing > module. Here is my current impleme

Re: Problem connecting to SMTP/IMAP server using SSL

2012-04-12 Thread Dan Stromberg
Are you quite sure that your iPhone isn't using some sort of VPN? On my Android phone, I need a VPN client to access my work mail, but I install it once and forget about it; it doesn't require me to enter my password more than once. On Fri, Mar 30, 2012 at 10:39 PM, Julien wrote: > Hi, > > I'm

Re: Problem connecting to SMTP/IMAP server using SSL

2012-04-12 Thread Dan Stromberg
Maybe it's a matter of two different protocols, one requiring a VPN, one not. You could perhaps try a sniffer to check that out. Where to place the sniffer could be complicated though. On Fri, Mar 30, 2012 at 10:39 PM, Julien wrote: > Hi, > > I'm able to connect to an Exchange server via SMTP

Re: Sockets accept() in child processes

2012-04-12 Thread Dan Stromberg
On Thu, Apr 12, 2012 at 10:48 AM, Merwin wrote: > Le 12/04/2012 19:10, Dan Stromberg a écrit : > > >> I wonder if this'll do what you need: >> https://trac.calendarserver.**org/browser/CalendarServer/** >> trunk/twext/python/sendfd.py<https://trac.calendarserv

Re: How to determine if IO redirection is occurring with the output from a Python program?

2012-04-18 Thread Dan Stromberg
On Tue, Apr 17, 2012 at 5:52 PM, Chris Angelico wrote: > > isatty() is supported on Windows (the underlying C API is different, > but the beauty of a high-level language is that you no longer need to > care), but the standard Windows console doesn't support ANSI > sequences. I think there is a wa

Re: Suggest design to accomodate non-unix platforms ?

2012-04-18 Thread Dan Stromberg
On Wed, Apr 18, 2012 at 7:02 AM, Richard Shea wrote: > On Apr 19, 1:56 am, Irmen de Jong wrote: > > On 18-4-2012 15:35, Richard Shea wrote: > > > > > ... which I think would work and be sufficiently flexible to deal with > > > alternatives to putty.exe but is there a more established (... > > >

Re: Suggest design to accomodate non-unix platforms ?

2012-04-19 Thread Dan Stromberg
On Wed, Apr 18, 2012 at 5:16 PM, Miki Tebeka wrote: > > So I'm interested in suggestions/examples where a user can update a > > config file to specify by which means they want (in this case) the ssh > > functionality to be supplied. > You can do something like that (it's called a factory): > > CO

Re: Suggest design to accomodate non-unix platforms ?

2012-04-20 Thread Dan Stromberg
On Thu, Apr 19, 2012 at 5:14 PM, Chris Angelico wrote: > The question then is whether to choose or auto-detect. Attempting to > auto-detect could be quite inefficient; imagine if you have to call on > ssh every couple of seconds, and something in $PATH is on a slow > network share (or on a floppy

Sort comparison

2012-04-30 Thread Dan Stromberg
A while back I did a sort algorithm runtime comparison for a variety of sorting algorithms, and then mostly sat on it. Recently, I got into a discussion with someone on stackoverflow about the running time of radix sort. I realize it's commonly said that radixsort is n*k rather than n*log(n). I'v

Re: Sort comparison

2012-05-01 Thread Dan Stromberg
On Tue, May 1, 2012 at 12:21 AM, Ian Kelly wrote: > On Mon, Apr 30, 2012 at 11:25 PM, Dan Stromberg > wrote: > > > > A while back I did a sort algorithm runtime comparison for a variety of > > sorting algorithms, and then mostly sat on it. > > > > Recently,

Re: Sort comparison

2012-05-01 Thread Dan Stromberg
On Tue, May 1, 2012 at 10:51 AM, Terry Reedy wrote: > On 5/1/2012 1:25 AM, Dan Stromberg wrote: > > Anyway, here's the comparison, with code and graph: >> http://stromberg.dnsalias.org/**~strombrg/sort-comparison/<http://stromberg.dnsalias.org/%7Estrombrg/sort-compariso

Re: Sort comparison

2012-05-01 Thread Dan Stromberg
On Tue, May 1, 2012 at 11:52 AM, Ian Kelly wrote: > On Tue, May 1, 2012 at 12:00 PM, Dan Stromberg > wrote: > > > > On Tue, May 1, 2012 at 12:21 AM, Ian Kelly > wrote: > >> > >> On Mon, Apr 30, 2012 at 11:25 PM, Dan Stromberg > >> wrote: &

Re: Lack of whitespace between contain operator ("in") and other expression tokens doesn't result in SyntaxError: bug or feature?

2012-05-03 Thread Dan Stromberg
On Thu, May 3, 2012 at 12:21 PM, Garrett Cooper wrote: > On Thu, May 3, 2012 at 12:03 PM, Ian Kelly wrote: > > On Thu, May 3, 2012 at 12:49 PM, Garrett Cooper > wrote: > >>I was wondering whether this was a parser bug or feature (seems > >> like a bug, in particular because it implicitly en

Re: When convert two sets with the same elements to lists, are the lists always going to be the same?

2012-05-03 Thread Dan Stromberg
If you need the same ordering in two lists, you really should sort the lists - though your comparison function need not be that traditional. You might be able to get away with not sorting sometimes, but on CPython upgrades or using different Python interpreters (Pypy, Jython), it's almost certain

Re: key/value store optimized for disk storage

2012-05-04 Thread Dan Stromberg
On Thu, May 3, 2012 at 11:03 PM, Paul Rubin wrote: > > Sort of as you suggest, you could build a Huffman encoding for a > > representative run of data, save that tree off somewhere, and then use > > it for all your future encoding/decoding. > > Zlib is better than Huffman in my experience, and Py

Re: Is Python Lazy?

2012-05-05 Thread Dan Stromberg
Generators and iterators are laziness where you tend to need laziness the most. Generator expressions are tiny generators - more full fledged generators are supported. Python probably won't have laziness at its core ever, but it's nice having a dose of it. IOW, you probably won't be able to writ

Re: sorting 1172026 entries

2012-05-06 Thread Dan Stromberg
How much physical RAM (not the virtual memory, but the physical memory) does your machine have available? We know the number of elements in your dataset, but how big are the individual elements? If a sort is never completing, you're probably swapping. list.sort() is preferrable to sorted(list),

Re: tee-like behavior in Python

2012-05-09 Thread Dan Stromberg
You've had some good responses already, but here're two more: 1) Easiest would be to use setvbuf in the child process, if you have access to its source. This allows you to force line-oriented buffering. 2) stdio likes to buffer to tty/pty's in a line-oriented manner, and other things in a block-

Re: bash/shell to python

2012-05-21 Thread Dan Stromberg
FWIW, I do manual argument parsing, because pylint understands how to detect typos with manual argument parsing, but not the highly dynamic modules that parse arguments. On Wed, May 16, 2012 at 7:16 PM, Rita wrote: > Hello, > > I currently build a lot of interfaces/wrappers to other applications

Re: Please use the Python Job Board for recruiting (was: Recruiting for Python Developer - Perm)

2012-05-22 Thread Dan Stromberg
On Tue, May 22, 2012 at 3:20 PM, Ben Finney wrote: > Python Recruiter writes: > > > Can any one help? I am looking for a Senior Python Developer > > Yes, please use the Python Job Board for this purpose instead > http://www.python.org/community/jobs/>. > > Good hunting! I find it more than a li

Re: install python 2.6 on Ubuntu 12.04

2012-05-22 Thread Dan Stromberg
If the pythons you require are in synaptic (sudo to root and run synaptic), you probably can just use them. If not, then you, for each release, need to: 1) download a tarball using a browser or whatever 2) extract the tarball: tar xvfp foo.tar.bz2 3) cd into the newly created, top-level directory,

Re: Please use the Python Job Board for recruiting

2012-05-23 Thread Dan Stromberg
On Wed, May 23, 2012 at 2:27 AM, Jean-Michel Pichavant < jeanmic...@sequans.com> wrote: > Dan Stromberg wrote: > >> >> On Tue, May 22, 2012 at 3:20 PM, Ben Finney >> > ben+python@benfinney.**id.au >> wrote: >> >>Python Recruiter mailto:ro

Re: Please use the Python Job Board for recruiting

2012-05-23 Thread Dan Stromberg
On Wed, May 23, 2012 at 3:30 AM, Chris Withers wrote: > On 23/05/2012 00:34, Dan Stromberg wrote: > >> >> I find it more than a little disappointing that the Python Job Board >> doesn't do latitude and longitude. It's a big missed opportunity. Yes, >> i

Python Tree datastructure comparison

2012-06-05 Thread Dan Stromberg
I've put together a comparison of some tree datastructures for Python, with varied runtime and varied workload: http://stromberg.dnsalias.org/~strombrg/python-tree-and-heap-comparison/ I hope to find time to add heaps to the article at some point, but for now, it only covers trees and the treap.

Import semantics?

2012-06-08 Thread Dan Stromberg
Did the import semantics change in cpython 3.3a4? I used to be able to import treap.py even though I had a treap directory in my cwd. With 3.3a4, I have to rename the treap directory to see treap.py. -- http://mail.python.org/mailman/listinfo/python-list

Re: Import semantics?

2012-06-08 Thread Dan Stromberg
On Fri, Jun 8, 2012 at 3:16 PM, Ethan Furman wrote: > Dan Stromberg wrote: > >> >> Did the import semantics change in cpython 3.3a4? >> >> I used to be able to import treap.py even though I had a treap directory >> in my cwd. With 3.3a4, I have to rename th

Re: Import semantics?

2012-06-08 Thread Dan Stromberg
On Fri, Jun 8, 2012 at 3:48 PM, Ian Kelly wrote: > On Fri, Jun 8, 2012 at 4:24 PM, Dan Stromberg wrote: > > Am I misinterpreting this? It seems like according to the PEP, I should > > have still been able to import treap.py despite having a treap/. But I > > couldn

Re: Import semantics?

2012-06-08 Thread Dan Stromberg
And a link to the ticket: http://bugs.python.org/issue15039 > -- http://mail.python.org/mailman/listinfo/python-list

Re: How does python bytecode works?

2012-06-17 Thread Dan Stromberg
On Sun, Jun 17, 2012 at 2:54 AM, gmspro wrote: > We know python is written in C. > Yes, at least CPython is. Of course, java is written in C, as are many other languages. > C is not portable. > C gives you lots of rope to hang yourself with, but if you use C well, it's more portable than anyth

Re: Bloom Filter in 22 lines of Python (updated)

2011-06-03 Thread Dan Stromberg
FWIW, I took what I believe to have been the 2nd generation of this code, and put some of my own spin on it - mostly making it pass pylint, changing the __init__ arguments to be a little more intuitive (to me), and expanding the tests a bit. It's at http://stromberg.dnsalias.org/svn/bloom-filter/t

Re: Any Better logic for this problem..

2011-06-09 Thread Dan Stromberg
On Thu, Jun 9, 2011 at 10:55 AM, geremy condra wrote: > On Thu, Jun 9, 2011 at 4:38 AM, Dave Angel wrote: > > On 01/-10/-28163 02:59 PM, Chris Rebert wrote: > >> > >> On Thu, Jun 9, 2011 at 1:31 AM, Ganapathy Subramanium > >> wrote: > >>> > >>> Hi Guru's, > >>> I'm working on a solution to fin

Re: Python 2.6 OR 3.2

2011-06-09 Thread Dan Stromberg
If your dependencies are satisfiable with 3.2, you're better off with 3.2. If not, use 2.7, or consider porting the dependencies yourself (assuming those dependencies have code available). Both 2.x and 3.x are good, but 3.x is clearly the way forward. 3.x has some annoyances corrected: more cent

Re: Handling emails

2011-06-12 Thread Dan Stromberg
On Sun, Jun 12, 2011 at 6:46 PM, Nobody wrote: > Any message with non-ASCII characters in the headers can safely be > discarded as spam (I've never seen this bug in "legitimate" email). > Many MTAs will simply reject such messages. http://en.wikipedia.org/wiki/Email_address#Internationalization

  1   2   3   4   5   6   7   8   9   10   >