Re: Noob question on 2 vs 3 Python releases

2010-11-14 Thread Dan Stromberg
On Sun, Nov 14, 2010 at 1:03 AM, Franck Ditter wrote: > Pardon my noobness (?) but why is there a 2.x and 3.x development > teams working concurrently in Python ? I hardly saw that in other > languages. Which one should I choose to start with, to cope with > the future ? Isn't 3.x supposed to ext

Re: Is Unladen Swallow dead?

2010-11-16 Thread Dan Stromberg
I'm not a contributor to the U-S project, but I have been monitoring alternative python implementations' progress some, and seem to be adding something to pypy all of a sudden. I think unladen swallow has produced performance improvements, and they are likely to be merged into cpython 3.3. Howeve

Re: remote server and effective uid

2010-11-16 Thread Dan Stromberg
On Tue, Nov 16, 2010 at 9:37 AM, Tim Arnold wrote: > "Tim Harig" wrote in message > news:ibs8h9$jm...@speranza.aioe.org... > > On 2010-11-15, Tim Arnold wrote: > >> On Nov 15, 10:41 am, Tim Harig wrote: > >>> On 2010-11-15, Tim Arnold wrote: > >>> > >>> > How can I enable the server process t

Re: simple(?) Python C module question

2010-11-17 Thread Dan Stromberg
On Wed, Nov 17, 2010 at 7:42 PM, Terry Reedy wrote: > On 11/17/2010 7:25 PM, Mark Crispin wrote: > > Have you looked at ctypes? It's not suitable for all libraries, but >>> it can often obviate the need to write any C code: >>> http://docs.python.org/release/2.6.6/library/ctypes.html#module-ctyp

Re: Is Unladen Swallow dead?

2010-11-18 Thread Dan Stromberg
On Thu, Nov 18, 2010 at 4:24 AM, BartC wrote: > "John Nagle" wrote in message > news:4ce37e01$0$1666$742ec...@news.sonic.net... > > On 11/16/2010 10:24 PM, swapnil wrote: >> > > AFAIK, the merging plan was approved by Guido early this year. I guess >>> Google is expecting the community to driv

Re: Changing the EAX register with Python

2010-11-18 Thread Dan Stromberg
Here's -a- way to try - not necessarily the best way: 1) Write a little gcc .c with inline assembler, to make your EAX change 2) Call it from CPython using ctypes However, by the time you return from the code that makes your change and resume execution in the CPython interpreter, EAX may well have

Reading lines of null-terminated text?

2010-11-29 Thread Dan Stromberg
What's the best way of reading lines of null terminated (ASCII NUL, \0) text in Python 2.x? How about for 3.x? I've been using http://stromberg.dnsalias.org/~strombrg/readline0.html with 2.x, but I'm moving some of my stuff to 3.x, and am wondering if there's a way that would obviate readline0.

Python 3 encoding question: Read a filename from stdin, subsequently open that filename

2010-11-29 Thread Dan Stromberg
I've got a couple of programs that read filenames from stdin, and then open those files and do things with them. These programs sort of do the *ix xargs thing, without requiring xargs. In Python 2, these work well. Irrespective of how filenames are encoded, things are opened OK, because it's all

Re: Python 3 encoding question: Read a filename from stdin, subsequently open that filename

2010-11-30 Thread Dan Stromberg
On Tue, Nov 30, 2010 at 11:47 AM, Martin v. Loewis wrote: >> Does anyone know what I need to do to read filenames from stdin with >> Python 3.1 and subsequently open them, when some of those filenames >> include characters with their high bit set? > > If your files on disk use file names encoded i

Re: Python 3 encoding question: Read a filename from stdin, subsequently open that filename

2010-11-30 Thread Dan Stromberg
On Tue, Nov 30, 2010 at 7:19 AM, Antoine Pitrou wrote: > On Mon, 29 Nov 2010 21:52:07 -0800 (PST) > Yingjie Lan wrote: >> --- On Tue, 11/30/10, Dan Stromberg wrote: >> > In Python 3, I'm finding that I have encoding issues with >> > characters >> > wi

Re: Python 3 encoding question: Read a filename from stdin, subsequently open that filename

2010-11-30 Thread Dan Stromberg
On Tue, Nov 30, 2010 at 9:53 AM, Peter Otten <__pete...@web.de> wrote: > $ ls > $ python3 > Python 3.1.1+ (r311:74480, Nov  2 2009, 15:45:00) > [GCC 4.4.1] on linux2 > Type "help", "copyright", "credits" or "license" for more information. with open(b"\xe4\xf6\xfc.txt", "w") as f: > ...     f.w

Re: How to initialize each multithreading Pool worker with an individual value?

