Re: Are dictionaries the same as hashtables?

2008-08-26 Thread Martin Marcher
On 2008-08-26 00:32:20, cnb wrote: > Are dictionaries the same as hashtables? Yes, but there is nothing in there that does sane collision handling like making a list instead of simply overwriting. PS: your sig was *a bit* longer than you question. please don't do that... signature.asc Descripti

Re: Python's doc problems: sort

2008-06-02 Thread Martin Marcher
Hi, On Wed, Apr 30, 2008 at 4:48 AM, [EMAIL PROTECTED] <[EMAIL PROTECTED]> wrote: > For example, in last week, that page is fetched 550 times. > The second most popular page, trails quite a distance. Here's the top yup that was me, i have access to a couple of machines and wanted to test some int

Re: preserve history in the interactive python

2008-05-20 Thread Martin Marcher
Hi, On Tue, May 20, 2008 at 8:19 PM, Nikhil <[EMAIL PROTECTED]> wrote: > Nikhil wrote: >> the previous interactive shell. Basically, is there anyway that I can >> preserve the history in the shell? > > I figured it out. This below thing works fine for me. > BTW, I got it from http://docs.python.or

Re: self.var hmm?

2008-05-20 Thread Martin Marcher
Hi, that's because self.group is not the same as TaskGroup.group quickish: class TaskGroup group = [] def __init__(self): """ ## note that all TaskGroup instances now use the the same self.group """ self.group = TaskGroup.group def addTask(self, task): self.group.app

Re: Best way to check if string is an integer?

2008-04-08 Thread Martin Marcher
arg, as posted earlier: int("10.0") fails, it will of course work with float("1E+1") sorry for the noise... On Tue, Apr 8, 2008 at 10:32 PM, Martin Marcher <[EMAIL PROTECTED]> wrote: > hmmm > > int() does miss some stuff: > > >>> 1E+1 > 1

Re: Best way to check if string is an integer?

2008-04-08 Thread Martin Marcher
hmmm int() does miss some stuff: >>> 1E+1 10.0 >>> int("1E+1") Traceback (most recent call last): File "", line 1, in ValueError: invalid literal for int() with base 10: '1E+1' I wonder how you parse this? I honestly thought until right now int() would understand that and wanted to show that

plpythonu+postgrs anybody using it?

2008-04-02 Thread Martin Marcher
Hello, I just started on working with a postgres project, the DB looks really bad and isn't normalized in any way... 4k Text messages representing a whole protocol which need to be transformed. Somehow it just doesn't seem right to put this stuff directly in the database and creating a bunch of st

Re: Checking if a variable is a dictionary

2008-03-06 Thread Martin Marcher
On Thu, Mar 6, 2008 at 2:06 PM, Guillermo <[EMAIL PROTECTED]> wrote: > >What makes you say you "need" to know this ? Except for a couple corner > >cases, you usually don't need to care about this. If you told us more > >about the actual problem (instead of asking about what you think is the > >

Re: Encrypting a short string?

2008-02-11 Thread Martin Marcher
Hi, On 2/11/08, erikcw <[EMAIL PROTECTED]> wrote: > In essence what I'm doing is trying to manage tickets for a helpdesk. > I want the ticket identifier to be short enough to fit in the subject > line along with the normal subject chosen by the user. So > cryptographic security isn't really impor

Re: Sorting Large File (Code/Performance)

2008-01-24 Thread Martin Marcher
On Thursday 24 January 2008 20:56 John Nagle wrote: > [EMAIL PROTECTED] wrote: >> Hello all, >> >> I have an Unicode text file with 1.6 billon lines (~2GB) that I'd like >> to sort based on first two characters. > > Given those numbers, the average number of characters per line is > less tha

Re: Email module, how to add header to the top of an email?

2008-01-24 Thread Martin Marcher
On Thursday 24 January 2008 20:32 David Erickson wrote: > I have been using the Email module and Message class for awhile, > however I have been unable to find a way to add a header to the top of > the email similar to what is done with Received: headers... the > add_header method only appends to

Re: UDP Client/Server

2008-01-23 Thread Martin Marcher
Guilherme Polo wrote: >> >>> class FooRequestHandler(BaseRequestHandler): >> ... def handle(self): >> ... data, addr_info = self.request[1].recvfrom(65534) > > Your FooReceiveServer subclasses UDPServer, it already handled the > recvfrom for you, so, this is wrong. > hmm then why

