Re: Python CPU

2011-04-01 Thread Dan Stromberg
On Fri, Apr 1, 2011 at 10:00 AM, Stefan Behnel wrote: > Nobody, 01.04.2011 18:52: > > Java is a statically-typed language which makes a distinction between >> primitive types (bool, int, double, etc) and objects. Python is a >> dynamically-typed language which makes no such distinction. Even som

Re: Guido rethinking removal of cmp from sort method

2011-04-01 Thread Dan Stromberg
On Fri, Apr 1, 2011 at 10:06 AM, Terry Reedy wrote: > On 4/1/2011 2:13 AM, harrismh777 wrote: > > When I speak of implementation vs interface I am speaking from a >> strictly object oriented philosophy, as pedigree, from Grady Booch, whom >> I consider to be the father of Object Oriented Analysi

Re: Guido rethinking removal of cmp from sort method

2011-04-01 Thread Dan Stromberg
On Mon, Mar 28, 2011 at 10:11 PM, Dan Stromberg wrote: > > On Mon, Mar 28, 2011 at 6:58 PM, Paul Rubin wrote: > >> DSU is a clever and useful design pattern, but comparison >> sorting is what all the sorting textbooks are written about. >> > > Actually, even thou

Re: newbie question

2011-04-01 Thread Dan Stromberg
On Fri, Apr 1, 2011 at 12:52 PM, Karl <8213543ggxnvjx...@kabelmail.de>wrote: > Hello, > > > one beginner question: > > > aList = [0, 1, 2, 3, 4] > > bList = [2*i for i in aList] > > sum = 0 > > for j in bList: > This iterates over the values in bList, not its indices. > sum = sum + bList[j] > S

Re: Guido rethinking removal of cmp from sort method

2011-04-01 Thread Dan Stromberg
On Fri, Apr 1, 2011 at 8:43 PM, Paul Rubin wrote: > Benjamin Peterson writes: > > Why would having PyPy as the reference implementation have made this > design > > decisions turn out better? > > A fair amount of Python 2's design was influenced by what was convenient > or efficient to implement

Re: a basic bytecode to machine code compiler

2011-04-02 Thread Dan Stromberg
On Sat, Apr 2, 2011 at 12:05 PM, John Nagle wrote: > On 4/2/2011 3:30 AM, Stefan Behnel wrote: > >> Cython actually supports most Python language features now (including >> generators in the development branch), both from Python 2 and Python 3. >> Chances are that the next release will actually c

Re: Python CPU

2011-04-02 Thread Dan Stromberg
On Sat, Apr 2, 2011 at 3:06 PM, BartC wrote: > > However, wasn't there a Python version that used JVM? Perhaps that might > run on a Java CPU, and it would be interesting to see how well it works. > Jython's still around - in fact, it had a new release not too long ago. Also, Pypy formerly work

Re: Python CPU

2011-04-02 Thread Dan Stromberg
On Sat, Apr 2, 2011 at 5:10 PM, Gregory Ewing wrote: > Brad wrote: > > I've heard of Java CPUs. Has anyone implemented a Python CPU in VHDL >> or Verilog? >> > > Not that I know of. > > I've had thoughts about designing one, just for the exercise. > > It's doubtful whether such a thing would ever

Re: better way to do this in python

2011-04-02 Thread Dan Stromberg
On Sat, Apr 2, 2011 at 5:24 PM, Chris Angelico wrote: > On Sun, Apr 3, 2011 at 9:58 AM, Mag Gam wrote: > > I suppose I can do something like this. > > (pseudocode) > > > > d={} > > try: > > d[key]+=1 > > except KeyError: > > d[key]=1 > > > > > > I was wondering if there is a pythonic way of do

Re: Multiprocessing, shared memory vs. pickled copies

2011-04-04 Thread Dan Stromberg
On Mon, Apr 4, 2011 at 1:20 PM, John Ladasky wrote: > When should one pickle and copy? When to implement an object in > shared memory? Why is pickling apparently such a non-trivial process > anyway? And, given that multi-core CPU's are apparently here to stay, > should it be so difficult to ma

Re: Multiprocessing, shared memory vs. pickled copies

2011-04-04 Thread Dan Stromberg
On Mon, Apr 4, 2011 at 4:34 PM, Philip Semanchuk wrote: > So if you're going to use multiprocessing, you're going to use pickle, and > you need pickleable objects. > http://docs.python.org/library/multiprocessing.html#sharing-state-between-processes -- http://mail.python.org/mailman/listinfo/pyt

Re: Testing for performance regressions

2011-04-04 Thread Dan Stromberg
On Mon, Apr 4, 2011 at 7:45 PM, Steven D'Aprano < steve+comp.lang.pyt...@pearwood.info> wrote: > I'm writing some tests to check for performance regressions (i.e. you > change a function, and it becomes much slower) and I was hoping for some > guidelines or hints. > > This is what I have come up w

