Re: Common Python Idioms

2006-12-08 Thread Daniel Dittmar
John Machin wrote: No it doesn't look wrong to anyone who has read the docs on sys.modules. My point was really that there is no obvious implementation for 'in' on dictionaries, so it should have been left out. And that GvR thought so for quite some time as well (until he got mixed up with a

Re: Common Python Idioms

2006-12-08 Thread Daniel Dittmar
Marc 'BlackJack' Rintsch wrote: If ``in`` shouldn't work with dictionaries, either `__contains__()` must be implemented to throw an exception or dictionaries shouldn't be iterable. I agree completely (in the sense that dictionaries shouldn't be iterable directly). Probably even more strongly,

Re: Common Python Idioms

2006-12-07 Thread Daniel Dittmar
Duncan Booth wrote: In this case, dict objects used to not support the 'in' operator, but at some point it was added. I believe it wasn't there originally because Guido wasn't sure whether people would expect it should match keys or keys and values. And he was right: import sys 'sys' in

Re: Is python memory shared between theads?

2006-12-01 Thread Daniel Dittmar
Wesley Henwood wrote: So I declare a variable named A in thread1, in script1.py. I assign the value of 2.5 to A. I then run script2.py in thread2. Script2.py assigns the value of 5.5 to a variable named A. Now, when thread1 resums execution, I see that A = 5.5, rather than 2.5 as I

Re: Py3K idea: why not drop the colon?

2006-11-09 Thread Daniel Dittmar
Michael Hobbs wrote: But if the BDFL insists that it remains, why not take the converse approach? That is, assume that the expression ends at the colon, not at the newline. That would make this type of statement possible: I suggested something like this a while back. The answer then was

Re: Exploiting Dual Core's with Py_NewInterpreter's separated GIL ?

2006-11-03 Thread Daniel Dittmar
robert wrote: I'd like to use multiple CPU cores for selected time consuming Python computations (incl. numpy/scipy) in a frictionless manner. Interprocess communication is tedious and out of question, so I thought about simply using a more Python interpreter instances

Re: Exploiting Dual Core's with Py_NewInterpreter's separated GIL ?

2006-11-03 Thread Daniel Dittmar
robert wrote: Question Besides: do concurrent INC/DEC machine OP-commands execute atomically on Multi-Cores as they do in Single-Core threads? No on the level that that Python reference counting is implemented. The CPUs have often special assembler ops for these operations. I think that

Re: Exploiting Dual Core's with Py_NewInterpreter's separated GIL ?

2006-11-03 Thread Daniel Dittmar
robert wrote: (IPython is only a special python network terminal as already said.) Sorry, I thought of IronPython, the .NET variant. Does Jython really eliminate the GIL? What happens when different Yes. threads alter/read a dict concurrently - the basic operation in python, which is

Re: can't open word document after string replacements

2006-10-24 Thread Daniel Dittmar
Antoine De Groote wrote: I have a word document containing pictures and text. This documents holds several 'ABCDEF' strings which serve as a placeholder for names. Now I want to replace these occurences with names in a list (members). I open both input and output file in binary mode and do

Re: Installing Python on a 64-Bit OS

2006-09-19 Thread Daniel Dittmar
Nico Grubert wrote: I'd like to install Python 2.3.5. on a 64-Bit OS (Suse Linux Enterprise Server 10) on an AMD Opteron 64-Bit machine. I have to use Python 2.3.5. Do I need a special source archive or can I use Python-2.3.5.tgz from

Re: threading support in python

2006-09-04 Thread Daniel Dittmar
km wrote: Is there any PEP to introduce true threading features into python's next version as in java? i mean without having GIL. when compared to other languages, python is fun to code but i feel its is lacking behind in threading Some of the technical problems: - probably breaks

Re: threading support in python

2006-09-04 Thread Daniel Dittmar
Rob Williscroft wrote: Daniel Dittmar wrote in news:[EMAIL PROTECTED] in comp.lang.python: - removing reference counting and relying on garbage collection alone will break many Python applications (because they rely on files being closed at end of scope etc.) They are already broken

Re: Beginner Textbook

2006-08-15 Thread Daniel Dittmar
M_M wrote: I am looking for a simple text book to introduce 13 to 18 year olds to python programming. Suggestion? If they're Germans: Python für Kids http://www.amazon.de/gp/product/3826609514/028-9407382-2771748?v=glancen=299956 or Python Programming for the Absolute Beginner

Re: Partial classes

2006-07-19 Thread Daniel Dittmar
Sanjay wrote: Hi All, Not being able to figure out how are partial classes coded in Python. Example: Suppose I have a code generator which generates part of a business class, where as the custome part is to be written by me. In ruby (or C#), I divide the code into two source files. Like

Re: CSV with comments

2006-07-19 Thread Daniel Dittmar
Sion Arrowsmith wrote: Daniel Dittmar [EMAIL PROTECTED] wrote: if line [:1] == '#': What's wrong with line[0] == '#' ? (For one thing, it's fractionally faster than [:1].) Matter of taste. Occasionally, I use line iterators that strip the '\n' from the end of each line, so empty

Re: How to use ParseTuple with unknown number of args?

2006-07-18 Thread Daniel Dittmar
ondekoza wrote: The earlier posts generally highlight some specific feature of calling with arrays. Can someone point me to a piece of software, where sth. like this is actually used? Python source/Objects/stringobject.c string_join would be an example if you only allow a list or tuple.

Re: Using Visual Slick Edit for Python

2006-07-18 Thread Daniel Dittmar
Brian Buderman wrote: Anyone know if there is a way to make slickedit tag the built in modules such as os and sys so that code completion and the like work? I don't think that this is possible as the docs are in the python executable. But it should be easy to generate a dummy module: import

Re: CSV with comments

2006-07-18 Thread Daniel Dittmar
GinTon wrote: GinTon wrote: In csv.reader, is there any way of skip lines that start whith '#' or empty lines I would add comments at my CSV file For skip comment I get a dirty trick: reader = csv.reader(open(csv_file)) for csv_line in reader: if csv_line[0].startswith('#'):

Re: Coding style

2006-07-18 Thread Daniel Dittmar
Patrick Maupin wrote: The argument that one should always use len() to test whether sequences are empty or not simply because the use of len() gives a free is it a sequence? type-check is not apt to be well received by an audience which rejects explicit type-checking in general. No explicit

Re: running python from a memory stick?

2006-07-13 Thread Daniel Dittmar
John Salerno wrote: Is there a way to 'install' and use Python on a memory stick, just as you would on any computer? I use Windows, and I know the installation does things with the registry, so probably I couldn't use the executable file to install it. But is it possible to do it some other

Re: Relying on the behaviour of empty container in conditional statements

2006-07-11 Thread Daniel Dittmar
horizon5 wrote: Hi, my collegues and I recently held a coding style review. All of the code we produced is used in house on a commerical project. One of the minor issues I raised was the common idiom of specifing: pre if len(x) 0: do_something() /pre Instead of using the

Re: Questions about OSS projects.

2006-06-28 Thread Daniel Dittmar
bio_enthusiast wrote: I was wondering how to go about starting an open source project for doing routine biological problems? There is a plethora of scripts and a fairly large biopython project to back up anyone who tried, these however cater to the bioinformatics community and it loses the

Re: 'module' object has no attribute 'ssl'

2006-06-21 Thread Daniel Dittmar
Niurka Perez wrote: ssl = socket.ssl(sock, self.key_file, self.cert_file) AttributeError: 'module' object has no attribute 'ssl' The socket module failed to import the _ssl module. And the ssl function gets only defined if _ssl could be imported. You probably haven't installed the

Re: Duplex communication with pipes - is possible ?

2006-06-20 Thread Daniel Dittmar
Dara Durum wrote: Now I trying with packet size decreasing. Are PIPE-s can handle the binary data packets, or I need to convert them with base64 ? In the client, you need to set the mode of sys.stdin to binary, otherwise, you get the DOS translation of linefeeds. See

Re: Duplex communication with pipes - is possible ?

2006-06-16 Thread Daniel Dittmar
Dara Durum wrote: Hi ! I want to create a Process Pool Object. I can hold started processes, and can communicate with them. I tryed with many ipc methods, but every of them have bug or other problem. Sockets are unavailabe (because Windows Firewall hold them). I think I will use pipe.

Re: XML, JSON, or what?

2006-06-16 Thread Daniel Dittmar
My client-server is Python-to-Python. At present, I am using cPickle to transfer objects between the two. Among other things, I sometimes transfer a tuple. Using JSON it appears on the other side as a list. As I sometimes use the tuple as a dictionary key, this fails, as you obviously cannot

Re: DB-API: how can I find the column names in a cursor?

2006-06-01 Thread Daniel Dittmar
A.M wrote: for row in out_cur: print row [...] The other problem is accessing data in each row by column name. One useful technique is for col1, col2, col3 in out_cur: sum = sum + col3 Access is still by index, but your code uses ordinary Python variables. It works better

Re: Is anybody knows about a linkable, quick MD5/SHA1 calculator library ?

2006-05-30 Thread Daniel Dittmar
DurumDara wrote: Hi ! I need to speedup my MD5/SHA1 calculator app that working on filesystem's files. You could try using threads. This would allow the CPU and the disk to work in parallel. The sha/md5 modules don't seem to release the global interpreter lock, so you won't be able to

Re: GUI issues in Python

2006-04-06 Thread Daniel Dittmar
[EMAIL PROTECTED] wrote: I want to create a GUI where a user can select drag and drop kind of boxes, circles and make connections between them. This is basically for depicting states and dependencies. I am writing a program where I let the user input states and dependencies in a certain

Re: GUI issues in Python

2006-04-06 Thread Daniel Dittmar
[EMAIL PROTECTED] wrote: Thanks Daniel, I really think that this should be the solution to my problem. A quick Question...is wxPython Operating System dependent or it can be used with anu OS like Linux, Windows and Mac ? see http://www.wxpython.org/download.php#binaries Linux and Win32

Re: HTMLParser fragility

2006-04-05 Thread Daniel Dittmar
Lawrence D'Oliveiro wrote: I've been using HTMLParser to scrape Web sites. The trouble with this is, there's a lot of malformed HTML out there. Real browsers have to be written to cope gracefully with this, but HTMLParser does not. Not only does it raise an exception, but the parser object

Re: Python and microsoft outlook-using com, can I interact with msoutlook?

2006-04-04 Thread Daniel Dittmar
[EMAIL PROTECTED] wrote: Hi All, I know that Microsoft Exchange has a com interface, CDO, but I can't seem to find one for Microsoft outlook. does anyone have code snippets for using msoutlook and python, or suggestions? You can use CDO to manage your Inbox, send mail etc. The following

Re: import random module

2006-03-22 Thread Daniel Dittmar
DataSmash wrote: Hi, When I import the random module at the python interpreter, it works fine: import random x = random.randint(1,55) print x 14 BUT, when I put the same code in a python script: * random.py: import random x = random.randint(1,55) print x and run it at the

Re: global, globals(), _global ?

2006-03-15 Thread Daniel Dittmar
Roy Smith wrote: In article [EMAIL PROTECTED], robert [EMAIL PROTECTED] wrote: Using global variables in Python often raises chaos. Other languages use a clear prefix for globals. Unsing globals raises chaos in any language. They should be shunned and avoided. Solution: replace

Re: Module written in C does not repond to Ctrl-C interruption.

2006-02-25 Thread Daniel Dittmar
Bo Peng wrote: Daniel Dittmar wrote: You could set up your own signal handler when entering the C extension. This should abort the extension (tricky) and call the Python signal handler. This can be done under linux using things in signal.h but I am not sure whether

Re: Module written in C does not repond to Ctrl-C interruption.

2006-02-24 Thread Daniel Dittmar
Diez B. Roggisch wrote: Although Python signal handlers are called asynchronously as far as the Python user is concerned, they can only occur between the ``atomic'' instructions of the Python interpreter. This means that signals arriving during long calculations implemented purely in C (such

Re: Using repr() with escape sequences

2006-02-23 Thread Daniel Dittmar
nummertolv wrote: - Consider a string variable containing backslashes. - One or more of the backslashes are followed by one of the letters a,b,f,v or a number. myString = bar\foo\12foobar How do I print this string so that the output is as below? bar\foo\12foobar typing 'print

Re: Add a month

2006-02-17 Thread Daniel Dittmar
Fredrik Lundh wrote: [EMAIL PROTECTED] wrote: Hi, this is probably a really simple question but... How do you add a month to a datetime date in python? It would be nice if you could do something like: d = datetime.date(2006,2,17) dm = datetime.timedelta(months=1) d_new = d + dm but

Re: low level data types

2006-02-15 Thread Daniel Dittmar
dementrio wrote: Thanks for the hint! However now I have another problem - endianness (the client runs on powerpc, the server on x86). I found that simply reversing the stuff I recv() works, but is there any cleaner way for taking care of this?

Re: Sharing database connection from C to Python

2006-02-01 Thread Daniel Dittmar
[EMAIL PROTECTED] wrote: I'm developing an application using the C language and Python for it's plugins. The C program connects to a MySQL database and keeps that connection active. Is it possible to 'share' this connection with the Python plugins? If so, is there a standard way to do that?

Re: Multiple modules with database access + general app design?

2006-01-20 Thread Daniel Dittmar
Frank Millman wrote: I have subclassed threading.Thread, and I store a number of attributes within the subclass that are local to the thread. It seems to work fine, but according to what you say (and according to the Python docs, otherwise why would there be a 'Local' class) there must be some

Re: DB API and thread safety

2006-01-20 Thread Daniel Dittmar
Robin Haswell wrote: Hey guys I've been reading http://www.python.org/peps/pep-0249.html and I don't quite get what level of thread safety I need for my DB connections. If I call db = FOOdb::connect() at the start of my app, and then every thread does it's own c = db.cursor() at the top,

Re: Multiple modules with database access + general app design?

2006-01-19 Thread Daniel Dittmar
Robin Haswell wrote: cursor for every class instance. This application runs in a very simple threaded socket server - every time a new thread is created, we create a new db.cursor (m = getattr(modules, module)\n m.c = db.cursor() is the first part of the thread), and when the thread finishes

Re: Multiple modules with database access + general app design?

2006-01-19 Thread Daniel Dittmar
Robin Haswell wrote: On Thu, 19 Jan 2006 14:37:34 +0100, Daniel Dittmar wrote: If you use a threading server, you can't put the connection object into the module. Modules and hence module variables are shared across threads. You could use thread local storage, but I think it's better to pass

Re: Multiple modules with database access + general app design?

2006-01-19 Thread Daniel Dittmar
Robin Haswell wrote: Ah I see.. sounds interesting. Is it possible to make any module variable local to a thread, if set within the current thread? Not directly. The following class tries to simulate it (only in Python 2.4): import threading class ThreadLocalObject (threading.local):

Re: Windows and python execution

2005-12-27 Thread Daniel Dittmar
Tim Roberts wrote: Mark Carter [EMAIL PROTECTED] wrote: What you need to do is include the following line in autoexec.bat: set .py=c:\python24\python.exe This will achieve the desired result. I'm suprised more people don't use it. They don't use it, because it doesn't do anything. I'd be

Re: Aproximative string matching

2005-11-21 Thread Daniel Dittmar
javuchi wrote: I'm searching for a library which makes aproximative string matching, for example, searching in a dictionary the word motorcycle, but returns similar strings like motorcicle. Is there such a library? agrep (aproximate grep) allows for a certain amount of errors and there

Re: initialising a list of lists

2005-11-16 Thread Daniel Dittmar
Peter Kleiweg wrote: This does not what I want it to do: a = [[]] * 6 a[3].append('X') a [['X'], ['X'], ['X'], ['X'], ['X'], ['X']] This does what I want: b = [[] for _ in range(6)] b[3].append('X') b [[], [], [], ['X'], [], []] The first is

Re: D foreach

2005-11-14 Thread Daniel Dittmar
[EMAIL PROTECTED] wrote: The Digital Mars D compiler is a kind of improved c++, it contains a foreach statement: http://www.digitalmars.com/d/statement.html#foreach Usage example: foreach(int i, inout int p; v1) p = i; Is equal to Python: for i in xrange(len(v)): v[i] = i [...] So the

Re: Why the nonsense number appears?

2005-10-31 Thread Daniel Dittmar
Johnny Lee wrote: print time1, time2 1130748744.461 1130748744.500 float(time2) - float(time1) 0.03934332275391 Why are there so many nonsense tails? thanks for your help. http://en.wikipedia.org/wiki/Floating_point#Problems_with_floating-point, especially 'Rounding'. Or

Re: Absolultely confused...

2005-10-06 Thread Daniel Dittmar
Jeremy Moles wrote: So, here is my relevant code: PyArg_ParseTuple(args, O!, PyType_vector3d, arg1) And here ismy error message: argument 1 must be pylf.core.vector3d, not pylf.core.vector3d It looks as if two PyType_vector3d exist in your system - the one that created the

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

2005-09-20 Thread Daniel Dittmar
Steve M wrote: About your main problem: I'm still convinced that it's the order of -jar and -D that is important, see my other post. I have tried (not entirely systematically but pretty exhaustively) every combination of backslashes in the cmd string, e.g.:

Re: Question about smtplib, and mail servers in general.

2005-09-20 Thread Daniel Dittmar
Chris Dewin wrote: Hi. I've been thinking about using smtplib to run a mailing list from my website. s = smtplib.SMTP(server) s.sendmail(fromaddress, toaddresess, msg) I know that in this instance, the toaddresses variable can be a variable of type list. Suppose the list contains

Re: How to write this iterator?

2005-09-19 Thread Daniel Dittmar
[EMAIL PROTECTED] wrote: Given a list of iterators, I'd like to have a new one that would cyclically walk over the list calling the next() method of the iterators (removing any iterator which is exhausted). It should also support adding a new iterator to the list; it should be added in

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

2005-09-19 Thread Daniel Dittmar
Steve M wrote: 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

Re: packaging python for install.

2005-09-12 Thread Daniel Dittmar
J wrote: I have created an App that embedds the python interpreter and I am now in the process of creating an installer. I am currently linking python24.lib, but it is only 184k and I suspect that it imports other dlls... I am also using numarray. Does anyone have any experiences in packaging

Re: re module help

2005-09-09 Thread Daniel Dittmar
[EMAIL PROTECTED] wrote: if I start replacing regex by re I get stuck at replacement of regex.symcomp() and regex.pattern() Groups identified by names are part of the standard regular expression syntax: regex.symcomp ('\(id[a-z][a-z0-9]*\)') becomes re.compile ('(?Pid[a-z][a-z0-9]*)') I

Re: warning when doubly liked list is defined globally

2005-09-05 Thread Daniel Dittmar
chand wrote: Hi., In my api.py file 'g_opt_list' is defined globally g_opt_list =[[],[],[],[],[],[],[]] when I run the py file, I am getting the Following Error SyntaxWarning: name 'g_opt_list' is used prior to global declaration g_del_opt_list =[[],[],[],[],[],[],[]] #g_opt_list = []

Re: what's the difference between *.dll and *.pyd if both of them are extended python module?

2005-08-23 Thread Daniel Dittmar
wen wrote: 1. what's the difference between them? i saw the code is same as common c++ extended python module, can i use microsoft visual C++ to create a dll project for compiling it as _cmd.dll? .pyd is just a naming convention. It was probably introduced to prevent name clashes with

Re: loop in python

2005-08-22 Thread Daniel Dittmar
km wrote: Why is it that the implementation of empty loop so slow in python when compared to perl ? [...] Is python runtime slow at all aspects when compared to perl ? No I really wonder what makes python slower than perl ? It could be that the Perl compiler recognizes such a for loop

Re: len(sys.argv) in (3,4)

2005-08-11 Thread Daniel Dittmar
Daniel Schüle wrote: if __name__ == __main__: if len(sys.argv) not in (3,4): print usage: prog arg1 argv2 [-x] # etc ... while develeoping I had my interpeter running and reloaded module now since I am ready, I wanted to run it from cmd windows shell but it always prints

Re: how to write thread-safe module ? and pytz

2005-08-10 Thread Daniel Dittmar
nicolas_riesch wrote: Does someone know if the module pytz (http://sourceforge.net/projects/pytz/) is thread-safe ? I have not seen it explicitely stated, and just wanted to be sure, as I want to use it. That's because in the file pytz/tzinfo.py, I see global variables _timedelta_cache,

Re: API class creation

2005-08-04 Thread Daniel Dittmar
kman3048 wrote: Hello, as a relative newcomer to Python API programming I've got a problem: To extend Python: - there is an API C call to create a module - there is also a API C call to create a method - there is an API C call to create a Class instance Now, I need to create a Class

Re: Dabo in 30 seconds?

2005-08-02 Thread Daniel Dittmar
Jorge Godoy wrote: I agree where you say that lack of information is a risk. But I don't see how it -- lack of information -- wouldn't affect both scenarios. At least, Because you put different probabilities on different outcomes. One easy 'risk markup' would be to assume that parts of the

Re: Dabo in 30 seconds?

2005-08-01 Thread Daniel Dittmar
Cliff Wells wrote: But then I'm willing to actually work a little to get what I want. For other it seems they won't be happy unless you drive to their house and install it for them To be fair to those slothes: some of them want to write software for a commercial setting where they have to

Re: Dabo in 30 seconds?

2005-08-01 Thread Daniel Dittmar
Jorge Godoy wrote: Daniel Dittmar wrote: To be fair to those slothes: some of them want to write software for a commercial setting where they have to install it on other peoples machines. So it isn't just getting it to work one one own's machine. Using a specifc Python library with external

Re: Dabo in 30 seconds?

2005-08-01 Thread Daniel Dittmar
Cliff Wells wrote: I can understand this, but from my experience, their concerns are badly misplaced: I recently wrote a fairly sizable Python app (~8K LOC) that utilized several 3rd party python librarys: wxPython, Twisted, FeedParser, DateUtils and SQLite to name a few off the top of my

Re: Dabo in 30 seconds?

2005-08-01 Thread Daniel Dittmar
Jorge Godoy wrote: We can find several problems, almost all of them can be solved with the admin's creativity. You must distinguish between solving technical problems once a course has ben set and choosing such a course in the first place. The latter has to deal also with the risks of the

Re: Ten Essential Development Practices

2005-07-29 Thread Daniel Dittmar
Dark Cowherd wrote: There should be one-- and preferably only one --obvious way to do it. But this not true of Python. GUI, Web development, Application Framework - it is shambles. It is so That's because there is no *obvious* way to do these. -Quote - Phillip J. Eby from dirtsimple.org

Re: Rich Graphics?

2005-07-28 Thread Daniel Dittmar
Chris Spencer wrote: I'm trying to write a Gui in Python for manipulating rich graphical representations, similar to something like Inkscape. I've tried tkinter, wxPython, pyGtk, and while they all do traditional widgets well enough, none of them really handle anti-aliased, transparent,

Re: PEP on path module for standard library

2005-07-25 Thread Daniel Dittmar
John Roth wrote: However, a path as a sequence of characters has even less meaning - I can't think of a use, while I have an application That's true. But the arguments for path objects as strings go more in the direction of using existing functions that expect strings. where traversing a

Re: PEP on path module for standard library

2005-07-25 Thread Daniel Dittmar
Terry Reedy wrote: for dir in pathobject: if isdir(dir): cd(dir) *is*, in essence, what the OS mainly does with paths (after splitting the string representation into pieces). That's why there is rarely a need to to it in Python code. Directory walks also work with paths as sequences

Re: PEP on path module for standard library

2005-07-22 Thread Daniel Dittmar
Duncan Booth wrote: I would have expected a path object to be a sequence of path elements rather than a sequence of characters. Maybe it's nitpicking, but I don't think that a path object should be a 'sequence of path elements' in an iterator context. This means that for element in

Re: Extending python - undefined symbol error on import

2005-07-22 Thread Daniel Dittmar
ch424 wrote: However, when I open up the python command line, and type from gpib import * or import gpib I get ImportError: /usr/.../gpibmodule.so: undefined symbol: ibdev -- but I know it's defined in the ni488.h file, especially as I can use this code from actual C programs without

Re: is a file open ?

2005-07-20 Thread Daniel Dittmar
luis wrote: for root, dirs, files in os.walk(path): for file in files: # ¿ is opened ? On Linux and some other Unixes, you can probably read the /proc filesystem. On Windows, you'll probably get the quickest result by running handle.exe

Re: automatic form filling

2005-07-12 Thread Daniel Dittmar
I would like to know how I could automatically fill a (search) form on a web page and download the resulting html page. http://wwwsearch.sourceforge.net/ClientForm/ Daniel -- http://mail.python.org/mailman/listinfo/python-list

Re: pyo contains absolute paths

2005-07-11 Thread Daniel Dittmar
David Siroky wrote: When I compile my python files with python -OO into pyo files then they still contain absolute paths of the source files which is undesirable for me. How can I deal with that? Use the script compileall.py (in Lib) to compile all the files. This script has an option -d

Re: Use cases for del

2005-07-08 Thread Daniel Dittmar
Scott David Daniels wrote: Testing for None should be an is-test (not just for speed). In older pythons the == result wasn't necessarily same as is-test. This made sense to me after figuring out NULL in database stuff. NULL in SQL databases has nothing to do with Python None. I'm quite sure

Re: Use cases for del

2005-07-06 Thread Daniel Dittmar
Peter Hansen wrote: Arguing the case for del: how would I, in doing automated testing, ensure that I've returned everything to a clean starting point in all cases if I can't delete variables? Sometimes a global is the simplest way to do something... how do I delete a global if not with

Re: Question about Python

2005-07-01 Thread Daniel Dittmar
Jan Danielsson wrote: But then it occured to me.. I started writing my program in Java pre-1.5. Then came 1.5, I upgraded, and my program would still compile and run, though I did get three warnings. The language had changed a little bit; I had to assign a type to three arrays. That wasn't

Re: Modules for inclusion in standard library?

2005-07-01 Thread Daniel Dittmar
Rocco Moretti wrote: Except that (please correct me if I'm wrong) there is somewhat of a policy for not including interface code for third party programs which are not part of the operating system. (I.e. the modules in the standard libary should all be usable for anyone with a default OS +

Re: Python syntax high-lighting and preservation on web

2005-06-29 Thread Daniel Dittmar
Gregory Piñero wrote: Hey guys, Does anyone know where I can pick up a style sheet (css) and/or other files/programs I might need to display python code on my website with tab preservation(or replace with spaces) and colored syntax? I want something similar to the python code on a page

Re: Which kid's beginners programming - Python or Forth?

2005-06-28 Thread Daniel Dittmar
BORT wrote: I told my son, who wants to learn how to compute probabilities, that we have to start with some boring stuff so we can learn how to do the cool stuff. Adding and subtracting aren't really fun, but figuring odds on rolling dice IS fun. Learning to program will be kind of like

Re: Which kid's beginners programming - Python or Forth?

2005-06-28 Thread Daniel Dittmar
[EMAIL PROTECTED] wrote: List comprehensions, however, *are* the basic control flow; loops are much more verbose and they should be used only when necessary. List comprehensions are probably a bad idea for entry level programmers: - for and while loops are much easier to debug as you can insert

Re: PEP ? os.listdir enhancement

2005-06-23 Thread Daniel Dittmar
Riccardo Galli wrote: On Thu, 23 Jun 2005 12:56:08 +0300, Konstantin Veretennicov wrote: What about os.listdir(dir='relative/path', abs=True)? Should listdir call abspath on results? Should we add another keyword rel? Would it complicate listdir unnecessarily? keyword dir not exists (don't

Re: PEP ? os.listdir enhancement

2005-06-23 Thread Daniel Dittmar
Riccardo Galli wrote: On Thu, 23 Jun 2005 11:34:02 +0200, Andreas Kostyrka wrote: What's wrong with (os.path.join(d, x) for x in os.listdir(d)) It's short, and easier to understand then some obscure option ;) Andreas how does it help in using list comprehension, as the ones in the

Re: *Python* Power Tools

2005-06-22 Thread Daniel Dittmar
Micah wrote: Anyone know if there is any organized effort underway to implement the Python equivalent of Perl Power Tools http://ppt.perl.org/? If not, would starting this be a waste of effort since: - it's already being done in Perl? - cygwin thrives? - UNIX is already pervasive :-) ?

Re: Multiple instances of a python program

2005-06-17 Thread Daniel Dittmar
Rahul wrote: Hi. I am part of a group in my univ where we organize a programming contest. In this contest we have a UDP based server. The server simulates a game and each contestant is to develop a team of virtual players. Each team is composed of 75 similar bots...i.e. governed by the same

Re: MySQLDBAPI

2005-06-14 Thread Daniel Dittmar
Gregory Piñero wrote: building '_mysql' extension gcc -pthread -shared build/temp.linux-i686-2.4/_mysql.o -lz -lmysqlclient_r -o build/lib.linux-i686-2.4/_mysql.so /usr/bin/ld: cannot find -lmysqlclient_r collect2: ld returned 1 exit status error: command 'gcc' failed with exit status 1 Now

Re: Which Python Wiki engine?

2005-06-14 Thread Daniel Dittmar
Kenneth McDonald wrote: I'm looking for a Wiki engine to set up for my company, so that we can incrementally add user documentation for a fairly complex program, plus allow users to add their own comments for the benefit of others. I'd strongly prefer a Python-based Wiki, since that

Re: lists in cx_Oracle

2005-05-10 Thread Daniel Dittmar
Andrew Dalke wrote: It sounds like you're saying that the interface is actually implemented by passing the execute string and a database-specific dictionary-like object; the latter created by the DB-API interface. That's the way it's supposed to work. The program prepares a statement with

Re: lists in cx_Oracle

2005-05-03 Thread Daniel Dittmar
Andrew Dalke wrote: I want to execute a query with an IN in the WHERE clause and with the parameter taken from a Python variable. That is, I wanted something like this to work id_list = [AB001, AB002, AB003] c.execute(SELECT s.smiles FROM smiles_database s WHERE s.id IN

Re: Getting into Python, comming from Perl.

2005-04-25 Thread Daniel Dittmar
Miguel Manso wrote: I've tryed to use python some times but I get frustrated very quick. I get myself many times needing to figure out how to loop through a list, declare an associative array, checking how to pass named parameters to functions, and simple things like that. Create a cheat sheet

Re: Case-insensitive dict, non-destructive, fast, anyone?

2005-04-01 Thread Daniel Dittmar
Ville Vainio wrote: I need a dict (well, it would be optimal anyway) class that stores the keys as strings without coercing the case to upper or lower, but still provides fast lookup (i.e. uses hash table). Store the original key together with the value and use a lowercase key for lookup. only a

Re: Case-insensitive dict, non-destructive, fast, anyone?

2005-04-01 Thread Daniel Dittmar
Ville Vainio wrote: Daniel == Daniel Dittmar [EMAIL PROTECTED] writes: Daniel Ville Vainio wrote: I need a dict (well, it would be optimal anyway) class that stores the keys as strings without coercing the case to upper or lower, but still provides fast lookup (i.e. uses hash

Re: Optimisation Hints (dict processing and strings)

2005-03-30 Thread Daniel Dittmar
OPQ wrote: - Try if it isn't faster to iterate using items instead of iterating over keys items are huge lists of numbers. keys are simple small strings. And even if it is faster, how can I find the key back, in order to delete it ? for v in hashh.items(): if len(v)2: del ???

Re: Optimisation Hints (dict processing and strings)

2005-03-29 Thread Daniel Dittmar
OPQ wrote: for (1): longone=longone + char # where len(char)== 1 I known that string concatenation is time consuming, but a small test on timeit seems to show that packing and creating an array for those 2 elements is equally time consuming - use cStringIO instead - or append all chars to a list

Re: The Running Time of += on Char Strings ?

2005-03-24 Thread Daniel Dittmar
Edg Bamyasi wrote: What is the running time of conactination on character strings. i.e. joe=123 joe+=9 is it Amortized Constant time? I don't think it would be O((number of chars)^2) but i really don't know. Strings are immutable, so joe+=9 is executed as joe =

Re: inter threading info

2005-03-23 Thread Daniel Dittmar
Tertius Cronje wrote: Q: Is it possible for a thread on SocketServer.ThreadingTCPServer to get the socket info of *other* open thread/s and use that info to send data to the accepting client? A specific socket can be used from every thread of a process. Just make sure that you synchronize

Re: Why tuple with one item is no tuple

2005-03-18 Thread Daniel Dittmar
Antoon Pardon wrote: My peeve is about having operators added to standard types. This increases the chances that using an object the wrong way leads to a bogus result, not a runtime error. A more common programming error I commit is passing a string where a list ist expected. And then I wonder

  1   2   >