UDP Client/Server

2008-01-22 Thread Martin Marcher
Hello, I created a really simple udp server and protocol but I only get every 2nd request (and thus answer just every second request). Maybe someone could shed some light, I'm lost in the dark(tm), sorry if this is a bit oververbose but to me everything that happens here is black magic, and I hav

Re: Looping through the gmail dot trick

2008-01-21 Thread Martin Marcher
Steven D'Aprano wrote: > Postfix, I think, interpets "foo+bar" the same as "foo". yup it does, but "foo" has to be a valid localpart so "foo+bar" -> foo foo+baz -> foo f+oobar -> f - which is a different user (aliases set aside) famous call on plus addressing, and you it's just a default you can

[OT] Valid Mail addresses modifications (WAS: Re: Looping through the gmail dot trick)

2008-01-21 Thread Martin Marcher
Martin Vilcans wrote: > Try the SMTP spec. IIRC there's a passage there that says that the > server should try to make sense of addresses that don't map directly > to a user name. Specifically, it says that firstname.lastname should > be mapped to the user with those first and last names. Short s

Re: Looping through the gmail dot trick

2008-01-20 Thread Martin Marcher
On Sunday 20 January 2008 17:38 Joshua Gilman wrote: > So I have a very interesting task ahead of me and it is to loop through an > email using the 'gmail dot trick'. Essentially this trick puts periods > throughout your email to make it look different. Even though it has > periods gmail will repl

Re: sqlite3 is it in the python default distro?

2008-01-13 Thread Martin Marcher
On Saturday 12 January 2008 21:34 Martin Marcher wrote: > a) Is sqlite included in the python default distribution > b) In real life can I consider (on linux) that an installation of python > includes the sqlite stuff? forgive my that was pebcack. I wasn't reading the docs fully

sqlite3 is it in the python default distro?

2008-01-12 Thread Martin Marcher
Hello, I can see that sqlite is in the standard lib documentation: http://docs.python.org/lib/module-sqlite3.html however debian and ubuntu (and gentoo according to the packages info) seem _not_ to include it. Now 2 question arise: a) Is sqlite included in the python default distribution b) In

Re: help with a problem from school??

2008-01-10 Thread Martin Marcher
Josh wrote: > Hello all I did a Google search and found this site and was hoping someone > could help me with what I am sure is a simple question that I cannot > figure out. Here goes: > > Given a simple straight through switch (SPST) with a supply of > 14V, and the need

Re: docstrings style question

2008-01-10 Thread Martin Marcher
Russ P. wrote: > On Jan 9, 9:47 pm, "Steve Brown" <[EMAIL PROTECTED]> wrote: >> I've got a series of modules which look like this: >> >> # >> # >> # Temperature Sense Test >> # >> # >> class Test3(ar_test.AR_TEST): >> """Temperature Sense Test""" >> >> I don't like the

Re: printing dots in simple program while waiting

2008-01-09 Thread Martin Marcher
John wrote: > import time > s = '.' > print 'working', # Note the "," at the end of the line > while True: > print s > time.sleep(1) see my comment in the code above... if that's what you mean /martin -- http://noneisyours.marcher.name http://feeds.feedburner.com/NoneIsYours You are

Re: Collecting Rich Data Structures for students