Re: is python 3 better than python 2?

2011-04-05 Thread Dan Stromberg
On Tue, Apr 5, 2011 at 10:04 PM, Terry Reedy wrote: > On 4/5/2011 4:42 PM, John Nagle wrote: > > Well, actually Unicode support went in back around Python 2.4. >> > > Even earlier, I think, but there were and still are problems with unicode > in 2.x. Some were and will only be fixed in 3.x. > >

Re: Behaviour of subprocess.Popen, ssh and nohup I don't understand

2011-04-06 Thread Dan Stromberg
On Wed, Apr 6, 2011 at 12:47 AM, Adriaan Renting wrote: > > > This solves the problem using stdin=open(os.devnull, 'rb') instead of > stdin=None makes it run even if there is input from stdin in the > foreground process. > > The operating system is Ubuntu 8.04 > I understood what Suspended (tty in

Re: is python 3 better than python 2?

2011-04-06 Thread Dan Stromberg
On Wed, Apr 6, 2011 at 9:31 AM, MRAB wrote: > On 06/04/2011 07:06, Dan Stromberg wrote: >> >> On Tue, Apr 5, 2011 at 10:04 PM, Terry Reedy > <mailto:tjre...@udel.edu>> wrote: >> >>    On 4/5/2011 4:42 PM, John Nagle wrote: >> >>        Well, actu

Re: Sending pictures using sockets

2011-04-06 Thread Dan Stromberg
On Wed, Apr 6, 2011 at 4:17 PM, Littlefield, Tyler wrote: > On 4/6/2011 4:58 PM, craf wrote: > >> >Hello. >> > >> >I'm testing the sockets in Python and I've seen the way in which >> >works to send string. My question is if anyone knows where >> >can find some information on how to send pictures t

Re: Trapping the segfault of a subprocess.Popen

2011-04-06 Thread Dan Stromberg
On Wed, Apr 6, 2011 at 2:20 AM, Pierre GM wrote: > All, > > I need to run a third-party binary from a python script and retrieve > its output (and its error messages). I use something like > >>> process = subprocess.Popen(options, stdout=subprocess.PIPE, > stderr=subprocess.PIPE) > >>> (info_out,

Re: multiprocessing

2011-04-06 Thread Dan Stromberg
On Wed, Apr 6, 2011 at 9:06 PM, elsa wrote: > Hi guys, > > I want to try out some pooling of processors, but I'm not sure if it > is possible to do what I want to do. Basically, I want to have a > global object, that is updated during the execution of a function, and > I want to be able to run th

Re: multiprocessing

2011-04-07 Thread Dan Stromberg
I'm afraid I've not heard of a way of putting more complex objects into shared memory with multiprocessing. That is, not without using a queue along the lines of http://docs.python.org/library/multiprocessing.html#exchanging-objects-between-processes, which isn't quite the same thing. On Thu, Apr

Re: fighting game made with python

2011-04-07 Thread Dan Stromberg
On Thu, Apr 7, 2011 at 6:51 AM, neil harper wrote: > is there any fighting games(street fighter, mortal kombat, etc) made in > python? I talked to a guy from Blizzard about Python in their games once. He said that not only are most (all?) B

Re: Free software versus software idea patents

2011-04-12 Thread Dan Stromberg
On Tue, Apr 12, 2011 at 10:32 AM, Terry Reedy wrote: > On 4/11/2011 4:36 AM, rusi wrote: > >> http://www.cse.uconn.edu/~dqg/papers/cie05.pdf >> >> may be of interest (and also other papers of Peter Wegner questioning >> the universality of Turing machines lambda calculus etc) > > Thank you for tha

Re: [OT] Free software versus software idea patents

2011-04-12 Thread Dan Stromberg
On Tue, Apr 12, 2011 at 12:37 PM, Ian Kelly wrote: > On Tue, Apr 12, 2011 at 3:22 AM, harrismh777 wrote: >> It is not measured in any way, and it is almost impossible to determine >> therefore in any accurate fashion. There >> really are no data... what we need here is a census of sorts. > > The

Re: Python & Sybase

2011-04-13 Thread Dan Stromberg
http://www.freetds.org/ There's likely also one you could get from your database admin. On Wed, Apr 13, 2011 at 8:40 AM, Chris M. Bartos wrote: > Hi, > > Are there any database drivers that allows Python to connect to remote > Sybase Databases. > I tried python-sybase, but somehow couldn't get i

Re: Postmortem on Unladen Swallow

2011-04-13 Thread Dan Stromberg
I'm not sure I'd call it a failure. It didn't achieve the speedup they hoped for, but they did successfully get CPython running overtop of LLVM. That is, their intended approach didn't pan out, but they successfully implemented their approach. And just as importantly, Pypy was looking like it'd

Re: [OT] Free software versus software idea patents

2011-04-15 Thread Dan Stromberg
On Thu, Apr 14, 2011 at 1:46 PM, Westley Martínez wrote: > On Thu, 2011-04-14 at 14:02 +, Steven D'Aprano wrote: >> On Thu, 14 Apr 2011 19:15:05 +1000, Chris Angelico wrote: >> >> > 4) Assumes people aren't deliberately fiddling the figures. Yeah, that >> > would be correct. We're in the realm

Re: Questions about GIL and web services from a n00b

2011-04-15 Thread Dan Stromberg
On Fri, Apr 15, 2011 at 9:33 AM, Chris H wrote: > 1. Are you sure you want to use python because threading is not good due to > the Global Lock (GIL)?  Is this really an issue for multi-threaded web > services as seems to be indicated by the articles from a Google search?  If > not, how do you av

Re: [Tutor] working with strings in python3

2011-04-18 Thread Dan Stromberg
On Mon, Apr 18, 2011 at 6:23 PM, Benjamin Kaplan wrote: > On Mon, Apr 18, 2011 at 8:58 PM, Westley Martínez wrote: >> On Tue, 2011-04-19 at 10:34 +1000, James Mills wrote: >>> On Tue, Apr 19, 2011 at 10:17 AM, Rance Hall wrote: >>> > pseudo code: >>> > >>> > >>> > message = "Bah." >>> > >>> > if

Re: Noob Question

2011-04-19 Thread Dan Stromberg
On Tue, Apr 19, 2011 at 7:55 AM, Rob McGillivray wrote: > Hi All, > > I'm new to Python, and trying to get python 3.2 installed on Centos 5.6. When > I run 'make test', I receive several errors. The readme states that you can > generally ignore messages about skipped tests, but as you can see be

Re: Pickling over a socket

2011-04-19 Thread Dan Stromberg
On Tue, Apr 19, 2011 at 11:53 AM, Roger Alexander wrote: > Hi, > > I'm trying to understand how to pickle Python objects over a TCP > socket. > > In the example below (based on code from Foundations of Python Network > Programming), a client creates a dictionary (lines 34-38) and uses > pickle.dum

Re: Teaching Python

2011-04-19 Thread Dan Stromberg
On Tue, Apr 19, 2011 at 4:03 PM, geremy condra wrote: > On Tue, Apr 19, 2011 at 3:42 PM, Passiday wrote: >> Hello, >> >> I am planning to teach Python to a group of high school students, who have >> in-depth interest in programming, hacking etc. >> >> I am looking for some good material, what I

Re: Teaching Python

2011-04-19 Thread Dan Stromberg
On Tue, Apr 19, 2011 at 3:42 PM, Passiday wrote: > Hello, > > I am planning to teach Python to a group of high school students, who have > in-depth interest in programming, hacking etc. > > I am looking for some good material, what I could use as a basic guide when > preparing the classes plan f

Re: Problem receiving UDP broadcast packets.

2011-04-19 Thread Dan Stromberg
On Tue, Apr 19, 2011 at 3:21 PM, Grant Edwards wrote: > I'm have problems figuring out how to receive UDP broadcast packets on > Linux. > > Here's the receiving code: > > --receive.py--- > But, the receiving Python program never sees any pac

Re: Problem receiving UDP broadcast packets.

2011-04-19 Thread Dan Stromberg
On Tue, Apr 19, 2011 at 4:40 PM, Irmen de Jong wrote: > On 20-4-2011 1:21, Grant Edwards wrote: >> >> If I don't call bind(), then the broadcast packets go out the wrong >> interface on the sending machine. >> > > Fair enough. > > Next issue then: as far as I know, broadcast packets are by default

Re: Problem receiving UDP broadcast packets.

2011-04-19 Thread Dan Stromberg
On Tue, Apr 19, 2011 at 6:15 PM, Grant Edwards wrote: >> Or can you simply use a stupid netmask like /1 that picks up all the >> IP ranges? That way, the source-IP check wouldn't fail. > > That would require that the device somehow knows that it's not > configured correctly and should change the

Re: Problem receiving UDP broadcast packets.

2011-04-19 Thread Dan Stromberg
On Tue, Apr 19, 2011 at 8:12 PM, Dan Stromberg wrote: > I agree though that you're kind of pushing IP in a direction it wasn't > intended to go. It just occurred to me: You might get some additional mileage out of popping the network adapter into promiscuous mode. In fact, it Mi

Re: mystery string code - help!

2011-04-20 Thread Dan M
> As a newbie Pythoner, I understand [] -1] but would some tell me how > '::' does its magic? > > Uncle Ben The -1 is the "stride" or "step" argument. It's described at http://docs.python.org/release/2.3.5/whatsnew/section-slices.html Dan -- http://mail.python.org/mailman/listinfo/python-list

Re: Problem receiving UDP broadcast packets.

2011-04-20 Thread Dan Stromberg
On Wed, Apr 20, 2011 at 7:21 AM, Grant Edwards wrote: > On 2011-04-20, Dan Stromberg wrote: >> On Tue, Apr 19, 2011 at 8:12 PM, Dan Stromberg wrote: >>> I agree though that you're kind of pushing IP in a direction it wasn't >>> intended to go. >> &g

Re: About threads in python

2011-04-21 Thread Dan Stromberg
On Thu, Apr 21, 2011 at 6:19 AM, dutche wrote: > Hi folks, how are ya? > > Here's the thing...I had to make a program with threads and after > finished, I found some posts and articles in Google about Python and > threads, raising the question about if it really implements thread > programming or

Re: learnpython.org - an online interactive Python tutorial

2011-04-21 Thread Dan Stromberg
On Thu, Apr 21, 2011 at 9:13 AM, MRAB wrote: > On 21/04/2011 15:14, Westley Martínez wrote: > >> On Thu, Apr 21, 2011 at 05:19:29PM +1000, Chris Angelico wrote: >> >>> On Thu, Apr 21, 2011 at 5:10 PM, Algis Kabaila >>> wrote: >>> False: Python IS strongly typed, without doubt (though the >>

Re: shared dictionary of dictionaries with Manager

2011-04-22 Thread Dan Stromberg
2011/4/21 Darío Suárez Gracia > Hi all, > I was trying to share a dictionary of dictionaries of arrays with Manager > from multiprocessing. Without multiprocessing the code works perfectly, but > with the current example the last print does not show the correct result. > It appears that if you p

Re: learnpython.org - an online interactive Python tutorial

2011-04-22 Thread Dan Stromberg
On Thu, Apr 21, 2011 at 11:38 PM, harrismh777 wrote: > > Yes. And you have managed to point out a serious flaw in the overall logic > and consistency of Python, IMHO. > > Strings should auto-type-promote to numbers if appropriate. Please no. It's a little more convenient sometimes when you're c

Re: Run a few Python commands from a temporary filesystem when the rootfs is halted

2011-04-22 Thread Dan Stromberg
You could open a pivot_root subprocess using the subprocess module, or you could run pivot_root() directly using ctypes. I doubt any preexisting Python module wraps pivot_root(), but I'd love to be surprised. You may find that your Python module path does amusing things right after the pivot, so

Re: How to concatenate unicode strings ???

2011-04-26 Thread Dan Stromberg
On Tue, Apr 26, 2011 at 8:58 AM, Ariel wrote: > Hi everybody, how could I concatenate unicode strings ??? > What I want to do is this: > > unicode('this an example language ') + unicode('español') > > but I get an: > Traceback (most recent call last): >   File "", line 1, in > UnicodeDecodeError:

Re: Terrible FPU performance

2011-04-26 Thread Dan Goodman
don't know much about them though, so I can't advise any further than that... Dan -- http://mail.python.org/mailman/listinfo/python-list

Re: Terrible FPU performance

2011-04-26 Thread Dan Stromberg
On Tue, Apr 26, 2011 at 6:40 AM, Mihai Badoiu wrote: > Hi, > I have terrible performance for multiplication when one number gets very > close to zero.  I'm using cython by writing the following code: >     cdef int i >     cdef double x = 1.0 >     for 0 <= i < 1000: >         x *= 0.8 >      

Re: Reading Huge UnixMailbox Files

2011-04-26 Thread Dan Stromberg
On Tue, Apr 26, 2011 at 12:39 PM, Brandon McGinty wrote: > List, > I'm trying to import hundreds of thousands of e-mail messages into a > database with Python. > However, some of these mailboxes are so large that they are giving > errors when being read with the standard mailbox module. > I create

Re: client-server parallellised number crunching

2011-04-26 Thread Dan Stromberg
On Tue, Apr 26, 2011 at 12:55 PM, Hans Georg Schaathun wrote: > I wonder if anyone has any experience with this ... > > I try to set up a simple client-server system to do some number > crunching, using a simple ad hoc protocol over TCP/IP.  I use > two Queue objects on the server side to manage t

Re: client-server parallellised number crunching

2011-04-26 Thread Dan Stromberg
On Tue, Apr 26, 2011 at 1:20 PM, Chris Angelico wrote: > But question: Why are you doing major number crunching in Python? On > your quad-core machine, recode in C and see if you can do the whole > job without bothering the unreliable boxen at all. Hmm, or try Cython or PyPy. ^_^ Here's that g

Re: Development tools and practices for Pythonistas

2011-04-26 Thread Dan Stromberg
On Tue, Apr 26, 2011 at 11:04 AM, Jean-Michel Pichavant wrote: > You can have a look at SVN and bugzilla, they are free SCM & bug tracker > applications. > Make sure it's worth the pain though, these tools are not that easy to > administrate (the usage is pretty simple). http://trac.edgewall.org/

Re: Reading Huge UnixMailbox Files

2011-04-26 Thread Dan Stromberg
On Tue, Apr 26, 2011 at 1:23 PM, Nobody wrote: > E.g. the following script reads a mailbox on stdin and writes a separate > file for each message: > >        #!/usr/bin/awk -f >        BEGIN { >                num = 0; >                ofile = ""; >        } > >        /^From / { >                

Re: Have you read the Python docs lately?

2011-04-27 Thread Dan Stromberg
On Wed, Apr 27, 2011 at 10:56 AM, Raymond Hettinger wrote: > A number of developers have been working on adding examples and useful > advice to the docs.  To sharpen your skills, here are some pieces of > recommended reading: > > http://docs.python.org/dev/library/heapq.html#priority-queue-impleme

Re: Reliably call code after object no longer exists or is "unreachable"?

2011-04-27 Thread Dan Stromberg
On Wed, Apr 27, 2011 at 5:54 PM, Thomas 'PointedEars' Lahn < pointede...@web.de> wrote: > Jack Bates wrote: > > Faced with the real potential for reference cycles, how can you reliably > > call code - but wait until an object no longer exists or is > > "unreachable"? > > For normal program termina

Re: socket.gethostbyaddr() wrongly returning a DNS CNAME as the 'primary' hostname

2011-04-28 Thread Dan Stromberg
On Thu, Apr 28, 2011 at 1:18 PM, cjblaine wrote: > Thanks for the reply, Ned. > > Bummer for me. Check this out: > > C code on Solaris 10 SPARC returns the following with nscd > running (the Solaris Naming Services Caching Daemon, on by > default): > I'm guessing the IP's PTR record is pointing

Re: Composition instead of inheritance

2011-04-28 Thread Dan Stromberg
On Thu, Apr 28, 2011 at 3:35 PM, Carl Banks wrote: > On Thursday, April 28, 2011 10:15:02 AM UTC-7, Ethan Furman wrote: >> For anybody interested in composition instead of multiple inheritance, I >> have posted this recipe on ActiveState (for python 2.6/7, not 3.x): >> >> http://code.activestate.c

Re: Compile 32bit C-lib on 64 bit

2011-05-01 Thread Dan Stromberg
On Sun, May 1, 2011 at 1:14 PM, Hegedüs Ervin wrote: > Hello, > > this is not a "clear" Python question - I've wrote a module in C, > which uses a 3rd-party lib - it's a closed source, I just get the > .so, .a and a header file. > > Looks like it works on 32bit (on my desktop), but it must be run

Re: Py / VNC Automation

2011-05-02 Thread Dan Stromberg
On Mon, May 2, 2011 at 5:23 PM, PyNewbie wrote: > Hi, > I'm looking for a python class or open source code that is tightly > integrated with VNC protocols - any ideas? > -- > http://mail.python.org/mailman/listinfo/python-list > I've not updated this in a while, but it's got a python vnc viewer

Re: Recursion or iteration (was Fibonacci series recursion error)

2011-05-02 Thread Dan Stromberg
On Mon, May 2, 2011 at 7:13 PM, Chris Angelico wrote: > On Tue, May 3, 2011 at 11:48 AM, rusi wrote: > > What are their space/time complexities? > > Which do you prefer? > > They're pretty similar actually. If you rework the first one to not > use range() but instead have a more classic C style

Re: Recursion or iteration (was Fibonacci series recursion error)

2011-05-02 Thread Dan Stromberg
On Mon, May 2, 2011 at 10:29 PM, Chris Angelico wrote: > On Tue, May 3, 2011 at 3:27 PM, Dan Stromberg wrote: > > > > But the recursive solution has time complexity of O(logn). The iterative > > solution has time complexity of O(n). That's a significant differ

Re: Recursion or iteration (was Fibonacci series recursion error)

2011-05-03 Thread Dan Stromberg
On Tue, May 3, 2011 at 5:49 AM, Steven D'Aprano < steve+comp.lang.pyt...@pearwood.info> wrote: > On Tue, 03 May 2011 21:04:07 +1000, Chris Angelico wrote: > > > And that, Your Honour, is why I prefer bignums (especially for integers) > > to floating point. Precision rather than performance. > > I'

Re: Appending to dictionary of lists

2011-05-03 Thread Dan Stromberg
On Tue, May 3, 2011 at 12:56 PM, Paul Rubin wrote: > "Alex van der Spek" writes: > > refd=dict.fromkeys(csvr.fieldnames,[]) ... > > I do not understand why this appends v to every key k each time. > > You have initialized every element of refd to the same list. Try > >refd = dict((k,[]) fo

Re: Hooking into Python's memory management

2011-05-04 Thread Dan Stromberg
Sturla had some great comments; I'll add, in no particular order: 1) You could use the ctypes module to call the real malloc and free from Python. 2) Yes, a Python "C extension module" can do explicit memory allocation. 3) Cython provides a language that is a hybrid of Python and C. It might be n

Re: Basic interaction with another program

2011-05-04 Thread Dan Stromberg
On Wed, May 4, 2011 at 9:34 AM, ETP wrote: > I have a dos program (run in a window) that I would like to control > with a script. It needs only text input. > > It will then wait for a file to be created, rename the file, then > loop. Simple. > Or not. > I'd like to run this on Lucid Puppy Li

Re: avro slow?

2011-05-05 Thread Dan Stromberg
On Thu, May 5, 2011 at 2:12 PM, Miki Tebeka wrote: > Greetings, > > I'm reading some data from avro file using the avro library. It takes about > a minute to load 33K objects from the file. This seem very slow to me, > specially with the Java version reading the same file in about 1sec. > You mi

Re: is there an autocompletion like Dasher ?

2011-05-07 Thread Dan Stromberg
On Sat, May 7, 2011 at 3:40 PM, Stef Mientki wrote: > hello, > > I would like to have a autocompletion / help /snippet system like Dasher : > > http://www.inference.phy.cam.ac.uk/dasher/ > > anyone seen such a component ? > Ummm... For what OS and what hardware? Do you need something that was

Re: Dictionary from String?

2011-05-08 Thread Dan Stromberg
On Sun, May 8, 2011 at 8:20 AM, Greg Lindstrom wrote: > Is it possible to create a dictionary from a string value? Something along > these lines (but that works): > > >>> mystring = "{'name':'greg','hatsize':'7 5/8'}" > >>> mystring > "{'name':'greg','hatsize':'7 5/8'}" > >>> dict(mystring) > Tra

Re: checking if a list is empty

2011-05-08 Thread Dan Stromberg
On Sun, May 8, 2011 at 3:41 PM, Terry Reedy wrote: > On 5/8/2011 10:07 AM, Steven D'Aprano wrote: > > Because the test of "is this nothing, or something?" is a common, useful >> test: >> > > Because inductive algorithms commonly branch on 'input is something' (not > done, change args toward 'not

Python backup programs?

2011-05-10 Thread Dan Stromberg
What are your favorite backup programs written, in whole or in part, in Python? What do you like about them? Dislike about them? Are there any features you wish your backup program had, whether in Python or not? Thanks! -- http://mail.python.org/mailman/listinfo/python-list

Re: Parsing a graph image

2011-05-13 Thread Dan Stromberg
You could convert the image to a netpbm format, like ppm, pgm or pbm. If the image has few colors, that should be quite viable. Each of these formats are easy to work with in Python. ppm is for color, pgm is for grayscale, pbm is for strictly black and white, pnm pertains to any of the 3. There

Re: Memcached in python 3

2011-05-16 Thread Dan Stromberg
Do you need something shared across multiple hosts? Across multiple CPU's of the same host? Or single process? By "Python Dictionary Manager", do you mean the manager stuff in the multiprocessing module? On Sun, May 15, 2011 at 9:52 PM, Navkirat Singh wrote: > Hi Guys, > > How can I used memc

Re: ipython prompt does not appear in windows

2011-05-17 Thread Dan Stromberg
Try running ipython in a cmd.exe. If that works, it almost certainly means that the I/O is going directly to video RAM instead of through a disciplined API. On Tue, May 17, 2011 at 12:00 AM, rusi wrote: > If I use ipython under emacs on linux it works (at least basic REPL) > ie I can type an ex

Re: Problem with multiprocessing

2011-05-19 Thread Dan Stromberg
Share as little as possible between your various processes - shared, mutable state is a parallelism tragedy. If you can avoid sharing an entire dictionary, do so. It'd probably be better to dedicate one process to updating your dictionary, and then using a multiprocessing.Queue to pass delta reco

Re: Abandoning Python

2011-05-21 Thread Dan Stromberg
On Sat, May 21, 2011 at 8:49 AM, John J Lee wrote: > > > I still like Python after using it for over a decade, but there are > things I don't like. > > What are your favourite up-and-coming languages of the moment? > > Here's my wishlist (not really in any order): > > * A widely used standard f

Re: Abandoning Python

2011-05-21 Thread Dan Stromberg
On Sat, May 21, 2011 at 9:00 AM, John Bokma wrote: > > A language I want to give a serious try the coming months is Haskell. > > Haskell is indeed interesting. However, do any of Haskell's implementations exploit the opportunities for parallelism that Haskell's definition allows? -- http://mail

Re: Abandoning Python

2011-05-21 Thread Dan Stromberg
On Sat, May 21, 2011 at 6:25 PM, Daniel Kluev wrote: > Also, most of these complaints could be solved by using correct python > dialect for particular task - RPython, Cython and so on. > Cython is an interesting dialect that I use now and then. RPython is probably just as well avoided. PyPy, w

Re: Why did Quora choose Python for its development?

2011-05-21 Thread Dan Stromberg
On Fri, May 20, 2011 at 1:47 PM, Dotan Cohen wrote: > They considered Haskell and OCaml and not a single mention of Perl? > Perl is like 10 languages smushed together. To write it, you need only learn one of the 10. To read someone else's, you don't know what subset of those 10 they've used u

Re: Abandoning Python

2011-05-22 Thread Dan Stromberg
On Sun, May 22, 2011 at 10:33 AM, John Lee wrote: > Dan Stromberg gmail.com> writes: > > > On Sat, May 21, 2011 at 8:49 AM, John J Lee pobox.com> wrote: > > > > I still like Python after using it for over a decade, but there are > > things I don't

Re: changing current dir and executing a shell script

2011-05-27 Thread Dan Stromberg
Each command will be run in a distinct subprocess. A CWD is typically local to a given subprocess. So after the first command/subprocess exits, your cd's change is no longer there. Try doing it in one command, with the two original commands separated by a semicolon. On Fri, May 27, 2011 at 2:25

Re: Beginner needs advice

2011-05-27 Thread Dan Stromberg
On Fri, May 27, 2011 at 7:40 AM, harrismh777 wrote: > Colin J. Williams wrote: > >> It would be safer to stick with Python 2.7 initially and then consider >> the transition to 3.2 later. >> > > I must disagree with Colin's statement. If you are a complete beginner with > Python... then there is go

Re: How to catch a line with Popen

2011-05-28 Thread Dan Stromberg
On Sat, May 28, 2011 at 4:32 PM, Tim Roberts wrote: > TheSaint wrote: > > > >I'm looking into subprocess.Popen docs. > >I've launch the program with its arguments and that's smooth. I'm > expecting > >to read the output by *comunicate()* at every line that prgram may blow > >during the process,

Re: scope of function parameters (take two)

2011-05-30 Thread Dan Stromberg
On Mon, May 30, 2011 at 5:28 PM, Henry Olders wrote: > What I would like is that the variables which are included in the function > definition's parameter list, would be always treated as local to that > function (and of course, accessible to nested functions) but NOT global > unless explicitly de

Re: Old Man Yells At Cloud

2017-09-18 Thread Dan Sommers
7;s usually while I'm developing an algorithm, and then I can decide whether or not and when to coerce the result to floating point. Dan -- https://mail.python.org/mailman/listinfo/python-list

Re: Beginners and experts (Batchelder blog post)

2017-09-27 Thread Dan Sommers
sn't apply to programmers. It's the same whether you use Python, something else, or some combination. Wow, that's a lot more than I intended to write. I don't mean to be discouraging, only enlightening. We all started somewhere, and your background as a sysadmin puts you way ahead of a lot of future programmers. HTH, Dan -- https://mail.python.org/mailman/listinfo/python-list

Re: The "loop and a half"

2017-10-05 Thread Dan Sommers
are designed to work together in a pipe; the output from "diff -e" can be piped into ed to make ed apply changes to a file. Dan -- https://mail.python.org/mailman/listinfo/python-list

Re: Coding style in CPython implementation

2017-10-28 Thread Dan Sommers
g, and grayscale printers (and we had to live in a small shoebox in the middle of the road). YMMV. Obviously. Dan -- https://mail.python.org/mailman/listinfo/python-list

Re: Where is ^ (symmetric_difference) documented in help()?

2017-12-22 Thread Dan Sommers
gt; s ^ t It's sort of documented in help(set): | __xor__(self, value, /) | Return self^value. HTH, Dan -- https://mail.python.org/mailman/listinfo/python-list

PSF grant for "Shed Skin" to python 3.x?

2018-01-11 Thread Dan Stromberg
Hi folks. Is anyone on the list familiar with the process of getting a Python Software Foundation grant awarded to a worthy project? And with what's generally considered "worthy"? I found https://www.python.org/psf/records/board/resolutions/ , but almost all of the grants seem to be for conferen

Re: Where is the usage of (list comprehension) documented?

2018-01-14 Thread Dan Stromberg
On Sun, Jan 14, 2018 at 3:01 PM, Peng Yu wrote: > Hi, > > I see the following usage of list comprehension can generate a > generator. Does anybody know where this is documented? Thanks. Here's the (a?) generator expression PEP: https://www.python.org/dev/peps/pep-0289/ Here's a presentation I pu

Re: Very strange issues with collections.Mapping

2018-01-18 Thread Dan Stromberg
Probably not what you want to hear, but this might be a good place for an SSCCE. On Thu, Jan 18, 2018 at 1:37 PM, Jason Swails wrote: > Hello! > > I am running into a very perplexing issue that is very rare, but creeps up > and is crashing my app. > > The root cause of the issue comes down to the

Re: error from Popen only when run from cron

2018-01-27 Thread Dan Stromberg
If you have your script set $PATH and $HOME, you can test it with: env - ./my-script The difference between running a script from the command line, and running a script from cron, is often environment variables. env - clears the environment. On Sat, Jan 27, 2018 at 7:58 AM, Larry Martell wrote:

Re: Data-structure for multiway associativity in Python

2018-01-27 Thread Dan Stromberg
It's possible, but not common, to do association lists in Python. They're pretty inefficient in just about any language. I'm not totally clear on what you need, but it might be a good thing to do a list of sets - if you're looking for an in-memory solution. On Sat, Jan 27, 2018 at 10:33 AM, Denni

Re: Sentiment analysis using sklearn

2018-01-27 Thread Dan Stromberg
On Sat, Jan 27, 2018 at 1:05 PM, qrious wrote: > I am attempting to understand how scikit learn works for sentiment analysis > and came across this blog post: > > https://marcobonzanini.wordpress.com/2015/01/19/sentiment-analysis-with-python-and-scikit-learn > > The corresponding code is at this

Re: Please help on print string that contains 'tab' and 'newline'

2018-01-28 Thread Dan Stromberg
How about: >>> os.write(1, message) On Sun, Jan 28, 2018 at 4:51 PM, Jason Qian via Python-list wrote: > print(repr(message)) out : > > *does not exist\r\n\tat com.* > > > for ch in message: > printf("%d %c",ch, chr(ch)) > > > %d %c 110 n > %d %c 111 o > %d %c 116 t > %d %c 32 > %d %c 101 e >

Re: Where has the practice of sending screen shots as source code come from?

2018-01-28 Thread Dan Stromberg
I'm afraid the perspective may be: Text == primitive GUI == modern It feel like it'd be possible to train a neural network to translate text in a screenshot to plain text though. On Sun, Jan 28, 2018 at 7:04 AM, Steven D'Aprano wrote: > I'm seeing this annoying practice more and more often. Even

Re: Where has the practice of sending screen shots as source code come from?

2018-01-28 Thread Dan Sommers
On Mon, 29 Jan 2018 00:27:07 +, Steven D'Aprano wrote: > On Mon, 29 Jan 2018 08:55:54 +1100, Tim Delaney wrote: > >> I got back a Word document containing about 10 screenshots where they'd >> apparently taken a screenshot, moved the horizontal scrollbar one >> screen, taken another screenshot

Re: Please help on print string that contains 'tab' and 'newline'

2018-01-28 Thread Dan Stromberg
On Sun, Jan 28, 2018 at 5:35 PM, Steven D'Aprano wrote: > On Sun, 28 Jan 2018 17:04:56 -0800, Dan Stromberg wrote: >> How about: >>>>> os.write(1, message) > > What do you think that will do that print() doesn't do? >>> message = b'*does n

Re: Please help on print string that contains 'tab' and 'newline'

2018-01-28 Thread Dan Stromberg
On Sun, Jan 28, 2018 at 6:04 PM, Steven D'Aprano wrote: > On Sun, 28 Jan 2018 17:49:44 -0800, Dan Stromberg wrote: > So what was the clue that it was bytes that you saw that (nearly) > everyone else missed? Especially me. Can I get away with saying "it was just a good guess

Re: Where has the practice of sending screen shots as source code come from?

2018-01-28 Thread Dan Stromberg
On Sun, Jan 28, 2018 at 5:46 PM, Steven D'Aprano wrote: > On Sun, 28 Jan 2018 17:13:05 -0800, Dan Stromberg wrote: >> It feel like it'd be possible to train a neural network to translate >> text in a screenshot to plain text though. > > That would be OCR, which has

Re: Where has the practice of sending screen shots as source code come from?

2018-01-28 Thread Dan Stromberg
On Sun, Jan 28, 2018 at 8:24 PM, Dan Stromberg wrote: > If an NN can ... play go on a level that can beat the best human in the > world Correcting myself: I think Google's AlphaGo used more than one NN, plus perhaps a little traditional reading algorithm. So I probably should have sa

Re: python not working

2018-01-29 Thread Dan Stromberg
Please google for "pythonw.exe system error: The program can't start because api-ms-win-crt-runtime-|1-1-0.dll is missing from your computer. try reinstalling the program to fix this problem.". I believe the Windows binaries for Python are built with a proprietary compiler that requires a separa

Re: New to Python and understanding problem

2018-01-29 Thread Dan Stromberg
On Mon, Jan 29, 2018 at 9:01 AM, Michelle Konzack wrote: > OK, I tried to install "blueman" (Bluetooth Manager) on my Debian 9.2 > (Stretch system and discovered a problem: > > [ c 'blueman-applet' ]-- > Traceback (most recent call last): > File

<    1   2   3   4   5   6   7   8   9   10   >