Re: How to do *args, **kwargs properly

2005-10-11 Thread Max M
Lasse Vågsæther Karlsen wrote: > Max M wrote: > So what you're saying is that instead of: > > def fn(*values, **options): > > I should use: > > def fn(values, cmp=cmp): > > in this specific case? > > and then instead of: > > fn(1, 2

dictionnaries and lookup tables

2005-10-11 Thread m . barenco
Hello, I am considering using dictionnaries as lookup tables e.g. >>>D={0.5:3.9,1.5:4.2,6.5:3} and I would like to have a dictionnary method returning the key and item of the dictionnary whose key is smaller than the input of the method (or <=,>,>=) but maximal (resp. maximal,minimal,minimal) eg

Re: dictionnaries and lookup tables

2005-10-11 Thread m . barenco
>Sure they're implemented. Oops, my apologies. Just to build up on that, when I run: #start of listing import random A={1:None,2:None,"hello":None,(1,2,3):None} def dictcomp(n): for i in range(n): B=A.copy() C=A.copy() b=random.uniform(0,

Re: dictionnaries and lookup tables

2005-10-11 Thread m . barenco
Ok, Thanks for your answers, that's pretty unambiguous. M. -- http://mail.python.org/mailman/listinfo/python-list

Re: Advice on this code

2005-10-12 Thread Steve M
output.write(wrkmisc(ifile,2582)) output.write(wrkviol(ifile,2774,16)) output.write(wrkaccid(ifile,3270,16)) output.write(wrkmisc2(ifile,3638)) output.write(wrkcov(ifile,3666,6))

Re: Well written open source Python apps

2005-10-13 Thread Steve M
Here is an article discussing the coding style of BitTorrent. http://www.onlamp.com/pub/a/python/2003/7/17/pythonnews.html Maybe that code is worth looking at. -- http://mail.python.org/mailman/listinfo/python-list

Re: Queue question

2005-10-15 Thread Steve M
According to my "Python in a Nutshell": q.get(block=True) is the signature, so, as you use it above, the call will hang until something is on the queue. If block is false and the queue is empty, q.get() will raise the exception Empty. q.get_nowait is apparently synonymous with q.get(block=False)

Re: Problem Pythoncard tutorial

2005-10-17 Thread Steve M
I'd say that the tutorial text (by Dan Shafer) and the file starter1.py are not in sync. The word 'self' doesn't appear in the source file, it isn't a keyword (just a convention) or a literal, and it isn't imported by wildcard or some other trickery. So just by inspection you can tell that the nam

在消息 "test"中发现病毒

2005-10-18 Thread m . hadfield
The message contains Unicode characters and has been sent as a binary attachment. -- http://mail.python.org/mailman/listinfo/python-list

Re: Python vs Ruby

2005-10-23 Thread Max M
e program in > less time. In my experience the LOC count is *far* less significant than the levels of indirections. Eg. how many levels of abstraction do I have to understand to follow a traceback, or to understand what a method relly does in a complex system. -- hilsen/regards Max M

Python 2.3.4, Berkeley db 1.85, db file format not recognized