2008-01-09 Thread Martin Marcher
Paddy wrote: > On Jan 9, 2:19 am, "[EMAIL PROTECTED]" <[EMAIL PROTECTED]> > wrote: >> Some have offered XML repositories, which I can well >> understand, but in this case we're looking specifically for >> legal Python modules (py files), although they don't have >> to be Latin-1 (e.g. the sushi ty

Re: use fileinput to read a specific line

2008-01-08 Thread Martin Marcher
Fredrik Lundh wrote: > Martin Marcher wrote: > >>> i need to read line 4 from a header file >> >> http://docs.python.org/lib/module-linecache.html > > I guess you missed the "using linecache will crash my computer due to > memory loading, because i a

Re: Open a List of Files

2008-01-08 Thread Martin Marcher
BJ Swope wrote: > On Jan 8, 2008 6:03 AM, Fredrik Lundh <[EMAIL PROTECTED]> wrote: > >> BJ Swope wrote: >> >> > given a list such as >> > >> > ['messages', 'recipients', 'viruses'] >> > >> > how would I iterate over the list and use the values as variables and >> > open the variable names a files

Re: use fileinput to read a specific line

2008-01-08 Thread Martin Marcher
jo3c wrote: > i need to read line 4 from a header file http://docs.python.org/lib/module-linecache.html ~/2delete $ cat data.txt L1 L2 L3 L4 ~/2delete $ python Python 2.5.1 (r251:54863, May 2 2007, 16:56:35) [GCC 4.1.2 (Ubuntu 4.1.2-0ubuntu4)] on linux2 Type "help", "copyright", "credits" or "

Re: Look for a string on a file and get its line number

2008-01-08 Thread Martin Marcher
Jeroen Ruigrok van der Werven wrote: > -On [20080108 09:21], Horacius ReX ([EMAIL PROTECTED]) wrote: >>I have to search for a string on a big file. Once this string is >>found, I would need to get the number of the line in which the string >>is located on the file. Do you know how if this is possi

Re: Python's great, in a word

2008-01-07 Thread Martin Marcher
On Monday 07 January 2008 21:25 Dustan wrote: > On Jan 7, 11:40 am, Martin Marcher <[EMAIL PROTECTED]> wrote: >> it's pythonicness. > > "it is pythonicness"??? not all here are native english speakers, but thanks for the correction. I&

Re: Python's great, in a word

2008-01-07 Thread Martin Marcher
[EMAIL PROTECTED] wrote: > The best thing about Python is ___. it's pythonicness. -- http://noneisyours.marcher.name http://feeds.feedburner.com/NoneIsYours You are not free to read this message, by doing so, you have violated my licence and are required to urinate publicly. Thank you. --

Re: Delete lines containing a specific word

2008-01-06 Thread Martin Marcher
On Sunday 06 January 2008 21:25 Francesco Pietra wrote: >> yes lines starting with a "#" are comments in python but that shouldn't >> be of concern for your input data. I don't quite get what you want >> here... > > Leaving the lines commented out would permit to resume them or at least > remeber

Re: Delete lines containing a specific word

2008-01-06 Thread Martin Marcher
On Sunday 06 January 2008 18:21 Francesco Pietra wrote: > Please, how to adapt the following script (to delete blank lines) to > delete lines containing a specific word, or words? > > f=open("output.pdb", "r") > for line in f: > line=line.rstrip() > if line: > print line > f.close() >>> import r

[OT] How is AI implemented

2008-01-03 Thread Martin Marcher
Hi, I know it's not a trivial field but I had some readings about artificial intelligence lately and my personal conclusion is that it's mostly just statistics. Naively explained: continiously gather and store information and apply a default rating 1) answer "questions" with gathered informatio

Re: which configparse?

2007-12-06 Thread Martin Marcher
Hi, On 12/6/07, Neal Becker <[EMAIL PROTECTED]> wrote: > configparse looks like what I want, but it seems last commit was >2years > ago. > > What is the best choice? that seems like configparse is the best choice. I use it quite often and no commit in >2years to me means "Boy that's stable softwa

Re: how to know if folder contents have changed

2007-11-17 Thread Martin Marcher
I just found this for win32 which seems to be the same as FAM provides: http://tgolden.sc.sabren.com/python/win32_how_do_i/watch_directory_for_changes.html So it's not about FAM as a definitive product to be used but more like something nearer to the OS that is there anyway and will tell you abou

Re: how to know if folder contents have changed