2010-11-30 Thread Dan Stromberg
On Tue, Nov 30, 2010 at 1:35 PM, Valery Khamenya wrote: > Hi, > > multithreading.pool Pool has a promissing initializer argument in its > constructor. > However it doesn't look possible to use it to initialize each Pool's > worker with some individual value (I'd wish to be wrong here) > > So, how

Intro to Python slides, was Re: how to go on learning python

2010-11-30 Thread Dan Stromberg
On Tue, Nov 30, 2010 at 6:37 AM, Xavier Heruacles wrote: > I'm basically a c/c++ programmer and recently come to python for some web > development. Using django and javascript I'm afraid I can develop some web > application now. But often I feel I'm not good at python. I don't know much > about ge

Unicode thing that causes a traceback in 2.6 and 2.7 but not in 2.5, and only when writing to a pipe, not to the terminal

2010-12-01 Thread Dan Stromberg
What is this about? It's another n~ thing, but this time in 2.x. All I'm doing is printing a str containing a character > 127. It works fine in 2.5, to a terminal or to a pipe. In 2.6 and 2.7, it fails when writing to a pipe but works fine writing to my terminal - an mrxvt.\ I really kind of wa

Re: Print recent CGI error

2010-12-04 Thread Dan Stromberg
I've sometimes got similar situations in CGI, that turned out to be because of a syntax error that kept apache from being able to run the script. What if you just run the script at the command line? It should either error out due to lack of a CGI environment/arguments, but hopefully it'll give yo

Re: Which non SQL Database ?

2010-12-05 Thread Dan Stromberg
On Sun, Dec 5, 2010 at 12:01 AM, John Nagle wrote: > On 12/4/2010 8:44 PM, Monte Milanuk wrote: >> >> On 12/4/10 3:43 PM, Jorge Biquez wrote: >> >>> I do not see a good reason for not using Sqlite3 BUT if for some reason >>> would not be an option what plain schema of files would you use? >> >

Re: Python 3 encoding question: Read a filename from stdin, subsequently open that filename

2010-12-05 Thread Dan Stromberg
m the same code. On Mon, Nov 29, 2010 at 9:26 PM, Dan Stromberg wrote: > I've got a couple of programs that read filenames from stdin, and then > open those files and do things with them.  These programs sort of do > the *ix xargs thing, without requiring xargs. > > In

Re: del operator and global namespace

2010-12-08 Thread Dan Stromberg
Please try adding "global x" to the beginning of f(). On Wed, Dec 8, 2010 at 10:06 AM, alust wrote: > Hello, > > Can somebody explain this strange (to me) effect please. > > In this program it is impossible to access a global variable within a > function: > > $ cat /tmp/test.py > x='xxx' > def f(

Re: Python critique

2010-12-10 Thread Dan Stromberg
On Fri, Dec 10, 2010 at 3:51 PM, John Nagle wrote: > On 12/10/2010 3:25 PM, Stefan Behnel wrote: >> >> Benjamin Kaplan, 11.12.2010 00:13: >>> >>> On Fri, Dec 10, 2010 at 5:46 PM, Octavian Rasnita wrote: > >>> The only scopes Python has are module and function. > >   There's more.  Both a lambda, a

Re: Generator question

2010-12-22 Thread Dan Stromberg
On Wed, Dec 22, 2010 at 3:15 PM, Victor Eijkhout wrote: > So I have a generator, either as a free function or in a class and I > want to generate objects that are initialized from the generated things. > > def generator(): >        for whatever: >                yield something > class Object(): >

Re: how to handle output generated after execution of command/script on host unix machine?

2010-12-22 Thread Dan Stromberg
On Sun, Dec 19, 2010 at 11:38 PM, Darshak Bavishi wrote: > Hi Experts, > I am still struggling with handling output generated after execution of >  command/script on host unix machine using windows client machine > ssh code : > import sys > import datetime > import time > # setup logging > paramik

Re: Python programming

2010-12-22 Thread Dan Stromberg
If it's a big list and you're checking multiple times, you're probably better off converting the list to a set, and using "in" on the set. Once you have your list converted to a set, you can update both quickly. On Wed, Dec 22, 2010 at 5:22 PM, Maurice Shih wrote: > Dear python-list@python.org,

Re: Keeping track of the N largest values

2010-12-31 Thread Dan Stromberg
On Sat, Dec 25, 2010 at 7:42 AM, Roy Smith wrote: > I'm processing a stream of N numbers and want to keep track of the K > largest.  There's too many numbers in the stream (i.e. N is too large) > to keep in memory at once.  K is small (100 would be typical). > > >From a theoretical point of view,

Re: Is there anyway to run JavaScript in python?

2010-12-31 Thread Dan Stromberg
On Thu, Dec 30, 2010 at 5:52 AM, crow wrote: > Hi, I'm writing a test tool to simulate Web browser. Is there anyway > to run JavaScript in python? Thanks in advance. > -- > http://mail.python.org/mailman/listinfo/python-list > You might also consider Pyjamas, which translates Python (somewhere be

Re: Matrix multiplication

2011-01-04 Thread Dan Stromberg
On Tue, Jan 4, 2011 at 4:22 AM, Zdenko wrote: > On 4.1.2011 11:15, Ulrich Eckhardt wrote: >> >> Zdenko wrote: >>> >>> Please, can anybody write me a simple recursive matrix multiplication >>> using multiple threads in Python, or at least show me some guidelines >>> how to write it myself >> >> No

Re: Matrix multiplication

2011-01-05 Thread Dan Stromberg
On Tue, Jan 4, 2011 at 11:31 PM, Tim Roberts wrote: > Zdenko wrote: >> >>Please, can anybody write me a simple recursive matrix multiplication >>using multiple threads in Python, or at least show me some guidelines >>how to write it myself > > Matrix multiplication is not generally done recursive

Re: Python app dev tools for Gnome?

2011-01-08 Thread Dan Stromberg
On Sat, Jan 8, 2011 at 8:07 AM, kj wrote: > There's a zillion utility apps that I've had kicking around in my > head for years, but I've never implemented because I absolutely > hate GUI programming. > > But I'm increasingly impressed by the quality, stability, and sheer > number, of Gnome apps th

Python use growing fast

2011-01-10 Thread Dan Stromberg
I invite folks to check out Tiobe's Language Popularity Rankings: http://www.tiobe.com/index.php/content/paperinfo/tpci/index.html The gist is: Python grew faster than any other programming language over the last year, according to this (slightly arbitrary, but better than no indicator) ranking.

Re: Python use growing fast

2011-01-10 Thread Dan Stromberg
On Mon, Jan 10, 2011 at 2:29 PM, John Nagle wrote: > On 1/10/2011 1:02 PM, MRAB wrote: >> >> On 10/01/2011 20:29, Dan Stromberg wrote: >>> >>> I invite folks to check out Tiobe's Language Popularity Rankings: >>> >>> http://www.tiobe.com/

Re: Python use growing fast

2011-01-10 Thread Dan Stromberg
On Mon, Jan 10, 2011 at 5:22 PM, Krzysztof Bieniasz wrote: >> Also depends on how one defines "popularity" in the context of >> programming languages. > > Tiobe quite clearly states what they mean by the name "popularity". > Namely the number of Google search results of expressions like > "program

Re: order of importing modules

2011-01-11 Thread Dan Stromberg
On Tue, Jan 11, 2011 at 4:30 PM, Catherine Moroney wrote: > In what order does python import modules on a Linux system?  I have a > package that is both installed in /usr/lib64/python2.5/site-packages, > and a newer version of the same module in a working directory. > > I want to import the versio

Re: order of importing modules

2011-01-12 Thread Dan Stromberg
of the first entries in sys.path. > > A colleague of mine is running on the same system as I am, and he > does not have the problem of the > /usr/lib64/python2.5/site-packages/pyhdfeos-1.0_r57_58-py2.5-linux-x86_64.egg > variable showing up as one of the first entries in sys.path. &g

Re: Elliptic Curve Prime factorisation

2011-01-14 Thread Dan Stromberg
On Fri, Jan 14, 2011 at 11:52 AM, mukesh tiwari wrote: > Hello all , I have implemented Elliptic curve prime factorisation > using wikipedia [ > http://en.wikipedia.org/wiki/Lenstra_elliptic_curve_factorization]. > I think that this code is not optimised and posting for further > improvement. Fee

Re: examples of realistic multiprocessing usage?

2011-01-16 Thread Dan Stromberg
On Sun, Jan 16, 2011 at 11:05 AM, TomF wrote: > I'm trying to multiprocess my python code to take advantage of multiple > cores.  I've read the module docs for threading and multiprocessing, and > I've done some web searches.  All the examples I've found are too simple: > the processes take simple

Re: Efficient python 2-d arrays?

2011-01-17 Thread Dan Stromberg
On Mon, Jan 17, 2011 at 2:20 PM, Jake Biesinger wrote: > Hi all, > > Using numpy, I can create large 2-dimensional arrays quite easily. import numpy mylist = numpy.zeros((1,2), dtype=numpy.int32) > > Unfortunately, my target audience may not have numpy so I'd prefer not to use >

Re: __pycache__, one more good reason to stck with Python 2?

2011-01-18 Thread Dan Stromberg
On Tue, Jan 18, 2011 at 8:27 AM, Peter Otten <__pete...@web.de> wrote: > Stefan Behnel wrote: > >> Peter Otten, 18.01.2011 10:04: >>> What's the advantage of 'find ... | xargs ...' over 'find ... -exec ...'? >> >> The former runs in parallel, the latter runs sequentially. > > This may sometimes be

Re: Efficient python 2-d arrays?

2011-01-20 Thread Dan Stromberg
On Thu, Jan 20, 2011 at 11:36 AM, Jake Biesinger wrote: >> Thanks for the great suggestions! > > On a related note, is there no way to efficiently sort a python array? > > x = array('f', xrange(1000)) x.sort() >

Re: Efficient python 2-d arrays?

2011-01-20 Thread Dan Stromberg
On Thu, Jan 20, 2011 at 4:07 PM, Jacob Biesinger wrote: > On Thu, Jan 20, 2011 at 12:48 PM, Dan Stromberg wrote: >> On Thu, Jan 20, 2011 at 11:36 AM, Jake Biesinger >> wrote: >>>> Thanks for the great suggestions! >>> >>> On a related note, is th

Re: examples of realistic multiprocessing usage?

2011-01-21 Thread Dan Stromberg
On Fri, Jan 21, 2011 at 3:20 AM, Adam Skutt wrote: > On Jan 20, 11:51 pm, Albert van der Horst > wrote: >> This is what some people want you to believe. Arm twisting by >> GPL-ers when you borrow their ideas? That is really unheard of. > > Doesn't matter, you're still legally liable if your work

Re: examples of realistic multiprocessing usage?

2011-01-21 Thread Dan Stromberg
On Fri, Jan 21, 2011 at 12:57 PM, Philip Semanchuk wrote: > On Jan 21, 2011, at 3:36 PM, Dan Stromberg wrote: >> On Fri, Jan 21, 2011 at 3:20 AM, Adam Skutt wrote: >>> On Jan 20, 11:51 pm, Albert van der Horst >>> wrote: >>>> This is what some peop

Re: How to execute foreing code from Python

2011-01-23 Thread Dan Stromberg
On Sun, Jan 23, 2011 at 4:24 PM, Dave Angel wrote: > On 01/-10/-28163 02:59 PM, hid...@gmail.com wrote: >> >> Hello i want to code from different languages using a Python script i >> know i can use os.system, but i don't know how to receive data or send >> arguments using that method if theres any

Re: why are functions greater than numbers?

2011-01-24 Thread Dan Stromberg
On Mon, Jan 24, 2011 at 1:51 PM, Alan wrote: > Why do function objects compare in this way to numbers? > Thanks, > Alan Isaac > > def f(): return > ... f>5 > True > > -- > http://mail.python.org/mailman/listinfo/python-list > They shouldn't, but did in 2.x, and no longer do in 3.x: $ /

Re: Limit on entries in dictionary data structure

2011-01-30 Thread Dan Stromberg
On Sun, Jan 30, 2011 at 6:43 PM, Shruti Sanadhya wrote: > Hi, > I am running a script that uses dictionaries on Python 2.6.4 on Ubuntu 9.10. > I notice that my script crashes with a MemoryError when my dictionary > reaches 44739243th entry. My system has 3GB RAM (32-bit). I noticed that > changing

Re: sending through non-default gateway

2011-02-05 Thread Dan Stromberg
IIRC, this is an instance of what's called "source routing", and was largely shut off after network admins realized it was a security issue. Of course, if you have root/administrator permission, you could probably do it. But if you have that, you could probably just fix the routing table. On Sat

Re: Socket connection between python and C

2011-02-08 Thread Dan Stromberg
On Tue, Feb 8, 2011 at 5:41 PM, Roy Smith wrote: > In article , >  "Williamson, Ross X. (Guest)" >  wrote: > >> Dear All, >> >> I'm trying to implement a server/client system where the server is written in >> python and the client has to be written in c/c++.  I can happily send simple >> text thr

Re: Programmatic Parsing of ps

2011-02-09 Thread Dan Stromberg
On Wed, Feb 9, 2011 at 11:15 AM, Emile van Sebille wrote: > On 2/9/2011 10:58 AM octopusgrabbus said... >> >> I have Python 2.6.6. I would like to get this output >> >> ps -ef | grep 'fglgo csm' >> >> into a list. What is the best way to do that? I've been reading the >> documentation, and am lost

Re: OO Python

2011-02-10 Thread Dan Stromberg
On Wed, Feb 9, 2011 at 1:50 PM, Paul Symonds wrote: > Are there any good resources to learn OO Python from? Yes, plenty, but it's important for us to know so we can advise you: Do you know any other OO languages yet? -- http://mail.python.org/mailman/listinfo/python-list

Re: Programmatic Parsing of ps

2011-02-10 Thread Dan Stromberg
)[stat.ST_UID] > >    if os.getuid() == uid: >        print pid, cmdline > > > For a more cross-platform solution there's a module that does that (I > forgot it's name but with some googling you might find it) > > > > > On Feb 9, 1:34 pm, Dan Stromberg

Re: Class or Dictionary?

2011-02-11 Thread Dan Stromberg
On Fri, Feb 11, 2011 at 6:56 AM, Martin De Kauwe wrote: > Hi, > > I have a series of parameter values which i need to pass throughout my > code (>100), in C I would use a structure for example. However in > python it is not clear to me if it would be better to use a dictionary > or build a class o

Re: Arrays/List, filters, Pytho, Ruby

2011-02-11 Thread Dan Stromberg
On Fri, Feb 11, 2011 at 1:43 PM, André Roberge wrote: > On Friday, February 11, 2011 5:24:15 PM UTC-4, LL.Snark wrote: >> Hi, >> >> I'm looking for a pythonic way to translate this short Ruby code : >> t=[6,7,8,6,7,9,8,4,3,6,7] >> i=t.index {|x| x> >> If you don't know Ruby, the second line means

Re: Arrays/List, filters, Pytho, Ruby

2011-02-11 Thread Dan Stromberg
On Fri, Feb 11, 2011 at 1:51 PM, Dan Stromberg wrote: > On Fri, Feb 11, 2011 at 1:43 PM, André Roberge > wrote: >> On Friday, February 11, 2011 5:24:15 PM UTC-4, LL.Snark wrote: >>> Hi, >>> >>> I'm looking for a pythonic way to translate this sh

Re: Class or Dictionary?

2011-02-11 Thread Dan Stromberg
On Fri, Feb 11, 2011 at 4:13 PM, Steven D'Aprano wrote: > On Fri, 11 Feb 2011 10:15:27 -0800, Dan Stromberg wrote: > > >> I'd use a class rather than a dictionary - because with a class, pylint >> (and perhaps PyChecker and pyflakes?) should be able to detect typ

Re: Class or Dictionary?

2011-02-12 Thread Dan Stromberg
On Fri, Feb 11, 2011 at 10:20 PM, Steven D'Aprano wrote: > On Fri, 11 Feb 2011 21:47:32 -0800, Dan Stromberg wrote: > >> Did you have some sort of bad experience with pylint?  Do you resent the >> 20 minutes it takes to set it up? > > If you read my post more c

Re: How to create a dict based on such a file?

2011-02-14 Thread Dan Stromberg
On Sun, Feb 13, 2011 at 9:47 PM, Wang Coeus wrote: > Hi all, > I am new to python. Currently I encountered a problem, please help me to > solve this. Thanks in advance! > I have a file like below: > ++ > block1 > { >  key1=value1 >  key2=value2 >  key3=value3 >

Re: How to create a dict based on such a file?

2011-02-14 Thread Dan Stromberg
On Mon, Feb 14, 2011 at 3:06 PM, Steven D'Aprano wrote: > On Mon, 14 Feb 2011 11:25:00 -0800, Dan Stromberg wrote: > >> FWIW, the creator of the many .ini format(s), Microsoft, no longer >> recommends using .ini files. > > That's because they want people to u

Re: How to create a dict based on such a file?

2011-02-14 Thread Dan Stromberg
On Mon, Feb 14, 2011 at 8:31 PM, Westley Martínez wrote: > On Mon, 2011-02-14 at 19:41 -0800, alex23 wrote: >> On Feb 15, 9:06 am, Steven D'Aprano > +comp.lang.pyt...@pearwood.info> wrote: >> > As I see it, the biggest problems with INI files are: >> > >> > * the INI file module that comes with Py

Re: Missing SIGCHLD

2011-02-15 Thread Dan Stromberg
On Tue, Feb 15, 2011 at 2:57 AM, Dinh wrote: > Hi, > > I currently build a process management system which is able to fork child > processes (fork()) and keep them alive (waitpid() ). > > if pid in self.current_workers: > os.waitpid(pid, 0) > > If a child process dies

Re: Editor/IDE with Python coverage support?

2011-02-16 Thread Dan Stromberg
I use vim, but I've considered switching to pycharm. I don't know if pycharm does this or not. Anyway, coverage.py will produce an HTML report describing how well your automated tests cover your code - I like to add it into my Makefile's default rule, and then view the HTML once in a while using

Re: How to use Python well?

2011-02-16 Thread Dan Stromberg
On Wed, Feb 16, 2011 at 10:35 AM, snorble wrote: > I use Python a lot, but not well. I usually start by writing a small > script, no classes or modules. Then I add more content to the loops, > and repeat. It's a bit of a trial and error learning phase, making > sure I'm using the third party modul

Re: Best way to gain root privileges

2011-02-16 Thread Dan Stromberg
On Wed, Feb 16, 2011 at 4:47 PM, Alexander Kapps wrote: > On 17.02.2011 01:00, GSO wrote: >> Having said that I'm possibly arriving at the conclusion that a quick >> perl script might be the simplest/easiest and most secure option - I >> read perl includes code to safely run suid perl scripts - wi

Re: Best way to gain root privileges

2011-02-16 Thread Dan Stromberg
On Wed, Feb 16, 2011 at 6:10 PM, GSO wrote: >> pretty much better off with sudo, or a tiny C wrapper that's so simple >> it's hard to get wrong.  However, perl's taint feature would be useful > > This snippet is about as tiny as it gets in C I think: Well, it could be tinier really, and actually,

Re: Best way to gain root privileges

2011-02-16 Thread Dan Stromberg
On Wed, Feb 16, 2011 at 6:59 PM, Adam Skutt wrote: > On Feb 16, 9:00 pm, Dan Stromberg wrote: >> So yeah, whether you use perl or anything else invoked with #!, you're >> pretty much better off with sudo, or a tiny C wrapper that's so simple >> it's hard to g

Re: client server socket interaction (inetd)

2011-02-17 Thread Dan Stromberg
On Thu, Feb 17, 2011 at 8:14 AM, Tim wrote: > Hi, I have an inetd service on freebsd that calls a program > (daemon.py) with which I want the remote user to communicate. I can > call daemon.py from the command line on the host machine and it works > fine. > > What I don't understand is how to ma

Re: interrupted system call w/ Queue.get

2011-02-17 Thread Dan Stromberg
On Thu, Feb 17, 2011 at 5:46 PM, Philip Winston wrote: > We have a multiprocess Python program that uses Queue to communicate > between processes. Recently we've seen some errors while blocked > waiting on Queue.get: > > IOError: [Errno 4] Interrupted system call > > What causes the exception?

Re: Problems of Symbol Congestion in Computer Languages

2011-02-17 Thread Dan Stromberg
I prefer special symbol "congestion" to special symbol proliferation. A lot. A language with few special symbols looks less like line noise, is easier to read and write, and is easier to google for answers about. I guess nothing's perfect. On Wed, Feb 16, 2011 at 2:07 PM, Xah Lee wrote: > mig

Re: Creating Long Lists

2011-02-21 Thread Dan Stromberg
On Mon, Feb 21, 2011 at 6:57 PM, Kelson Zawack wrote: > I have a large (10gb) data file for which I want to parse each line into an > object and then append this object to a list for sorting and further > processing. I have noticed however that as the length of the list increases > the rate at wh

Re: Creating Long Lists

2011-02-21 Thread Dan Stromberg
On Mon, Feb 21, 2011 at 7:24 PM, Dan Stromberg wrote: > > On Mon, Feb 21, 2011 at 6:57 PM, Kelson Zawack < > zawack...@gis.a-star.edu.sg> wrote: > >> I have a large (10gb) data file for which I want to parse each line into >> an object and then append this ob

Re: Troubles with python internationalization

2010-05-26 Thread Dan Stromberg
On May 25, 10:46 am, Pascal Chambon wrote: > * code safety : it seems default python string formatting technics (% > operator, .format() method) are normally used when one needs to > substitute placeholders in translated strings. But the thing is : I DONT > want my view to raise an exception simp

Re: FIle transfer over network - with Pyro?

2010-06-03 Thread Dan Stromberg
On Jun 3, 10:47 am, Nathan Huesken wrote: > Hi, > > I am writing a network application which needs from time to time do > file transfer (I am writing the server as well as the client). > For simple network messages, I use pyro because it is very comfortable. > But I suspect, that doing a file tran

Re: getting MemoryError with dicts; suspect memory fragmentation

2010-06-04 Thread Dan Stromberg
On Thu, Jun 3, 2010 at 3:43 PM, Emin.shopper Martinian.shopper < emin.shop...@gmail.com> wrote: > Dear Experts, > > I am getting a MemoryError when creating a dict in a long running > process and suspect this is due to memory fragmentation. Any > suggestions would be welcome. Full details of the p

Re: FIle transfer over network - with Pyro?

2010-06-05 Thread Dan Stromberg
On Thu, 03 Jun 2010 20:05:15 +, exarkun wrote: > On 06:58 pm, strom...@gmail.com wrote: >>On Jun 3, 10:47 am, Nathan Huesken wrote: >>>Hi, >>> >>>I am writing a network application which needs from time to time do >>>file transfer (I am writing the server as well as the client). For >>>simple

Re: vector addition

2010-06-07 Thread Dan Stromberg
Call me strange, but I regard this as a good place to use a functional style - IE, to use reduce, and furthermore I regard this as a good example of why reduce is useful for more than just summing numbers: #!/disc/gx/sdfw/dans/python26/bin/python import collections def count_first_letters(dictio

Re: Importing modules

2010-06-07 Thread Dan Stromberg
On Sun, Jun 6, 2010 at 8:16 PM, Ben Finney > wrote: > Anthony Papillion writes: > > > import os > > > > os.path.append('$HOME/gsutils/boto') > > > > thinking I could then successfully do the import boto statement. > > Nope. > > You'll need to give the literal path. Substitution of environment >

Re: vector addition

2010-06-07 Thread Dan Stromberg
On Mon, Jun 7, 2010 at 1:16 PM, Thomas Jollans wrote: > On 06/07/2010 07:45 PM, Dan Stromberg wrote: > > > Call me strange, but I regard this as a good place to use a functional > style - IE, to use reduce, and furthermore I regard this as a good example > of why reduce is us

Re: GUIs - A Modest Proposal

2010-06-08 Thread Dan Stromberg
On Sat, Jun 5, 2010 at 7:22 PM, ant wrote: > I get the strong feeling that nobody is really happy with the state of > Python GUIs. > Tkinter is not widely liked, but is widely distributed. WxPython and > PyGtk are both > powerful, but quirky in different ways. PyQt is tied to one platform. > And

Re: capitalize() NOT the same as var[0].upper _ var[1:]

2010-06-09 Thread Dan Stromberg
On Tue, Jun 8, 2010 at 7:09 PM, alex23 wrote: > > I'm amazed at the endless willingness of this group to help Victor > write his contracted project for free. > > I don't get it. What's wrong with helping people? And what's it to you if others do? -- http://mail.python.org/mailman/listinfo/pyth

Re: GUIs - A Modest Proposal

2010-06-09 Thread Dan Stromberg
On Tue, Jun 8, 2010 at 6:12 PM, geremy condra wrote: > On Tue, Jun 8, 2010 at 4:46 PM, Steven D'Aprano > wrote: > > On Tue, 08 Jun 2010 15:40:51 -0700, geremy condra wrote: > > > >> On Tue, Jun 8, 2010 at 3:09 PM, Lie Ryan wrote: > > > >>> Nobody complains that python included a regular express

Re: Python way to printk?

2010-06-09 Thread Dan Stromberg
I'm not sure of the specifics, but you may find that you can do this with the syslog module - may require reconfiguring syslog.conf or the equivalent though. If you hit an appropriate facility and level, you likely will see syslog messages go to the kernel's dmesg ring buffer. On Wed, Jun 9, 2010

Re: Python way to printk?

2010-06-09 Thread Dan Stromberg
On Wed, Jun 9, 2010 at 3:25 PM, Thomas Jollans wrote: > On 06/09/2010 11:40 PM, J wrote: > > Does anyone know of a way, or have a recipe, to do a linux printk > > equivalent in Python? > > > > I've been googling for a while and not finding anything useful. > > > > The nutshell version of this is

Re: using reverse in list of tuples

2010-06-09 Thread Dan Stromberg
$ python Python 2.5.1 (r251:54863, Nov 2 2007, 11:57:24) [GCC 3.2.3 20030502 (Red Hat Linux 3.2.3-52)] on linux2 Type "help", "copyright", "credits" or "license" for more information. >>> list_ = [(1,2), (3,4), (5,6)] >>> print list_.reverse() None >>> print list_ [(5, 6), (3, 4), (1, 2)] >>> On

Re: gui doubt

2010-06-10 Thread Dan Stromberg
You probably should tell us what GUI toolkit you're using. But if your GUI toolkit has the concept of a "vertical box", then create a vertical box, add it to your window, and put things in the vertical box. To put your widget at the bottom of your vertical box, append to the end it last or insert

Re: How do subprocess.Popen("ls | grep foo", shell=True) with shell=False?

2010-06-10 Thread Dan Stromberg
On Thu, Jun 10, 2010 at 4:52 AM, Nobody wrote: > > Also, "ls | grep" may provide a useful tutorial for the subprocess module, > but if you actually need to enumerate files, use e.g. os.listdir/os.walk() > and re.search/fnmatch, or glob. Spawning child processes to perform tasks > which can easily

Re: how to build with 2.4 having 2.6 as main python

2010-06-15 Thread Dan Stromberg
I don't think #!/usr/bin/env python is the right thing - unless a script really doesn't care much what version of python it gets. I used to #!/usr/bin/env everything, but I've been updating my old scripts not to. It's just too much trouble, despite the one minor simplification it provides. My Ub

Re: how to build with 2.4 having 2.6 as main python

2010-06-15 Thread Dan Stromberg
On Tue, Jun 15, 2010 at 4:26 PM, Benjamin Kaplan wrote: > On Tue, Jun 15, 2010 at 3:55 PM, Dan Stromberg > wrote: > > > > I don't think #!/usr/bin/env python is the right thing - unless a script > > really doesn't care much what version of python it gets

Re: pythonize this!

2010-06-15 Thread Dan Stromberg
On Tue, Jun 15, 2010 at 9:26 AM, Ian Kelly wrote: > On Tue, Jun 15, 2010 at 6:21 AM, Alain Ketterlin > wrote: > > You compute i**2 too many times (7/5 times more than necessary) and > > twice too many modulos. I suggest: > > > > c = { 0:1, 1:1, 2:1, 3:-1, 4:-1 } > > #or, why not: c = lambda i :

Re: Updating a module level shared dictionary

2010-06-16 Thread Dan Stromberg
On Tue, Jun 15, 2010 at 6:33 PM, MRAB wrote: > Vishal Rana wrote: > >> Hi, >> >> A module level dictionary 'd' and is accessed by different >> threads/requests in a django web application. I need to update 'd' every >> minute with a new data and the process takes about 5 seconds. >> What could be

Re: any issues with long running python apps?

2010-07-09 Thread Dan Stromberg
On Fri, Jul 9, 2010 at 5:23 PM, Tim Chase wrote: > On 07/09/2010 06:32 PM, Roy Smith wrote: > >> i have been asked to guarantee that a proposed Python application will >>> run continuously under MS Windows for two months time. And i am looking >>> to know what i don't know. >>> >> >> Heh. The OS

Re: Issues compiling 2.6.5 on AIX 6.1

2010-07-10 Thread Dan Stromberg
On Fri, Jul 9, 2010 at 5:54 AM, Stopp, Bryan wrote: > I checked, none of the files are symlinks. The install process never got > to the point where it created sym-links for libraries (if it even does, > I haven't gotten to that point in the install process.) > > -B > > -Original Message- >

Re: how to determine whether pathname1 is below bathname2

2010-07-11 Thread Dan Stromberg
You could probably: cd to dir1 getcwd cd to dir2 getcwd repeat cd .. getcwd if getcwd == dir1's cwd, then under until at / cd to dir1 repeat cd .. getcwd if getcwd == dir2's cwd, then under until at / This should deal with symlinks and junctions, as long as you aren't worried

Re: How is Unladen Swallow coming along?

2010-07-13 Thread Dan Stromberg
2010/7/8 Luis M. González > On Jul 8, 1:42 pm, John Nagle wrote: > > How is Unladen Swallow coming along? Looking at the site, code is > > being checked in and issues are being reported, but the last quarterly > > release was 2009 Q3. They missed their January 2010 release date > > for "20

Re: pylint scores

2010-07-30 Thread Dan Stromberg
On Fri, Jul 30, 2010 at 12:18 PM, News123 wrote: > On 07/30/2010 03:12 PM, wheres pythonmonks wrote: > > I am starting to use pylint to look at my code and I see that it gives a > rating. > > What values do experienced python programmers get on code not > > targeting the benchmark? > > > > I wrot

Re: Multiprocessing taking too much time

2010-07-30 Thread Dan Stromberg
On Thu, Jul 29, 2010 at 12:04 PM, John Nagle wrote: > On 7/29/2010 11:08 AM, Shailendra wrote: > >> Hi All, >> I have a following situation. >> ==PSUDO CODE START== >> class holds_big_array: >> big_array #has a big array >> >> def get_some_element(self, co

Re: Performance ordered dictionary vs normal dictionary

2010-07-30 Thread Dan Stromberg
On Wed, Jul 28, 2010 at 11:11 PM, Chris Rebert wrote: > On Wed, Jul 28, 2010 at 8:12 PM, Navkirat Singh > wrote: > > Sorry, I might have been a bit vague: > > (Also, I am new to pythong) > > I am trying to do construct my own web session tracking algorithm for a > web > > server (which also I ha

Re: constructing and using large lexicon in a program

2010-08-02 Thread Dan Stromberg
On Mon, Aug 2, 2010 at 10:46 AM, Majdi Sawalha wrote: > Dear List members, > > I am developing a morphological analyzer that depends on a large lexicon. i > construct a Lexicon class that reades a text file and construct a dictionary > of the lexicon entries. > the other class will use the lexicon

Re: Reading binary files

2009-08-30 Thread Dan Stromberg
David Robinow wrote: This works for a simple binary file, but the actual file I'm trying to read is give throwing an error that the file cannot be found. Here is the name of the my file: 2009.08.02_06.52.00_WA-1_0001_00_0662_0.jstars Should python have trouble reading this file name or extension

Re: is list comprehension necessary?

2010-10-26 Thread Dan Stromberg
On Tue, Oct 26, 2010 at 10:31 AM, Mikael B wrote: > > > > > > > That's from the functional programming crowd. > > > > Python isn't a functional language. > > > A noob question: what is a functional language? What does it meen? > > -- > http://mail.python.org/mailman/listinfo/python-list > > It's

Re: curses and processing terminal escape characters

2010-10-29 Thread Dan Stromberg
On Fri, Oct 29, 2010 at 10:35 AM, Tim Harig wrote: > On 2010-10-29, mix wrote: > > Hi, > > > > I'm wondering if there is a way in python to process a string > > containing terminal escape characters. Example: Please consider the > > following string: > > Python could easily process the escape co

Re: functions, list, default parameters

2010-10-29 Thread Dan Stromberg
On Thu, Oct 21, 2010 at 7:53 PM, John Nagle wrote: > On 10/21/2010 2:51 PM, Chris Rebert wrote: > >> On Thu, Oct 21, 2010 at 2:36 PM, Sean Choi wrote: >> >>> I found two similar questions in the mailing list, but I didn't >>> understand >>> >>> the explanations. >>> I ran this code on Ubuntu 10.

Re: Compare source code

2010-11-09 Thread Dan Stromberg
On Thu, Nov 4, 2010 at 10:45 AM, Tim Harig wrote: > I also looked at F# and Scala; but, neither are really applicable on my > chosen platform. With F# being such a new language, I suspect that it > borrowed its indent practices either from Haskell or from Python. > I'm pretty sure F# gets its wh

Re: strange behavor....

2010-11-13 Thread Dan Stromberg
On Sat, Nov 13, 2010 at 5:46 AM, Tracubik wrote: > hi all, > i've this on python 2.6.6: > > >>> def change_integer(int_value): > ... int_value = 10 > ... > ... def change_list(list): > ... list[0] = 10 > ... > ... a = 1 > ... l = [1,1,1] > ... > ... change_integer(a) > ... change_list(l)

<    5   6   7   8   9   10   11   >