2005-10-26 Thread Dan M
I'm working on a script that will interface with sendmail on my FreeBSD box. I'm trying to read my access.db file (yes, it's for a quick and dirty SMTP-after-POP application). I'm trying: import bsddb bsddb.hashopen("access.db") but I get: bsddb._db.DBInvalidArgError: (22, 'Invalid argument -- ac

Re: Python 2.3.4, Berkeley db 1.85, db file format not recognized

2005-10-26 Thread Dan M
On Wed, 26 Oct 2005 14:23:49 -0500, skip wrote: > > Dan> import bsddb > Dan> bsddb.hashopen("access.db") > > Dan> but I get: > Dan> bsddb._db.DBInvalidArgError: (22, 'Invalid argument -- access.db: > unexpected file type or format') > > Dan> Any suggestions on how to r

Building 2.4.2 on OpenBSD 3.8

2005-10-29 Thread Dan M
I've been working with python 2.2.3 for the last couple of weeks, but would like to move up to 2.4. I grabbed the 2.4.2 tarball and attempted to install, but I get: gcc -pthread -c -fno-strict-aliasing -DNDEBUG -g -O3 -Wall -Wstrict-prototypes -I. -I./Include -DPy_BUILD_CORE -o Modules/python.o

Re: query a port

2005-10-29 Thread Dan M
On Sat, 29 Oct 2005 20:21:20 -0700, eight02645999 wrote: > hi > in python, how do one query a port to see whether it's up or not? > thanks I'm an absolute beginner, but let's see if I can help. Assuming you want to check a port on another machine, import socket port=25 # Port we

Re: query a port

2005-10-30 Thread Dan M
On Sat, 29 Oct 2005 23:21:16 -0700, eight02645999 wrote: > thanks alot! > that's all there is to it..so it's just a simple connect. If all you want to do is check that the given port is open on the given host, that's it. I tried it on my local box. When connecting to port 25, it made the connecti

Re: Python for .NET and IronPython

2005-11-02 Thread Steve M
I was under the impression that IronPython is like CPython and Jython, namely an implementation of the Python language. So in that sense it is exactly like normal Python, although I don't know how convenient it is to deploy. I was also under the impression that Python for .NET is like an API wrapp

Re: convert COM obj to integer

2005-11-02 Thread Steve M
I don't know exactly what a COM object is, but those aren't them. The win32com package takes care of converting everything to Python types. The excel call returns a tuple of tuples. That is, the outer tuple is the sequence of rows, and each such row is itself a tuple with one member per column requ

Re: Using Which Version of Linux

2005-11-05 Thread Dan M
On Sat, 05 Nov 2005 04:26:38 -0600, blahman wrote: > ok, i m going to use Linux for my Python Programs, mainly because i > need to see what will these fork() and exec() do. So, can anyone tell > me which flavour of linux i should use, some say that Debian is more > programmer

Re: So, Which Version is Suitable for Beginners

2005-11-06 Thread Steve M
There is a new gratis VMWare player at http://www.vmware.com/download/player/ You can download an image http://www.vmware.com/vmtn/vm/browserapp.html that they call a Browser Appliance, but if I remember correctly it is Ubuntu. -- http://mail.python.org/mailman/listinfo/python-list

Re: Using Which Version of Linux

2005-11-06 Thread Steve M
Max wrote: > (Mark Shuttleworth, ... > really loves Python - he gave me quite a lot of money for using it). Please elaborate. -- http://mail.python.org/mailman/listinfo/python-list

Re: Sending email in utf-8?

2005-11-08 Thread Max M
success = 0 try: cleaner = lambda adresses: [adress.strip() for adress in adresses.split(',') if adress.strip()] all_receivers = cleaner(to) + cleaner(cc) + cleaner(bcc) all_receivers = list(set(all_receivers)) if all_receivers: # only send if any recipients self._mailhost().send(str(msg), mto=all_receivers, mfrom=mfrom) success = 1 except: pass -- hilsen/regards Max M, Denmark http://www.mxm.dk/ IT's Mad Science -- http://mail.python.org/mailman/listinfo/python-list

Re: A Tcl/Tk programmer learns Python--any advice?

2005-11-08 Thread Steve M
Even though its for any (not just Tcl) experienced programmer, and even though you've got all the appropriate resources, I'll mention that you should get a lot out of the book Dive Into Python, at http://www.diveintopython.org/ -- http://mail.python.org/mailman/listinfo/python-list

Re: append to non-existing list

2005-11-09 Thread Max M
guess that's normal as it's the way python works...?!? Well you could do something like this. (Untested and unrecommended) self.__dict__.setdefault('pkcolumns', []).append(row[0].strip()) Personally I find pkcolumns = [] pkcolumns .append(row[0].strip()) to be nicer ;-) -- hilsen/regards Max M, Denmark http://www.mxm.dk/ IT's Mad Science -- http://mail.python.org/mailman/listinfo/python-list

Re: newbie - How do I import automatically?

2005-11-16 Thread Steve M
The file C:\Python24\Lib\sitecustomize.py (which I think doesn't exist by default) executes every time Python starts. (This means not just your IDLE session but every time you run any Python script.) One use for this file is to invoke sys.setdefaultencoding because that name gets deleted during in

Re: the PHP ternary operator equivalent on Python

2005-11-18 Thread Steve M
Another way to simulate the ternary operator is this: a = (quantity > 90 and "It is very huge") or "The value is correct" You have to be careful of semantics of 'and' and 'or'. But in this case I wonder why you don't just test whether quantity is greater than 90 and assign the corresponding value

Reading binary data

2005-11-23 Thread David M
OK so here is my task. I want to get at the data stored in /var/account/pacct, which stores process accounting data, so that I can make it into a more human understandable format then what the program sa can do. The thing is, its in a binary format and an example program that reads some data from

Timeout in urllib2

2005-11-23 Thread Dan M
I'm writing a system monitor script that needs to load web pages. I'm using urllib2.urlopen to get the pages, and I'm attempting to set the timeout value using socket.defaulttimeout. Specifically, I'm calling socket.defaultttimeout(10), then calling urllib2.urlopen to fetch a web page that never g

Re: Reading binary data

2005-11-23 Thread David M
Thanks but the C Struct describing the data doesn't match up with the list on the module-struct page. this is the acct.h file #ifndef _SYS_ACCT_H #define _SYS_ACCT_H 1 #include #define __need_time_t #include #include __BEGIN_DECLS #define ACCT_COMM 16 /* comp_t is a 16-bit "floating

Re: Python Midi Package: writing events non-chronologically

2005-11-24 Thread Max M
structure is then is complete, you use the midi library to write it to disk. I have attached a simple example here. -- hilsen/regards Max M, Denmark http://www.mxm.dk/ IT's Mad Science # event classes. Only used internally by notes2midi class NoteOn: def __init__(self, time=0, pit

Re: Dive into Python PDF

2005-11-29 Thread Steve M
You should buy the book in hardcopy, that one looks fine. -- http://mail.python.org/mailman/listinfo/python-list

Re: how to handle two forms in cgi?

2005-11-30 Thread Dan M
> My question is: How let these two form works together? I try to use > two codes for these two forms, e.g. Login.py for login form and > search.py for search form. But when user input data in search form and > click its submit button, it just comes back to login form. Second form > doesn't work.

Re: Python web publishing framework like Cocoon?

2005-12-07 Thread Dan M
> Is there a Python web publishing framework like Cocoon? > > I found Maki but it was last updated in > 2003 and its author says that he doesn't want to make another release... How about: http://www.cherrypy.org/ http://www.turbogears.org/ http://www.djangoproject.

Re: Calling Function Without Parentheses!

2005-01-02 Thread Max M
a('default result') -- hilsen/regards Max M, Denmark http://www.mxm.dk/ IT's Mad Science -- http://mail.python.org/mailman/listinfo/python-list

Re: csh to Python

2005-01-04 Thread Max M
Nader Emami wrote: Hello, I am new in Python world, and would like to begin with translate a csh file to a python script. Could somebody give me an advise (documentation or web-site) where I can do that. You are probably interrested in the os 6 os.path modules. -- hilsen/regards Max M, Denmark

Re: Dr. Dobb's Python-URL! - weekly Python news and links (Dec 30)

2005-01-04 Thread Max M
unicode string into a special string/file format # and you can decode a string from a special string/file format back into unicode. ### u'Some danish characters \xe6\xf8\xe5' 'Some danish characters \xe6\xf8\xe5' Some danish characters æøå

Re: Dr. Dobb's Python-URL! - weekly Python news and links (Dec 30)

2005-01-04 Thread Max M
range(128) Hm, why does the 'encode' call complain about decoding? Because it tries to print it out to your console and fail. While writing to the console it tries to convert to ascii. Beside, you should write: u"ä".encode("latin-1") to get a latin-1 encoded stri

Re: Dr. Dobb's Python-URL! - weekly Python news and links (Dec 30)

2005-01-05 Thread Max M
code('utf-8') >>u'INBOX' Tn that case id.decode('hex') doesn't return a unicode, but a utf-8 encoded string. -- hilsen/regards Max M, Denmark http://www.mxm.dk/ IT's Mad Science -- http://mail.python.org/mailman/listinfo/python-list

Re: smtp question

2005-01-05 Thread Max M
TED]' >>> to = '[EMAIL PROTECTED]' >>> msg = Message() >>> msg['Subject'] = 'From Python' >>> msg['From'] = fromaddr >>> msg['To'] = to >>> body = "This is the message content" >&g

Returning same type as self for arithmetic in subclasses

2005-01-07 Thread Max M
thods? """ from datetime import datetime, timedelta class myDatetime(datetime): pass class myTimedelta(timedelta): pass if __name__ == "__main__": import os.path, doctest, dtime # import and test this file doctest.testmod(dtime) -- hilsen/regards Max M, Denmark http://www.mxm.dk/ IT's Mad Science -- http://mail.python.org/mailman/listinfo/python-list

Re: Returning same type as self for arithmetic in subclasses

2005-01-08 Thread Max M
))) except: raise ValueError, 'Wrong format' return vDatetime(*timetuple) fromstring = staticmethod(fromstring) def __str__(self): return self.strftime("%Y%m%dT%H%M%S") -- hilsen/regards Max M, Denmark http://www.mxm.dk/ IT's Mad Science -- http://mail.python.org/mailman/listinfo/python-list

Re: Another look at language comparisons

2005-01-08 Thread Max M
Jan Dries wrote: [EMAIL PROTECTED] wrote: And there is hope for Python, as Guido has recently been seen with a beard :-) http://www.tbray.org/ongoing/When/200x/2004/12/08/-big/IMG_3061.jpg LOL, he is working on linux, isn't he? So it was about bloody time. -- hilsen/regards Max M, Denmark

Re: Weekly Python Patch/Bug Summary

2005-01-08 Thread Max M
Kurt B. Kaiser wrote: Remove witty comment in pydoc.py (2005-01-01) CLOSED http://python.org/sf/1094007 opened by Reinhold Birkenfeld This is not a joke? :-) -- hilsen/regards Max M, Denmark http://www.mxm.dk/ IT's Mad Science -- http://mail.python.org/mailman/listinfo/python-list

oddities in the datetime module

2005-01-14 Thread Max M
etimetuple) class date2(date): def datetimetuple(self): return self.timetuple()[:6] + (0, None) def from_datetimetuple(dt_tuple): return date2(*dt_tuple[:3]) from_datetimetuple = staticmethod(from_datetimetuple) #from datetime import datetime # #ical = Calendar() #print ical.ical() if

Re: oddities in the datetime module

2005-01-14 Thread Max M
Serge Orlov wrote: Max M wrote: Yes, you did. datetime.timetuple is those who want *time module* format, you should use datetime.data, datetime.time, datetime.year and so on... As they say, if the only tool you have is timetuple, everything looks like tuple Try this: dt = datetime(2005, 1, 1

[ANN] iCalendar package 0.9

2005-01-17 Thread Max M
Api is pretty stable, and will probably not change much. I would like anybody interrested to give it a test drive before I finish it off and make it a 1.0. http://www.mxm.dk/products/public/ical/ Any feedback would be welcome. -- hilsen/regards Max M, Denmark http://www.mxm.dk/ IT's Mad Sc

Re: [ANN] iCalendar package 0.9

2005-01-18 Thread Max M
Roger Binns wrote: "Max M" <[EMAIL PROTECTED]> wrote in message news:[EMAIL PROTECTED] http://www.mxm.dk/products/public/ical/ Any feedback would be welcome. How well do you cope with the crud that real programs generate? Does it work with the different dialects uses out there?

Re: find isset() php function equivalent in python

2005-02-01 Thread Max M
bad practice to do it like that. If you need variables that you don't know that name of, you should put them in a dictionary. They are made for that exact purpose. >>> unkown_vars = {} >>> unkown_vars['variable'] = 42 >>> 'variable' in unkown

Re: Remove HTML tags (except anchor tag) from a string using regular expressions

2005-02-01 Thread Max M
Nico Grubert wrote: If it's not to learn, and you simply want it to work, try out this library: http://zope.org/Members/chrisw/StripOGram/readme -- hilsen/regards Max M, Denmark http://www.mxm.dk/ IT's Mad Science -- http://mail.python.org/mailman/listinfo/python-list

Re: Printing Filenames with non-Ascii-Characters

2005-02-02 Thread Max M
g cookie in your file? Try adding this as the first or second line. # -*- coding: cp850 -*- Python will then know how your file is encoded -- hilsen/regards Max M, Denmark http://www.mxm.dk/ IT's Mad Science -- http://mail.python.org/mailman/listinfo/python-list

global name not defined :$

2005-06-20 Thread Anna M.
enough for you guys to see the problem, how ever the class is almost 200 lines so I just didn’t want to put it all in the post.   Many thanks, Anna M.   class node:     def __init__(self,g=None):     self.data="">     self.parent=None     self.child=[None,None]

Re: Boss wants me to program

2005-06-28 Thread Max M
ll not be as > mysterious or dangerous. I agree. The language is more important than the gui. It is not very hard to make good applikations in eg. Tkinter, and you will understand evey part of it. -- hilsen/regards Max M, Denmark http://www.mxm.dk/ IT's Mad Science -- http://mail.python.

Re: Modules for inclusion in standard library?

2005-07-01 Thread Max M
gestion to start with. ctypes certainly. Even though it can crash Python. People using ctypes would be aware of this. Another good bet is BeautifulSoup, which is absolutely great for scraping content from webpages. http://crummy.com/software/BeautifulSoup/index.html -- hilsen/regards

Re: What are the other options against Zope?

2005-07-04 Thread Max M
objects can then be called eg. from a web browser with different parameters. But you can also use other protocols than http like dav, ftp etc. This is a very effective way to build web applications, and does not need sql-object remapping as normal web apps does. -- hilsen/regards Max

Re: f*cking re module

2005-07-04 Thread Max M
rom a reference! If you want to try out re interactively you could use: \Tools\Scripts\redemo.py -- hilsen/regards Max M, Denmark http://www.mxm.dk/ IT's Mad Science -- http://mail.python.org/mailman/listinfo/python-list

Re: mail sending using telnet in python

2005-07-08 Thread Max M
on but I cann't > get solution for it. Why not just use the smtp module? It's a tad easier. -- hilsen/regards Max M, Denmark http://www.mxm.dk/ IT's Mad Science -- http://mail.python.org/mailman/listinfo/python-list

Re: Help with mass remove in text file

2005-07-13 Thread Steve M
First, in your intro you say you want to remove all strings of the form "f=n;" where n can be 0-14. So you want to remove "f=0;" and "f=1;" and ... Later, you appear to be trying to remove "f=;" which may be what you want but it doesn't match your described intentions. Second, the formatting (whit

Re: PY2EXE => Is there a way to go backwards? EXE2PY

2005-07-13 Thread Steve M
>I have the executable of a script that I wrote, that has been erased. >Is there any way to retrieve the uncompiled python script from the >executable that was created with py2exe? You're gonna need a case of 20-weight ball bearings and several quarts of antifreeze. Preferably Quakerstate. No, be

Re: How to run python script in background after i logout

2005-07-24 Thread Steve M
Harlin Seritt wrote: > I have a remote linux server where I can only access it via ssh. I have > a script that I need to have run all the time. I run like so: > > python script.py & > > It runs fine. When I log off ssh I notice that the script died when I > logged off. How do I make sure it stays r

Re: Create a variable "on the fly"

2005-07-27 Thread Steve M
PythonWin 2.3.5 (#62, Feb 9 2005, 16:17:08) [MSC v.1200 32 bit (Intel)] on win32. Portions Copyright 1994-2004 Mark Hammond ([EMAIL PROTECTED]) - see 'Help/About PythonWin' for further copyright information. >>> locals()['OSCAR'] = 'the grouch' >>> OSCAR 'the grouch' >>> -- http://mail.python.or

python SMTP server

2005-07-30 Thread Fernando M.
Hi, i made a test with smtplib module a few days ago, for sending mails, and i was wondering if there's another module for running an SMTP server, so i could make a standalone script for sending mails without using an external SMTP server. I've been searching but i'm not sure if there are modules f

Re: trying to parse non valid html documents with HTMLParser

2005-08-03 Thread Steve M
>You were right, the HTMLParser of htmllib is more permissive. He just ignores the bad tags ! The HTMLParser on my distribution is a she. But then again, I am using ActivePython on Windows... -- http://mail.python.org/mailman/listinfo/python-list

Printing to printer

2005-08-11 Thread Steve M
Hello, I'm having problems sending information from a python script to a printer. I was wondering if someone might send me in the right direction. I wasn't able to find much by Google TIA Steve -- http://mail.python.org/mailman/listinfo/python-list

Re: Printing to printer

2005-08-11 Thread Steve M
Kristian Zoerhoff wrote: > On 8/11/05, Steve M <[EMAIL PROTECTED]> wrote: >> Hello, >> >>I'm having problems sending information from a python >> script to a printer. I was wondering if someone might send me >> in the right direction. I w

Re: Psyco & Linux

2005-08-11 Thread Steve M
> First, I tried the usual "python setup.py install" but that did not work. How exactly did it fail? Perhaps you can paste the error output from this command. -- http://mail.python.org/mailman/listinfo/python-list

Re: Python's Exception, and Capitalization

2005-08-12 Thread Steve M
You might find the Python Style Guide to be helpful: http://www.python.org/doc/essays/styleguide.html -- http://mail.python.org/mailman/listinfo/python-list

Re: Printing to printer

2005-08-12 Thread Steve M
ees or warranties. > > Hope it helps. > > Larry Bates > > Steve M wrote: >> Hello, >> >> I'm having problems sending information from a python >> script to a printer. I was wondering if someone might send me >> in the right direction. I wasn&#

Re: Printing to printer

2005-08-12 Thread Steve M
Kristian Zoerhoff wrote: > On 8/11/05, Steve M <[EMAIL PROTECTED]> wrote: >> Kristian Zoerhoff wrote: >> >> > On 8/11/05, Steve M <[EMAIL PROTECTED]> wrote: >> >> Hello, >> >> >> >>I'm having problems sending in

Re: Psyco & Linux

2005-08-12 Thread Steve M
> c/codegen.h:19:3: #error "sorry -- I guess it won't work like that on 64-bits > machines" The first error output by gcc suggests the 64-bit OS might be the problem. But I don't actually know what that error means. -- http://mail.python.org/mailman/listinfo/python-list

Re: Iterparse and ElementTree confusion

2005-08-17 Thread Steve M
"when i attempted [to load 150MB xml file] my PC goes to lala land, theres much HDD grinding followed by "windows runnign low on virtual memory" popup after 10-15mins. Then just more grinding...for an hour before i gave up" I have had great success using SAX to parse large XML files. If you use ca

Re: Binary Trees in Python

2005-08-20 Thread Steve M
[diegueus9] Diego Andrés Sanabria <[EMAIL PROTECTED]> wrote: > Hello!!! > > I want know if python have binary trees and more? You might be interested that ZODB comes with some B-tree implementations. They can be used alone or you can persist them in the ZODB quite easily. http://www.zope.org/Wi

Re: Python Light Revisted?

2005-08-20 Thread Steve M
I agree with you in part and disagree in part. I don't see the point to making the distribution any smaller. 10MB for the installer from python.org, 16MB for ActiveState .exe installer. How is 5MB "lightweight" while 10MB isn't? The Windows XP version of Java at java.com is 16+ MB, and the .NET fr

Re: Unix diff command under Window.

2005-08-25 Thread Max M
TonyHa wrote: > Hello, > > Does any one have using Python to write a Unix "diff" command for > Window? I generally just us the diff built into tortoiseSVN. That way it's only a rightclick away. -- hilsen/regards Max M, Denmark http://www.mxm.dk/ IT's Mad Sc

Re: Problem with Pythoncard

2005-08-26 Thread Steve M
There are some Python packages that I prefer to get from the developer instead of from my Linux distribution (Debian). Usually it is because I intend to upgrade the package before, or more often than, my distribution releases a new version. (A likely scenario if you use Debian - zing!) So I downlo

Re: ANN: PyDev 0.9.8 released

2005-08-30 Thread Max M
ing to it, I just wondered what experiences other users might have when using it for production. Being that my text editing environment is my bread and butter. Is it stable/effective etc? Anybody cares to share? -- hilsen/regards Max M, Denmark http://www.mxm.dk/ IT's Mad Science --

Re: ANN: PyDev 0.9.8 released

2005-08-30 Thread Max M
ojects (my current ambient has about 400 python modules, all > managed in pydev). Also, there are no current bug reports for any > instability in pydev. Ok. I am starting a new product for Plone tomorrow, that should take about a week to finish. I will try switching cold-turkey to pyd

Re: Mapping network drive on Linux

2005-08-31 Thread Steve M
You can approximate it by doing this at the command prompt: # mkdir /z #mount //blah/data /z I assume 'blah' is the hostname for a Windows machine and 'data' is the name of a share on blah. You might need to install smbfs and/or use 'mount.smb' and/or use 'mount -t smbfs'. Of course this can all b

Re: is there a better way to check an array?

2005-09-01 Thread Steve M
You can check for membership in a list at least these ways: my_list.index(candidate) -returns the index into my_list of the first occurrence of candidate. Raises ValueError if candidate doesn't occur in my_list. my_list.find(candidate) -returns the index into my_list of the first occurrence of ca

Re: encryption with python

2005-09-07 Thread Steve M
>My goal is to combine two different numbers and encrypt them to create a new number that cann't be traced back to the originals. Here's one: def encrypt(x, y): """Return a number that combines x and y but cannot be traced back to them.""" return x + y -- http://mail.python.org/mailman/l

Re: where is sys.path initialized?

2005-09-09 Thread Steve M
The PYTHONPATH environment variable is good for that. For general customizing beyond the path, you can make a file called: C:\Python24\Lib\site-packages\sitecustomze.py and it will be executed every time python runs. It might look like this: import sys sys.path.insert(0, r'C:\Python24\mypython')

Re: How to protect Python source from modification

2005-09-12 Thread Steve M
This is a heck of a can of worms. I've been thinking about these sorts of things for awhile now. I can't write out a broad, well-structured advice at the moment, but here are some things that come to mind. 1. Based on your description, don't trust the client. Therefore, "security", whatever that a

Re: O'Reilly book on Twisted

2005-09-14 Thread Steve M
Does anybody know: Is this book fully up to date with Twisted 2.0? Does the book cover Nevow at all? Does the book cover general programming concepts related to concurrency? I'm reminded of those high quality articles about Deferreds and event programming by one of the Twisted developers? What

Re: brain cramp: emulating cgi.FieldStorage

2005-09-15 Thread Max M
blank strings. The default false value indicates that blank values are to be ignored and treated as if they were not included. strict_parsing: flag indicating what to do with parsing errors. If false (the default), errors are silently ignored.

Re: IDE, widget library

2005-09-16 Thread Max M
ob on pydev! -- hilsen/regards Max M, Denmark http://www.mxm.dk/ IT's Mad Science -- http://mail.python.org/mailman/listinfo/python-list

Re: dictionary to file

2005-09-16 Thread Max M
and save that to a file. http://docs.python.org/lib/module-pickle.html -- hilsen/regards Max M, Denmark http://www.mxm.dk/ IT's Mad Science -- http://mail.python.org/mailman/listinfo/python-list

Re: C#3.0 and lambdas

2005-09-19 Thread Max M
s it would normally look: def func(*arg) That should work just as well for those cases. -- hilsen/regards Max M, Denmark http://www.mxm.dk/ IT's Mad Science -- http://mail.python.org/mailman/listinfo/python-list

Windows paths, Java, and command-line arguments, oh my!

2005-09-19 Thread Steve M
I'm trying to invoke a Java command-line program from my Python program on Windows XP. I cannot get the paths in one of the arguments to work right. The instructions for the program describe the following for the command-line arguments: java -jar sforcedataloader.jar -Dsalesforce.config.dir=CONFI

Re: Windows paths, Java, and command-line arguments, oh my!

2005-09-19 Thread Steve M
Well, apparently I fried my brain trying to sort this out. There is a typo in my example code in the post but not in my real program. (I know it is a no-no when asking help on c.l.py but I simplified some details from the real code in order not to confuse the issues. Probably backfired by this poin

Re: Getting tired with py2exe

2005-09-20 Thread Steve M
What about PyInstaller that was announced the other day? The feature list looks great, and it appears the developers intend to maintain and enhance the program indefinitely. http://groups.google.com/group/comp.lang.python/browse_thread/thread/b487056b7b1f99bc/583da383c1749d9f?q=ANN&rnum=1&hl=en#58

Re: Windows paths, Java, and command-line arguments, oh my!

2005-09-21 Thread Steve M
Thank you. I was able to fix it by putting the '-Dwhatever=x' bit before the '-jar y.jar' bit. I had no idea this could matter. Thanks all for the help. -- http://mail.python.org/mailman/listinfo/python-list

Re: Convert from unicode to int

2005-09-22 Thread Max M
Tor Erik Sønvisen wrote: > Hi > > Is there any simpler way to convert a unicode numeric to an int than: > > int(u'1024'.encode('ascii')) why doesn't: int(u'104') work for you? -- hilsen/regards Max M, Denmark http://www.mxm.dk/ I

Re: Is Python as capable as Perl for sysadmin work?

2005-02-08 Thread Max M
x27;t work. You have to suggest that it 'try ... except', which is really offensive. If I want to beg my computer to run programs, I know where to find Intercal with its "PLEASE" and "DO PLEASE" constructions. Wasn't there talk about a "try harder" recently

Re: Big development in the GUI realm

2005-02-11 Thread Max M
developing something like a desktop application that you want to sell for money, using the GPL is a bad idea. -- hilsen/regards Max M, Denmark http://www.mxm.dk/ IT's Mad Science -- http://mail.python.org/mailman/listinfo/python-list

Re: exec function

2005-02-12 Thread scott m
Thanks, both of these examples will help me clean my code and improve it. Scott -- http://mail.python.org/mailman/listinfo/python-list

Re: Why doesn't join() call str() on its arguments?

2005-02-17 Thread Max M
7; Is this really that hard to do, that you want it in the library? -- hilsen/regards Max M, Denmark http://www.mxm.dk/ IT's Mad Science -- http://mail.python.org/mailman/listinfo/python-list

Re: tiff via email-module

2005-02-17 Thread Max M
.append(part.get_payload(decode=1)) return attachments return [] -- hilsen/regards Max M, Denmark http://www.mxm.dk/ IT's Mad Science -- http://mail.python.org/mailman/listinfo/python-list

Tuple index

2005-02-20 Thread Steve M
Hello, I'm trying to figure out the index position of a tuple member. I know the member name, but I need to know the members index position. I know that if I use the statement print tuple[4] that it will print the contents of that location. What I don't understand is if I know that foo is

Re: Tuple index

2005-02-21 Thread Steve M
John Machin wrote: > > Steve M wrote: >> Hello, >> >> I'm trying to figure out the index position of a tuple > member. >> I know the member name, but I need to know the members index > position. > > Tuples, like lists, don't have

Re: Tuple index

2005-02-21 Thread Steve M
Steven Bethard wrote: > Steve M wrote: >> I guess I explained my problem incorrectly. Let me try again. >> >> tuple = ("fred", "barney", "foo") >> >> I know that foo is an element of tuple, but what I need to know is what >> t

Re: Tuple index

2005-02-21 Thread Steve M
Michael Hartl wrote: > I actually find it strange that tuples don't have an index function, > since finding the index doesn't involve any mutation. Anyone know why > Python doesn't allow a statement like t.index('foo')? > > In any case, you can use the index method of list objects if you > conve

Re: Tuple index

2005-02-21 Thread Steve M
John Machin wrote: > > Steve M wrote: >> I'm actually doing this as part of an exercise from a book. What the > program >> is supposed to do is be a word guessing game. The program automaticly >> randomly selects a word from a tuple. > > Care to tell us whi

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