2007-11-17 Thread Martin Marcher
I think that without further information from the OP about the requirements all we can do is guessing. So both of our solutions are just theory after all (just my personal opinion) 2007/11/14, [EMAIL PROTECTED] <[EMAIL PROTECTED]>: > On Nov 12, 11:27 am, "Martin Marcher" <[E

[OT] The Jew Spam on this list

2007-11-13 Thread Martin Marcher
Hello, please do not respond to the "political" spam on this list anymore. Rather report it as spam to your provider/anti-spam-measures or report it to the listmasters (if you have the feeling that it helps, I guess they're already on this issue). I understand that this might be a heated topic bu

Re: how to know if folder contents have changed

2007-11-12 Thread Martin Marcher
2007/11/12, [EMAIL PROTECTED] <[EMAIL PROTECTED]>: > Why not use the file creation/modification timestamps? because you'd have to a) create a thread that pulls all the time for changes or b) test everytime for changes fam informs in a notification like way. Personally I'd create a "hidden" cach

reading file objects in chunks

2007-11-12 Thread Martin Marcher
Hi, I'm looking for something that will give me an iterator to a file-(like)-object. I have large files with only a single line in it that have fixed length fields like, record length is 26bytes, dataA is 10 bytes, dataB is 16 bytes. Now when I made my parsing stuff but can't find anything that w

Re: regular expression syntax the same in Python, Perl and grep?

2007-11-07 Thread Martin Marcher
2007/11/7, Chris Mellon <[EMAIL PROTECTED]>: > On Nov 7, 2007 12:11 PM, [EMAIL PROTECTED] > <[EMAIL PROTECTED]> wrote: > > How similar is Python's re module (regular expressions) compared > > to Perl's and grep's regular expression syntaxes? > > > > Somewhat. > > > I really hope regular expression

Re: Library package import question

2007-11-05 Thread Martin Marcher
2007/11/5, Frank Aune <[EMAIL PROTECTED]>: > To prevent namespace pollution, I want to import and use this library in the > following way: > > import Foo > (...) > t = Foo.module2.Bee() from x import y as z that has always worked for me to prevent pollution... -- http://noneisyours.marcher.na

Re: dictionary viewer

2007-11-05 Thread Martin Marcher
2007/11/5, [EMAIL PROTECTED] <[EMAIL PROTECTED]>: > On Nov 5, 3:10 pm, Erika Skoe <[EMAIL PROTECTED]> wrote: > > > > That's funny, I can't see anything. Of course, it's an empty dict! tzz, *shaking head* martin -- http://noneisyours.marcher.name http://feeds.feedburner.com/NoneIsYours -- http:

Re: shouldn't 'string'.find('ugh') return 0, not -1 ?

2007-10-31 Thread Martin Marcher
2007/10/31, jelle <[EMAIL PROTECTED]>: > the subject pretty much says it all. > if I check a string for for a substring, and this substring isn't found, > should't the .find method return 0 rather than -1? > this breaks the IMHO "0" would mean the substring starts at index 0 of the iterable. If t

Proxying downloads

2007-10-30 Thread Martin Marcher
Hello, more a recipe question. I'm working on a proxy that will download a file for a client. The thing that doesn't yield problems is: Alice (Client) Bob (Client) Sam (Server) 1 Alice asks Sam for "foobar.iso" 2 Sam can't find "foobar.iso" in "cachedir" 3 Sam requests "foobar.iso" from the upli

Re: A class question

2007-10-29 Thread Martin Marcher
2007/10/29, Hrvoje Niksic <[EMAIL PROTECTED]>: > Sbe unpx inyhr, urer vf n cbffvoyr vzcyrzragngvba: > ... was that on purpose? martin -- http://noneisyours.marcher.name http://feeds.feedburner.com/NoneIsYours -- http://mail.python.org/mailman/listinfo/python-list

Re: sharing vars with different functions

2007-10-29 Thread Martin Marcher
I hate gmail, always forgetting to set the right recipient... -- Forwarded message -- From: Martin Marcher <[EMAIL PROTECTED]> Date: 29.10.2007 10:11 Subject: Re: sharing vars with different functions To: "[EMAIL PROTECTED]" <[EMAIL PROTECTED]> 2007/1

Re: os.walk and recursive deletion

2007-10-28 Thread Martin Marcher
27 Oct 2007 17:38:10 GMT, Marc 'BlackJack' Rintsch <[EMAIL PROTECTED]>: > On Sat, 27 Oct 2007 18:07:44 +0200, Martin Marcher wrote: > > I'm playing around with os.walk and I made up del_tree(path) which I > > think is correct (in terms of the algorithm, but not

os.walk and recursive deletion

2007-10-27 Thread Martin Marcher
Hello, I'm playing around with os.walk and I made up del_tree(path) which I think is correct (in terms of the algorithm, but not as python wants it :)). As soon as some directory is deleted the iterator of os.walk chokes. OK that is somehow clear to me as it can't be valid anymore since it can't

Re: "Standard" Full Text Search Engine

2007-10-26 Thread Martin Marcher
2007/10/26, [EMAIL PROTECTED] <[EMAIL PROTECTED]>: > On Oct 26, 8:53 am, "Diez B. Roggisch" <[EMAIL PROTECTED]> wrote: > > Martin Marcher wrote: > Thanks for the NUCULAR mention (http://nucular.sourceforge.net). It > certainly doesn't meet all the re

"Standard" Full Text Search Engine

2007-10-26 Thread Martin Marcher
Hello, is there something like a standard full text search engine? I'm thinking of the equivalent for python like lucene is for java or ferret for rails. Preferrably something that isn't exactly a clone of one of those but more that is python friendly in terms of the API it provides. Things I'd

Re: Eclipse Plugins

2007-10-26 Thread Martin Marcher
2007/10/26, Robert Rawlins - Think Blue <[EMAIL PROTECTED]>: > I'm not sure what you IDE you all generally use for your python development. > I've been somewhat lazy and always used a plain text editor, however this > technique is starting to take its toll, and it's purely been out of laziness > no

Re: print vs sys.stdout.write, and UnicodeError

2007-10-25 Thread Martin Marcher
25 Oct 2007 17:37:01 GMT, Brent Lievers <[EMAIL PROTECTED]>: > Greetings, > > I have observed the following (python 2.5.1): > > >>> import sys > >>> print sys.stdout.encoding > UTF-8 > >>> print(u'\u00e9') > é > >>> sys.stdout.write(u'\u00e9\n') > Traceback (most recent call last): > File "", lin

Re: New to Vim and Vim-Python

2007-10-24 Thread Martin Marcher
Hello, 2007/10/24, Daniel Folkes <[EMAIL PROTECTED]>: > I am new to using Vim's scripts. > I was wondering if anyone uses Vim-Python and how to use it? This > includes things like key bindings and such. are you talking about * how to use vim? * http://www.vi-improved.org/tutorial.php * how to

Re: Test for a unicode string

2007-10-24 Thread Martin Marcher
2007/10/24, goldtech <[EMAIL PROTECTED]>: > Question: Is there a way to test a string for unicode chars (ie. test > if a string will throw the error cited above). yes there ist :) >>> isinstance(u"a", basestring) True >>> isinstance(u"a", unicode) True >>> isinstance("a", unicode) False >>> isins

Re: crontab library

2007-10-24 Thread Martin Marcher
2007/10/24, Guilherme Polo <[EMAIL PROTECTED]>: > 2007/10/24, Martin Marcher <[EMAIL PROTECTED]>: > > I had a look at the crontab docs and never realized how complex it > > actually is. So before I spend time in creating such a thing maybe > > someone did it alread

crontab library

2007-10-24 Thread Martin Marcher
Hello, is anyone aware of a crontab library. Possibly even more complete, something that will let me create/manipulate/delete crontab entries in a nice way and install the new crontab accordingly. I had a look at the crontab docs and never realized how complex it actually is. So before I spend t

Re: C++ version of the C Python API?

2007-10-23 Thread Martin Marcher
2007/10/21, Robert Dailey <[EMAIL PROTECTED]>: > On 10/21/07, "Martin v. Löwis" <[EMAIL PROTECTED]> wrote: > > No, I literally meant that the Python C API is object-oriented. > > You don't need an object-oriented language to write object-oriented > > code. > > I disagree with this statement. C is n

Re: test if email

2007-10-12 Thread Martin Marcher
2007/10/12, Grant Edwards <[EMAIL PROTECTED]>: > On 2007-10-12, Florian Lindner <[EMAIL PROTECTED]> wrote: > > > I was just asking for the correct syntax of the mail address. I know about > > the various problems actually impossibility to test for a live and valid > > address. > > Don't forget to a

Re: We need PIGs :)

2007-08-30 Thread Martin Marcher
Hello, On 30 Aug 2007 07:14:25 GMT, Marc 'BlackJack' Rintsch <[EMAIL PROTECTED]> wrote: > On Thu, 30 Aug 2007 07:10:47 +0200, Martin Marcher wrote: > > > Does that sound like a good idea or would that be over formalization? > > Sounds like over engineering/forma

We need PIGs :)

2007-08-29 Thread Martin Marcher
Hello, having worked quite a bit with python in the last months (some Java before, and some C++ before that) I was very impressed by an idea the Java people had. Explanation: the JSRs define how to implement certain services and or features in Java so that they can be reused. I haven't found such