Re: Subsetting a dataset

2011-06-12 Thread Dan Stromberg
On Sun, Jun 12, 2011 at 9:53 PM, Kumar Mainali wrote: > I have a huge dataset containing millions of rows and several dozen columns > in a tab delimited text file. I need to extract a small subset of rows and > only three columns. One of the three columns has two word string with header > “Scien

Re: What is the most efficient way to compare similar contents in two lists?

2011-06-13 Thread Dan Stromberg
On Mon, Jun 13, 2011 at 8:09 AM, Chris Angelico wrote: > On Tue, Jun 14, 2011 at 12:58 AM, Zachary Dziura > wrote: > > if set(source_headers) == set(target_headers): > >similar_headers = len(source_headers) > > Since you're making sets already, I'd recommend using set operations - > same_hea

Re: working with raw image files

2011-06-14 Thread Dan Stromberg
On Tue, Jun 14, 2011 at 1:26 PM, MRAB wrote: > On 14/06/2011 21:13, kafooster wrote: > >> >> I would like to visualize this data with PIL, but PIL works only with >> 8bit data. How could I resample my array from 16bit to 8bit? >> > > Multiply the numpy array by a scaling factor, which is > float(

Re: Rant on web browsers

2011-06-20 Thread Dan Stromberg
On Tue, Jun 14, 2011 at 1:46 AM, Chris Angelico wrote: > On Tue, Jun 14, 2011 at 6:39 PM, Martin P. Hellwig > wrote: > > On 14/06/2011 07:31, Chris Angelico wrote: > > > >> > >> But if anyone feels like writing an incompatible browser, please can > >> you add Python scripting? > > > > You might

Re: writable iterators?

2011-06-23 Thread Dan Stromberg
On Wed, Jun 22, 2011 at 12:28 PM, Neal Becker wrote: > AFAICT, the python iterator concept only supports readable iterators, not > write. > Is this true? > > for example: > > for e in sequence: > do something that reads e > e = blah # will do nothing > > I believe this is not a limitation on th

Re: poll of filesystem

2011-07-02 Thread Dan Stromberg
On Sat, Jul 2, 2011 at 2:40 AM, Belisko Marek wrote: > Hi, > > just want to use poll method to get data from /proc file system. Use > simple code for it. Problem is it seems poll return POLLIN flag but > when I try to read data it's always empty. Could be a problem changes > are so fast that print

from module import * using __import__?

2011-07-02 Thread Dan Stromberg
Is there a decent way of running "from import *"? Perhaps using __import__? Does it mean using the copy module or adding an element to globals() somehow? Yes, I think I do have a good use for this: importing either pure python or cython versions of a module into a single namespace that can prov

Re: The end to all language wars and the great unity API to come!

2011-07-02 Thread Dan Stromberg
On Sat, Jul 2, 2011 at 5:21 PM, rantingrick wrote: > On Jul 2, 6:38 pm, Chris Angelico wrote: > [...] > > It takes work to suit your API to a different language. Let's take GNU > > Aspell as an example; [...] Should the Aspell team offer bindings for > every > > known language? In your post, you

Re: Problem!!

2011-07-03 Thread Dan Stromberg
You'll probably want to give more detail about what your code is doing and what it should be doing. Mindreading is hard, especially when it's accurate. Usually the main difference between *ix and windows for text files is the line endings though - on *ix, you can open a file as text or binary, an

Re: Problem!!

2011-07-04 Thread Dan Stromberg
It turned out that switching to binary I/O made seek do what he was expecting. I'm guessing the transparent crlf to lf conversions in windows text I/O get seek() a bit perplexed, because it transparently changes the number of bytes. On Mon, Jul 4, 2011 at 4:30 PM, Steven D'Aprano < steve+comp.lan

Re: write file

2011-07-05 Thread Dan Stromberg
What's date_cdr supposed to be? Is your exception handler doing unusual things with sys.exit? Did you try to run this? When I try to run it, it fails to compile. You might want to try opening your output file once and writing to it repeatedly, then close()ing it after all your writes are comple

Re: Microsoft GUIs (was: The end to all language wars and the great unity API to come!) (OT)

2011-07-05 Thread Dan Stromberg
On Tue, Jul 5, 2011 at 9:13 PM, Andrew Berg wrote: > On 2011.07.05 09:31 PM, Chris Angelico wrote: > > I've said for a while that Microsoft could do far worse than to turn > > Windows into a GUI that sits on top of a Unix-derived kernel. They > > won't do it, though, because it would be tantamount

Re: Serial & reset of the device

2011-07-07 Thread Dan Stromberg
On Thu, Jul 7, 2011 at 12:34 PM, yorick wrote: > Hello, > > I'm trying to access a hardware board of my company through a serial > connection using a Python script and the pyserial module. > > I use Python 2.7.1 with Ubuntu 11.04 (pyserial is the package python- > serial with version 2.5.2, > htt

Re: Finding duplicated photo

2011-07-08 Thread Dan Stromberg
On Fri, Jul 8, 2011 at 8:16 AM, Thomas Jollans wrote: > On 07/08/2011 01:29 PM, TheSaint wrote: > > Hello, > > > > I came across the problem that Gwenview moves the photo from the camera > > memory by renaming them, but later I forgot which where moved. > > Then I tought about a small script in p

Re: String concatenation vs. string formatting

2011-07-08 Thread Dan Stromberg
On Fri, Jul 8, 2011 at 3:50 PM, Ben Finney wrote: > * The ‘%’ string formatting operator is superseded in current Python > versions by the more flexible ‘format’ method of string objects. > AFAIK, % formatting is the only kind of formatting that works portably across all of CPythons 2.5, 2.6, 2.

Backshift mailing list create - opensource, deduplicating, compressing backups in Python

2011-07-10 Thread Dan Stromberg
I've created a google mailing list for the discussion of the backup program I've been working on, "backshift". You can find it at: backsh...@googlegroups.com And I'd be pleased if you were to choose to join, if you're interested in the subject of Python and Backups. -- http://mail.python.org/ma

Re: parsing packets

2011-07-11 Thread Dan Stromberg
On Mon, Jul 11, 2011 at 5:05 AM, Thomas Rachel < nutznetz-0c1b6768-bfa9-48d5-a470-7603bd3aa...@spamschutz.glglgl.de> wrote: > Am 10.07.2011 22:59 schrieb Littlefield, Tyler: > > Hello all: >> I'm working on a server that will need to parse packets sent from a >> client, and construct it's own pac

Re: parsing packets

2011-07-11 Thread Dan Stromberg
On Sun, Jul 10, 2011 at 1:59 PM, Littlefield, Tyler wrote: > Hello all: > I'm working on a server that will need to parse packets sent from a client, > and construct it's own packets. > I like to use this module (I wrote while in the employ of UCI, so it's under a UCI - BSDesque - license, but th

Re: An interesting beginner question: why we need colon at all in the python language?

2011-07-11 Thread Dan Stromberg
On Mon, Jul 11, 2011 at 8:28 AM, Ian Kelly wrote: > On Mon, Jul 11, 2011 at 8:50 AM, Sébastien Volle > wrote: > > Could it have been made optional, like the trailing comma in list > > declaration? > > Cobra makes the colons optional, so probably yes. > -- > http://mail.python.org/mailman/listinf

Re: Please Help with vertical histogram

2011-07-11 Thread Dan Stromberg
I have a histogram script in Python at http://stromberg.dnsalias.org/svn/histogram/trunk/ It's under a UCI (BSD-like) license. Feel free to use it or borrow ideas from it. On Mon, Jul 11, 2011 at 5:42 PM, Cathy James wrote: > Please kindly help- i have a project where I need to plot dict resul

Re: What is the difference between PyPy and Python? are there lot of differences?

2011-07-13 Thread Dan Stromberg
On Wed, Jul 13, 2011 at 8:18 AM, Ian Kelly wrote: > On Wed, Jul 13, 2011 at 8:19 AM, Anthony Kong > wrote: > > One of the main difference is that pypy supports only R-Python, which > stands > > for 'Restricted Python". > > It is a subset of C-python language. > > This is wrong. The PyPy *interp

Re: Python ++ Operator?

2011-07-15 Thread Dan Stromberg
On Fri, Jul 15, 2011 at 1:06 AM, Chris Angelico wrote: > 2011/7/15 Björn Lindqvist : > > Pre and post-increments are > > almost always confusing unless they are used as the counter-variable > > inside for-loops. > > I agree that they're often confusing (i+j) but there are several > places whe

Re: Print encoding problems in console

2011-07-15 Thread Dan Stromberg
I've used the code below successfully to deal with such a problem when outputting filenames. Python2x3 is at http://stromberg.dnsalias.org/svn/python2x3/ , but here it's just being used to convert Python 3.x's byte strings to strings (to eliminate the b'' stuff), while on 2.x it's an identity func

Re: MemoryError vs malloc error

2011-07-16 Thread Dan Stromberg
Is the whole program pure python? Sometimes a reference to undefined memory or a lack of error checking elsewhere in a program, can cause innocuous code to fail later: http://stromberg.dnsalias.org/~dstromberg/checking-early.html If the program uses ctypes, or an unusual Python/C API module, I'd

Re: Tabs -vs- Spaces: Tabs should have won.

2011-07-16 Thread Dan Stromberg
On Sat, Jul 16, 2011 at 9:51 AM, rantingrick wrote: > > -- > Summary > -- > As we all know python allows us to use either tabs or spaces but NEVER > both in the same source file. And as we also know t

Re: Tabs -vs- Spaces: Tabs should have won.

2011-07-16 Thread Dan Stromberg
On Sat, Jul 16, 2011 at 4:52 PM, Cameron Simpson wrote: > Well to some extent because I share files with > another who uses 4 position tabs. Editing these is a real nightmare if > one uses 8 position tabs (as I do, the common editor/terminal default > these days). 8's been the default in pretty

Re: Ordered list question

2011-07-17 Thread Dan Stromberg
If you need "read everything, then sort once", then a dictionary (or collections.defaultdict if you require undefined's) and a single sort at the end is probably the way to go. If you truly need an ordered datastructure (because you're reading one element, using things sorted, reading another elem

Re: Strings show as brackets with a 'u'.

2011-07-23 Thread Dan Stromberg
It's probably a list containing a single unicode string. You can pull the first element from the list with n[0]. To print a unicode string in 2.x without the u stuff: print u'174'.encode('ISO-8859-1') On Sat, Jul 23, 2011 at 5:33 PM, goldtech wrote: > > Hi, > > >>> n > [u'174'] > >>> > > Prob

Re: Convert '165.0' to int

2011-07-23 Thread Dan Stromberg
On Sat, Jul 23, 2011 at 8:53 PM, Billy Mays wrote: > I'll probably get flak for this, but damn the torpedoes: > > def my_int(num): >import re >try: >m = re.match('^(-?[0-9]+)(.0)?$', num) >return int(m.group(1)) >except AttributeError: >#raise your own error, o

Re: I am fed up with Python GUI toolkits...

2011-07-23 Thread Dan Stromberg
On Wed, Jul 20, 2011 at 12:20 AM, Stefan Behnel wrote: > Steven D'Aprano, 20.07.2011 06:28: > > Python has a GIL. >>> >> >> Except for Jython, IronPython and PyPy. >> > > PyPy has a GIL, too. There's been talk of removing PyPy's GIL using transactional memory though. -- http://mail.python.org

Re: Refactor/Rewrite Perl code in Python

2011-07-24 Thread Dan Stromberg
On Sun, Jul 24, 2011 at 2:29 AM, Shashwat Anand wrote: > I am working with a huge codebase of Perl. > The code have zero documentation and zero unit-tests. > It seems like a huge hack. > My condolences. Er, actually, it sounds kind of fun. The underlying database schema is horrid. > So I want t

Re: Python for Web

2011-07-24 Thread Dan Stromberg
On Wed, Jun 15, 2011 at 5:11 AM, bruno.desthuilli...@gmail.com < bruno.desthuilli...@gmail.com> wrote: > On Jun 15, 9:50 am, sidRo wrote: > > Is Python only for server side? > > Is it a theoretical question or a practical one ?-) > > More seriously: except for the old proof-of-concept Grail brows

Re: Only Bytecode, No .py Files

2011-07-26 Thread Dan Stromberg
Another possibility: You could probably create a bunch of zero-length .py's that are older than the corresponding .pyc's. On Tue, Jul 26, 2011 at 8:19 AM, Eldon Ziegler wrote: > Is there a way to have the Python processor look only for bytecode > files, not .py files? We are seeing huge numbers o

Re: Selecting unique values

2011-07-26 Thread Dan Stromberg
Some good stuff has already been suggested. Another possibility is using a treap (not a duptreap but a treap): http://stromberg.dnsalias.org/~dstromberg/treap/ If you just need things unique'd once, the set + yield is an excellent option. If you need to keep things in order, but also need to ma

Re: seeking an example on C extension works in python 3.1.x or above

2011-07-26 Thread Dan Stromberg
You could try looking in the Python sources for examples. But using Cython is probably easier. On Tue, Jul 26, 2011 at 5:06 PM, wrote: > Hello, > I have been searching the example on C extension that works in python > 3.1.x ror above for long time. I tried the simple example given in > python

Re: seeking an example on C extension works in python 3.1.x or above

2011-07-26 Thread Dan Stromberg
BTW, I believe you need to compile your extension module(s) with the same compiler that was used to build the Python interpreter - otherwise there could be calling convention issues. On Tue, Jul 26, 2011 at 5:58 PM, Dan Stromberg wrote: > > You could try looking in the Python sourc

Re: shlex parsing

2011-07-27 Thread Dan Stromberg
I've not used the shlex module, but this feels more like an issue to address with a parser than for a lexical analyzer - or perhaps even both, since you're splitting on whitespace sometimes, and matching square brackets sometimes. I've used pyparsing for stuff a bit similar to this. Or here's a l

Re: shlex parsing

2011-07-27 Thread Dan Stromberg
ng seems to be pretty simple but my constraint is to use > standard lib (at maximum). To bad it is not part of python standard libs. > On the other hand, I will have to regroup expression like '-option1 $VAL == > $CONSTRAINT' > in ['-option1', '$VAL == $CO

Re: Approximate comparison of two lists of floats

2011-07-28 Thread Dan Stromberg
You'd probably better explain in English which things truly need to be compared with what. Right now, your first version is, I believe, an O(n^4) algorithm, which is extremely expensive, while your second (set-based) version appears to be O(n^3), which is quite a bit better, but still not stellar.

Re: Any suggestion to start more threads at the same time?

2011-07-28 Thread Dan Stromberg
You could try Jython. Other than that, you probably want a threadpool, or perhaps to try multiprocessing - but that much forking could be a problem as well. On Thu, Jul 28, 2011 at 2:07 PM, smith jack wrote: > I start many threads in order to make the work done, when the > concurrent number is

Re: python reading file memory cost

2011-08-01 Thread Dan Stromberg
A code snippet would work wonders in making sure you've communicated what you really need, or at least what you have now. But if you read the data into one big string, that'll be much more efficient than if you read it as a list of integers or even as a list of lines. Processing the data one chun

Re: Complex sort on big files

2011-08-01 Thread Dan Stromberg
Python 2.x, or Python 3.x? What are the types of your sort keys? If you're on 3.x and the key you need reversed is numeric, you can negate the key. If you're on 2.x, you can use an object with a __cmp__ method to compare objects however you require. You probably should timsort the chunks (which

Re: test systems

2011-08-01 Thread Dan Stromberg
I've been testing my Python code on these using virtualbox and/or physical machines (but mostly virtualbox): CentOS 6.0 Debian DragonflyBSD Fedora 15 FreeBSD Haiku R1 alpha 3 Linux Mint Minix OpenIndiana openSUSE Sabayon Scientific Linux 6 Slackware Solaris Express Ubuntu Windows 7 Sadly, I don't

Re: python reading file memory cost

2011-08-01 Thread Dan Stromberg
You could try forcing a garbage collection... On Mon, Aug 1, 2011 at 8:22 PM, Tony Zhang wrote: > Thanks! > > Actually, I used .readline() to parse file line by line, because I need > to find out the start position to extract data into list, and the end > point to pause extracting, then repeat u

Re: Complex sort on big files

2011-08-02 Thread Dan Stromberg
On Tue, Aug 2, 2011 at 3:25 AM, Alistair Miles wrote: > Hi Dan, > > Thanks for the reply. > > On Mon, Aug 1, 2011 at 5:45 PM, Dan Stromberg wrote: > > > > Python 2.x, or Python 3.x? > > Currently Python 2.x. > So it sounds like you may want to move this code

Re: Hardlink sub-directories and files

2011-08-02 Thread Dan Stromberg
On Tue, Aug 2, 2011 at 3:13 AM, Thomas Jollans wrote: > On 02/08/11 11:32, loial wrote: > > I am trying to hardlink all files in a directory structure using > > os.link. > > > > However I do not think it is possible to hard link directories ? > That is pretty true. I've heard of hardlinked dire

Re: how to sort a hash list without generating a new object?

2011-08-02 Thread Dan Stromberg
On Tue, Aug 2, 2011 at 5:53 PM, Chris Rebert wrote: > On Tue, Aug 2, 2011 at 11:02 AM, smith jack wrote: > > the source code is as follows > > > > x={} > > x['a'] = 11 > > x['c'] = 19 > > x['b'] = 13 > > print x > > If you /really/ need a sorted mapping datatype, google for > "sorteddict" (which

Re: code generation

2011-08-02 Thread Dan Stromberg
Perhaps: http://code.google.com/p/python-graph/ On Tue, Aug 2, 2011 at 8:03 PM, Rita wrote: > Hello, > > This isn't much of a python question but a general algorithm question. > > I plan to input the following string and I would like to generate something > like this. > > input: a->(b,c)->d > o

Re: parsing in python

2011-08-03 Thread Dan Stromberg
To just split lines into words, you could probably just use a regex. If you need to match things, like quotes or brackets or parens, pyparsing is pretty nice. On Wed, Aug 3, 2011 at 6:26 AM, Jayron Soares wrote: > Hi folks, > > I've created a simple method to grab files texts from directory by w

Re: Hardlink sub-directories and files

2011-08-03 Thread Dan Stromberg
On Wed, Aug 3, 2011 at 2:47 AM, Thomas Jollans wrote: > Is it more portable? I don't actually have cpio installed on this > system. Interesting. Of course, it's probably readily available to you. What *ix are you seeing that doesn't include cpio by default? > Which implementations of cp don

Re: Hardlink sub-directories and files

2011-08-03 Thread Dan Stromberg
On Wed, Aug 3, 2011 at 12:04 AM, Nobody wrote: > On Tue, 02 Aug 2011 02:32:54 -0700, loial wrote: > > > However I do not think it is possible to hard link directories ? > > Modern Unices disallow hard links to directories, as it makes the > directory "tree" not a tree, so anything which performs

Re: Hardlink sub-directories and files

2011-08-03 Thread Dan Stromberg
On Wed, Aug 3, 2011 at 11:49 AM, Thomas Jollans wrote: > > > Interesting. Of course, it's probably readily available to you. What > > *ix are you seeing that doesn't include cpio by default? > > Arch Linux - the base install is quite minimal. I just discovered that I > have a program called bsd

Re: Hardlink sub-directories and files

2011-08-03 Thread Dan Stromberg
On Wed, Aug 3, 2011 at 2:54 PM, Thomas Jollans wrote: > > On 03/08/11 23:25, Dan Stromberg wrote: > > > Interesting. Of course, it's probably readily available to you. > What > > > *ix are you seeing that doesn't include cpio by default? > &g

Re: Inconsistent SMTP/Gmail connection drop

2011-08-03 Thread Dan Stromberg
Some things to consider: 1) You might see if there's something about the size of the message - is it bigger after collecting data all night? Is google disconnecting after a maximum amount of data is transferred? 2) You might try sending a tiny test message at the beginning, just to yourself, and

Re: PyWhich

2011-08-04 Thread Dan Stromberg
On Thu, Aug 4, 2011 at 10:22 AM, Chris Rebert wrote: > > > #!/usr/bin/python > > > > import sys > > if __name__ == '__main__': > >if len(sys.argv) > 1: > >try: > >m = __import__(sys.argv[1]) > >sys.stdout.write(m.__file__ + '\n') > >sys.stdout.flush

Re: problem with bcd and a number

2011-08-04 Thread Dan Stromberg
It sounds like you have what you need, but here's an amusing way of dealing with a BCD byte: >>> print int(hex(0x72).replace('0x', '')) 72 On Thu, Aug 4, 2011 at 5:15 PM, shawn bright wrote: > Thanks for your help on this, gents. Got it working now. > shawn > > On Thu, Aug 4, 2011 at 2:28 PM, D

Re: Sockets: Receiving C Struct

2011-08-05 Thread Dan Stromberg
First, s.recv(4) is not guaranteed to always return 4 bytes. It could return 0, 1, 2, 3, or 4, wtih 4 being the most likely. To deal with this, I tend to use http://stromberg.dnsalias.org/~dstromberg/bufsock.html - but I suspect that Twisted has a way of dealing with it too. Then, to put your da

Re: Complex sort on big files

2011-08-05 Thread Dan Stromberg
Yup. Timsort is described as "supernatural", and I'm inclined to believe it. On Fri, Aug 5, 2011 at 7:54 PM, Roy Smith wrote: > Wow. > > Python took just about half the time. Certainly knocked my socks off. > Hard to believe, actually. > -- > http://mail.python.org/mailman/listinfo/python-li

Re: Inconsistent SMTP/Gmail connection drop

2011-08-05 Thread Dan Stromberg
Well, a sniffer is one of many, and one worth mentioning. Though I'd recommend wireshark over tcpdump, pretty much any day. http://stromberg.dnsalias.org/~dstromberg/Problem-solving-on-unix-linux-systems.html On Fri, Aug 5, 2011 at 6:29 PM, BJ Swope wrote: > The best tool to debug this is tcpd

Re: Segmentation Fault on exit

2011-08-06 Thread Dan Stromberg
I have little reason to doubt that it's related to referencing counting, but: http://stromberg.dnsalias.org/~dstromberg/checking-early.html On Sat, Aug 6, 2011 at 3:35 AM, Vipul Raheja wrote: > Hi, > > I have wrapped a library from C++ to Python using SWIG. But when I > import it in Python, I a

Re: help

2011-08-06 Thread Dan Stromberg
I'll be a lot easier for you to get help, if you take a shot at it yourself first, then post a link to what you have here, along with any error messages you may be getting. On Sat, Aug 6, 2011 at 1:38 PM, aahan noor wrote: > > Hi all: > i am new to python. i am working with lm-sensors to monito

Re: Object Diffs

2011-08-08 Thread Dan Stromberg
You probably need a recursive algorithm to be fully general, and yes, looking at pickle might be a good place to start. Note that pickle can't pickle everything, but it can handle most things. Also check out NX - not the CPU feature, but the (re)transmission compressing software (there are two di

Re: Need help with Python to C code compiler

2011-08-08 Thread Dan Stromberg
Shedskin is one option - if it doesn't have the modules you need, you could try finding pure python versions of them and translating them too, along with your own code. Cython is probably the one I hear the most about. On Mon, Aug 8, 2011 at 10:37 PM, Vijay Anantha Murthy < vijay.mur...@gmail.com

Re: problem installing psyco on windows (Unable to find vcvarsall.bat)

2011-08-10 Thread Dan Stromberg
FWIW, a few months ago I was working on a database application on Windows, and I benchmarked the psyco-enhanced version consistently running slower than the non-psyco version. The same code on Linux was faster with psyco though. If you need performance, and you aren't constrained by module availa

Re: Processing a large string

2011-08-12 Thread Dan Stromberg
This is the sort of thing I wrote bufsock for. Don't let the name fool you - although I originally wrote it for sockets, it's since been extended to work with files and file handles. http://stromberg.dnsalias.org/~dstromberg/bufsock.html It was recently modified to work on 2.x and 3.x. On Thu,

Re: Java is killing me! (AKA: Java for Pythonheads?)

2011-08-12 Thread Dan Stromberg
Check varargs (as another poster mentioned), and consider doing your unit tests in Jython. Some shops that don't want Python for production code are fine with Python for unit tests. However, if the reason for preferring java is type checking, you could perhaps get somewhere by suggesting pylint.

Re: Why no warnings when re-assigning builtin names?

2011-08-15 Thread Dan Stromberg
On Mon, Aug 15, 2011 at 2:52 PM, Gerrat Rickert wrote: > With surprising regularity, I see program postings (eg. on StackOverflow) > from inexperienced Python users accidentally re-assigning built-in names. > http://pypi.python.org/pypi/pylint checks for this and many other issues. I don't know

Re: testing if a list contains a sublist

2011-08-15 Thread Dan Stromberg
Check out collections.Counter if you have 2.7 or up. If you don't, google for multiset or bag types. On Mon, Aug 15, 2011 at 4:26 PM, Johannes wrote: > hi list, > what is the best way to check if a given list (lets call it l1) is > totally contained in a second list (l2)? > > for example: > l1

Re: Measure the amount of memory used?

2011-08-18 Thread Dan Stromberg
"A person with one watch knows what time it is. A person with two is never sure." You're probably best off just picking one or more measures that work for your purposes, and going with them. Don't concern yourself overmuch with finding "the" amount. Memory can actually contract on some modern s

Re: List spam

2011-08-18 Thread Dan Stromberg
On Thu, Aug 18, 2011 at 6:39 AM, Jason Staudenmayer < jas...@adventureaquarium.com> wrote: > > > On 18/08/2011 13:58, Jason Staudenmayer wrote: > > > I really like this list as part of my learning tools but the amount > > > of spam that I've been getting from it is CRAZY. Doesn't > > anything get

Re: Replacement for the shelve module?

2011-08-19 Thread Dan Stromberg
On Fri, Aug 19, 2011 at 8:31 AM, Forafo San wrote: > Folks, > What might be a good replacement for the shelve module, but one that > can handle a few gigs of data. I'm doing some calculations on daily > stock prices and the result is a nested list like: > > [[date_1, floating result 1], > [date_

Re: Record seperator

2011-08-27 Thread Dan Stromberg
http://stromberg.dnsalias.org/svn/bufsock/trunk does it. $ cat double-file daemon:x:1:1:daemon:/usr/sbin:/bin/sh bin:x:2:2:bin:/bin:/bin/sh sys:x:3:3:sys:/dev:/bin/sh sync:x:4:65534:sync:/bin:/bin/sync games:x:5:60:games:/usr/games:/bin/sh man:x:6:12:man:/var/cache/man:/bin/sh root:x:0:0:root:/roo

Re: Checking Signature of Function Parameter

2011-08-29 Thread Dan Stromberg
On Sun, Aug 28, 2011 at 2:20 PM, Travis Parks wrote: > There are some things I want to make sure of. 1) I want to make sure > that source is iterable. 2) More importantly, I want to make sure that > predicate is callable, accepting a thing, returning a bool. > You can check a lot of this stuff ve

Re: Python getting stuck

2011-02-26 Thread Dan Stromberg
On Sat, Feb 26, 2011 at 4:03 PM, Corey Richardson wrote: > On 02/26/2011 06:55 PM, Shanush Premathasarathan wrote: > > Hi All, > > > > When I use cut, copy, paste, and any keyboard shortcuts, Python freezes > and I am unable to use Python. Please Help as quick as possible!!! > > What OS? Are you

Re: OT: Code Examples

2011-03-01 Thread Dan Stromberg
On Tue, Mar 1, 2011 at 8:51 AM, Erik de Castro Lopo wrote: > Definitely not. As I said I used Python for a number of years > and ditched it in favour of Ocaml and Haskell. > These are all 3 intriguing languages. I wish I had time to learn OCaML and Haskell, and I wish one or both of them were nea

Re: 2to3 and maketrans

2011-03-03 Thread Dan Stromberg
On Wed, Mar 2, 2011 at 10:58 PM, Gregory Ewing wrote: > What is the recommended way to write code for 2.7 using > maketrans() on text strings in such a way that it will > convert correctly using 2to3? > > There seems to be two versions of maketrans in 3.x, one > for text and one for bytes. Code th

Re: 2to3 and maketrans

2011-03-03 Thread Dan Stromberg
On Thu, Mar 3, 2011 at 3:46 PM, Martin v. Loewis wrote: > That depends on how you chose to represent text in 2.7. > The recommended way for that (also with 3.x in mind) > is that you should use Unicode strings to represent text. > For application programming, I'm sure Unicode is usually preferab

Re: auto increment

2011-03-03 Thread Dan Stromberg
On Thu, Mar 3, 2011 at 8:48 PM, Chris Rebert wrote: > On Thu, Mar 3, 2011 at 8:41 PM, monkeys paw wrote: > > Does python have an analogy to c/perl incrementer? > > > > e.g. > > > > i = 0 > > i++ > > i += 1 > > If you're doing this for a list index, use enumerate() instead. > There's been discus

Re: auto increment

2011-03-03 Thread Dan Stromberg
On Thu, Mar 3, 2011 at 9:07 PM, Chris Rebert wrote: > On Thu, Mar 3, 2011 at 9:05 PM, Dan Stromberg wrote: > > On Thu, Mar 3, 2011 at 8:48 PM, Chris Rebert wrote: > >> On Thu, Mar 3, 2011 at 8:41 PM, monkeys paw > wrote: > >> > Does python have

Re: What do I need to know in order to write a web application in python?

2011-03-06 Thread Dan Stromberg
On Fri, Mar 4, 2011 at 6:07 PM, Paul Rubin wrote: > ErichCart ErichCart writes: > > By real-time, I mean that I want it to be similar to the way instant > > online chess works. Something like here: instantchess.com, but for > > RISK. > > If you want to do that in a web browser, the main techniqu

Re: I'm happy with Python 2.5

2011-03-06 Thread Dan Stromberg
On Thu, Mar 3, 2011 at 10:43 AM, Ian Kelly wrote: > On Sun, Feb 27, 2011 at 7:15 AM, n00m wrote: > > http://www.spoj.pl/problems/TMUL/ > > > > Python's "print a * b" gets Time Limit Exceeded. > > If speed is the only thing you care about, then you can forget about > fretting over whether 2.5 or

Re: python data types in c++ code

2011-03-06 Thread Dan Stromberg
On Sun, Mar 6, 2011 at 10:07 AM, Arthur Mc Coy <1984docmc...@gmail.com>wrote: > You know, they are still using SVN, they are > very loosely coupled to the past. > Cython's very nice if you don't plan to do more than C/C++ with Python. SWIG might be better if you intend to do more VHLL's than Pyth

Re: Purely historic question: VT200 text graphic programming

2011-03-09 Thread Dan Stromberg
Hm, maybe curses? *ix programmers often know what it is, but it was present on VMS as well. And the python sources come with a curses module. http://h71000.www7.hp.com/doc/732final/5763/5763pro_015.html The main question then becomes, was VMS's curses a termcap curses or a terminfo curses, or so

Re: What do you use with Python for GUI programming and why?

2011-03-10 Thread Dan Stromberg
You're probably best off with Pyjamas. Then you get something that runs on the web and on the desktop, from the same code - similar to GWT, but for Python. The desktop version runs overtop of CPython, the web version is AJAX and is automatically translated from a very 2.x-ish dialect of Python to

Re: Just finished reading of "What’s New In Python 3.0"

2011-03-10 Thread Dan Stromberg
On Thu, Mar 10, 2011 at 6:05 PM, alex23 wrote: > On Mar 11, 11:58 am, n00m wrote: > > http://docs.python.org/py3k/whatsnew/3.0.html > > > > What's the fuss abt it? Imo all is ***OK*** with 3k (in the parts I > > understand). > > I even liked print as a function **more** than print as a stmt > >

Re: Just finished reading of "What’s New In Python 3.0"

2011-03-11 Thread Dan Stromberg
On Thu, Mar 10, 2011 at 11:59 PM, n00m wrote: > Fitzgerald had been an alcoholic since his college days, and became > notorious during the 1920s for his extraordinarily heavy drinking, > leaving him in poor health by the late 1930s. According to Zelda's > biographer, Nancy Milford, Scott claimed

Re: Creating a very simple revision system for photos in python

2011-03-11 Thread Dan Stromberg
On Fri, Mar 11, 2011 at 6:56 AM, Thomas W wrote: > I`m thinking about creating a very simple revision system for photos > in python, something like bazaar, mercurial or git, but for photos. > The problem is that handling large binary files compared to plain text > files are quite different. Has a

Re: Two random lists from one list

2011-03-11 Thread Dan Stromberg
Catenate the lists into a new list. Then randomize the order of the new list by iterating over each element in turn, swapping it with a random element elsewhere in the same list (optionally including swapping it with itself - that's easier and still gives good randomization). This gives linear ti

Re: What do you use with Python for GUI programming and why?

2011-03-11 Thread Dan Stromberg
On Fri, Mar 11, 2011 at 12:54 PM, Fred Pacquier wrote: > Robert said : > > > Is there a push to one toolkit or the other? > > If you are just now getting started, I would honestly suggest you save a > whole lot of time and dive straight into PyQt. I've tried most 'em over the > years (including s

Re: Calling C++ Modules in Python

2011-03-11 Thread Dan Stromberg
On Fri, Mar 11, 2011 at 1:15 PM, Patrick wrote: > Hi, > > I saw in the Beginner document that "•Is easily extended by adding new > modules implemented in a compiled language such as C or C++. ". > > While to my investigation, it seems not that easy or did I miss > something? > > boost python (C++

Re: Re: Calling C++ Modules in Python

2011-03-11 Thread Dan Stromberg
panies are > willing to rebuild their own libraries with those wrappers or decorations > added(though needs approves from all sorts of departments :)), they can't > force their 3rd-party developers/users. > Correct me if I am wrong. > > Rg, > -Patrick > > On Mar 11, 2

Re: How should I handle socket receiving?

2011-03-11 Thread Dan Stromberg
On Fri, Mar 11, 2011 at 3:30 PM, Hans wrote: > I'm thinking to write a code which to: > 1. establish tons of udp/tcp connections to a server > 2. send packets from each connections > 3. receive packets from each connections and then do something based > on received content and connection statues.

Re: OT: processes, terminals and file descriptors on *nix (was: Re: attach to process by pid?)

2011-03-11 Thread Dan Stromberg
On Fri, Mar 11, 2011 at 3:49 PM, Alexander Kapps wrote: > On 11.03.2011 03:18, Nobody wrote: > >> On Thu, 10 Mar 2011 23:55:51 +0100, Alexander Kapps wrote: >> >> I think he wants to attach to another process's stdin/stdout and > read/write from/to them. > I don't know if this is possibl

Re: Memory Usage of Strings

2011-03-16 Thread Dan Stromberg
On Wed, Mar 16, 2011 at 8:38 AM, Amit Dev wrote: > I'm observing a strange memory usage pattern with strings. Consider > the following session. Idea is to create a list which holds some > strings so that cumulative characters in the list is 100MB. > > >>> l = [] > >>> for i in xrange(10): > .

Re: organizing many python scripts, in a large corporate environment.

2011-03-16 Thread Dan Stromberg
If you just want to be unhappy about the current situation, I hereby formally bestow upon you permission to be so. :) The problem seems to be that you want to hook into the python process, without hooking into the python process. Were this possible, it seems we might have a serious security issu

Re: Fitting polynomial curve

2011-03-17 Thread Dan Stromberg
On Thu, Mar 17, 2011 at 5:44 PM, Astan Chee wrote: > > On Thu, Mar 17, 2011 at 5:09 PM, Terry Reedy wrote: > >> Look at scipy. >> > > Thanks for the info. I realized I made some mistakes. Anyway, what I'm > trying to do is in maya (python), fit selected vertices on a curve. Here is > what I have

Re: Reading/Writing files

2011-03-18 Thread Dan Stromberg
For open() or os.open(), it should look in your Current Working Directory (CWD). Your python's CWD defaults to what the CWD was when python was started, and it is changed with os.chdir(). Absolute paths will of course be relative to / on most OS's (or C:/ if you're on C:, D:/ if you're on D:, etc

Re: Reading/Writing files

2011-03-18 Thread Dan Stromberg
Are you on windows? You probably should use / as your directory separator in Python, not \. In Python, and most other programming languages, \ starts an escape sequence, so to introduce a literal \, you either need to prefix your string with r (r"\foo\bar") or double your backslashes ("\\foo\\bar

Re: Bounds checking

2011-03-18 Thread Dan Stromberg
Actually, I'd probably create a class with 3 arguments - an initial value, a lower bound, and an upper bound, give it a _check method, and call _check from the various operator methods. The class would otherwise impersonate an int. In code that isn't performance-critical, it's better to check for

Re: Reading/Writing files

2011-03-18 Thread Dan Stromberg
On Fri, Mar 18, 2011 at 4:00 PM, Ethan Furman wrote: > Dan Stromberg wrote: > >> >> Are you on windows? >> >> You probably should use / as your directory separator in Python, not \. >> In Python, and most other programming languages, \ starts an escape &g

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