Re: How do I do this? (eval() on the left hand side)

2004-12-09 Thread Peter Otten
Caleb Hattingh wrote: I am convinced now that locals() doesn't work as (I) expected. Steven says there was some or other reason why locals() as used in this context is not writable - Do you know why this is? I really do not like guidelines like may not work, is unreliable and so on.

newbie question: starting external application(win)?

2004-12-09 Thread Frank Esselbach
Hello, I'am new in python. I need informations, how its possible run another (non-python) exe file from python without terminate the python system. I have googeled, but could not find informations that I can understand. The most informations comes from unix/linux butIneed this for win32. Thanks

Re: How do I do this? (eval() on the left hand side)

2004-12-09 Thread Nick Coghlan
Peter Hansen wrote: Nick Coghlan wrote: Generally, altering the contents of the dicts returned by locals() and globals() is unreliable at best. Nick, could you please comment on why you say this about globals()? I've never heard of any possibility of unreliability in updating globals() and, as

Re: ElementTree and XPATH

2004-12-09 Thread Fredrik Lundh
[EMAIL PROTECTED] wrote: I'm using ElementTree from effbot (http://effbot.org/zone/element.htm) and I'm having some problems finding nodes that have the same name. I know in XPATH, we can use an index to identify which node we need, but it seems to be invalid syntax if I give /a/b[0] to the

Re: new comp.lang.python mirror at lampfroums.org--any Linux, Apache, MYSQL, Python Apps?

2004-12-09 Thread Fredrik Lundh
Terry Reedy wrote: Whereas this is my second or third exposure, with the first that made an impression coming earlier this year. A list of those books might help some people, and would establish that LAMP is an established concept. the LAMP concept has been pushed by O'Reilly and

Re: a newbie question

2004-12-09 Thread Nick Coghlan
Peter Hansen wrote: If that's not what you wanted, try specifying what you mean by preinstalled python libraries. I can think of at least two things that this phrase might refer to... For the where's the standard library interpretation, the following works on any platform: python -c import

Re: deferred decorator

2004-12-09 Thread Nick Coghlan
Bryan wrote: Nick Coghlan wrote: Bryan wrote: i'm also curious if it's possible to write this recipe using the new class style for the Deffered class.it appears you can nolonger delegate all attributes including special methods to the contained object by using the __getattr__ or the new

Re: Parse XML using Python

2004-12-09 Thread Thomas Guettler
Am Wed, 08 Dec 2004 23:25:49 -0800 schrieb anilby: Hi, I wanted to write a script that will read the below file: Hi, Here is an example how to use sax: http://pyxml.sourceforge.net/topics/howto/node12.html Thomas -- Thomas Güttler, http://www.thomas-guettler.de/ --

Re: wxPython bug

2004-12-09 Thread Dennis Benzinger
Jive wrote: [...] What to do? Ask in comp.soft-sys.wxwindows -- http://mail.python.org/mailman/listinfo/python-list

Psycopg 1.1.17 compiled binaries for windows, postgre 8.0.0-beta4 and python 2.3

2004-12-09 Thread Eino Mäkitalo
I had Visual C++ 6.0, so I compiled those libpq.dll and psycopg.pyd. if there are anyone to play with Windows, Python 2.3 and Postgre-8.0.0-beta4 for windows like me. You cat get those from: http://eino.net/html/python.html Original psycopg source code is available in:

Re: os.path.islink()

2004-12-09 Thread Peter Maas
JanC schrieb: There are no ntfs links. You're wrong, NTFS supports symlinks for directories and hard links for files: http://www.sysinternals.com/ntw2k/source/misc.shtml#junction http://shell-shocked.org/article.php?id=284 Thanks for the update and my apologies to Egor. I was using Win2k for

Re: Ideas for projects

2004-12-09 Thread Fuzzyman
Phillip Bowden wrote: I feel that I've learned the language pretty well, but I'm having trouble thinking of a medium to large project to start. What are some projects that you have written in the past with Python? I'm the maintainer of several python projects. Most of them have their current

Re: ANNOUNCE: Ice 2.0 released

2004-12-09 Thread Duncan Grisby
In article [EMAIL PROTECTED], Michi Henning [EMAIL PROTECTED] wrote: [...] Instead of compiling the definition, you can write: Ice.loadSlice(Color.ice) import M print My favourite color is , M.Color.blue Just like this then? omniORB.importIDL(Color.idl) import M

Re: Upgrading Python Article

2004-12-09 Thread Fuzzyman
Sure - I don't really *blame* windoze for the problem. It's just more of a pain upgrading python version on windows. As I said it's given me an opportunity to work out which extension modules I'm really using ! In actual fact I admire windows, there's an awful lot that goes on beneath the hood.

Re: Sorting in huge files

2004-12-09 Thread Paul
The reason I am not telling you much about the data is not because I am afraid anyone would steal my ideas, or because I have a non-disclosure agreement or that I don't want to end up pumping gas. It is just that it is pretty freaking damn hard to even explain what is going on. Probably a bit

Re: Python Docs. Hardcopy 2.4 Library Reference, interested?

2004-12-09 Thread Richie Hindle
[Brad] Is anyone interested in purchasing a hardcopy version of the Python 2.4 Library reference? Have you seen http://www.network-theory.co.uk/python/ ? (I don't know anything about it beyond what's on that page.) For what it's worth, I wouldn't want a hardcopy manual - I find the

Re: Sorting in huge files

2004-12-09 Thread Paul Rubin
Paul [EMAIL PROTECTED] writes: If you really want to know, my entries are elliptic curves and my hashing function is an attempt at mapping them to their Serre resdual representation modulo a given prime p. Now, for you to tell me something relevant about the data that I don't already know

Re: Python 2.3.5 ?

2004-12-09 Thread Fuzzyman
Fuzzy Regards, What's that phrase that includes 'hobgoblin of little minds' ? -- http://mail.python.org/mailman/listinfo/python-list

Re: How do I do this? (eval() on the left hand side)

2004-12-09 Thread caleb . hattingh
Both Peters :) Sure, I must concede that the problem here was my expectation of how things should work. Thanks for the explanations. I still don't really know whether this behaviour of locals() is the result of a design decision, or an implementation artifact of CPython, but at least I have a

Re: dictionary initialization

2004-12-09 Thread caleb . hattingh
Hi Dan I must confess that upon rereading my words, there is some irony there (but not really sarcasm, is there?). However, I *really* tried to keep my tone, well, professional. I realise I didn't do a good job and apologise. I hope that's ok. Keep well Caleb --

Re: Pictograms and Python

2004-12-09 Thread caleb . hattingh
Diez Ya got me there! I have a sript that downloads a webpage. According to the picture on this webpage I need to pass a parameter to this , running script a few lines later. Err, ya, I guess I would be suspicious too.Sorry about that! Keep well Caleb --

Wrapper objects

2004-12-09 Thread Egil M?ller
Is there any way to create transparent wrapper objects in Python? I thought implementing __getattribute__ on either the wrapper class or its metaclass would do the trick, but it does not work for the built in operators: class Foo(object): class __metaclass__(type): def

Re: installing wxPython on Linux and Windows

2004-12-09 Thread Ed Leafe
On Dec 2, 2004, at 4:19 AM, Peter Maas wrote: Recently I replaced Win2k with Linux on my desktop computer. Using mostly multi-platform software I thought this would be easy. It was not as easy as expected getting wxPython to work. There seemed to be no SuSE RPM so I installed from source. Here

Re: Questions about file object and close()

2004-12-09 Thread John Marshall
On Thu, 2004-12-09 at 08:41 -0500, Peter Hansen wrote: John Marshall wrote: Hi, Does anyone see a problem with doing: data = file(tata).read() Each time this is done, I see a new file descriptor allocated (Linux) but not released. 1) Will there ever be a point where I

MDaemon Warning - virus found: Returned mail: see transcript for details

2004-12-09 Thread MAILER-DAEMON
*** WARNING ** Este mensaje ha sido analizado por MDaemon AntiVirus y ha encontrado un fichero anexo(s) infectado(s). Por favor revise el reporte de abajo. AttachmentVirus name Action taken

results of division

2004-12-09 Thread Brad Tilley
Hello, What is the proper way to limit the results of division to only a few spaces after the decimal? I don't need rocket-science like precision. Here's an example: 1.775 is as exact as I need to be and normally, 1.70 will do. Thank you, Brad --

Re: High level SNMP

2004-12-09 Thread Jeremy Sanders
On Thu, 09 Dec 2004 15:34:14 +0200, Petri Laakso wrote: have you tested twistedsnmp? http://twistedsnmp.sourceforge.net/ I looked at it, but it needs Twisted compiled and installed, which is a pain. The old versions of PySNMP (version 2.XX), seem to be a lot simpler to use than later ones, so

Re: new comp.lang.python mirror at lampfroums.org--any Linux, Apache, MYSQL, Python Apps?

2004-12-09 Thread astro
Thanks for the feedback. I linked to Oreilly's onlamp.com article at: http://lampforums.org/forumdisplay.php?f=36 What is LAMP? LAMP is an acronym for Linux, Apache, MYSQL/Postgres, and PHP/Perl/Python/Ruby. These open-source efforts offer ever-increasing power and versatility. In 2001,

samba/windows shares

2004-12-09 Thread I.V. Aprameya Rao
hi does anybody know how to access samba/windows shares on a network? is there any module that does this? i am running linux and i thought of using the mount command to mount that remote share and then access it, but i was wondering whether that is the right way? Aprameya --

Re: PIL for Windows for Python 2.4

2004-12-09 Thread Fuzzyman
If you're determined enough there are instructions here : http://www.vrplumber.com/programming/mstoolkit/ These will get you the Visual Studio 7 tools (free releases of) and tell you how to configure distutils to use it. Hefty downloads though, do not attempt this without broadband ! Regards,

Re: Help beautify ugly heuristic code

2004-12-09 Thread Jeremy Sanders
On Wed, 08 Dec 2004 18:38:14 -0500, Stuart D. Gathman wrote: Here are the last 20 (which my subjective judgement says are correct): 65.112.76.15usfshlxmx01.myreg.net 201.128.108.41 [snip] 80.143.79.97p508F4F61.dip0.t-ipconnect.de DYN Looks like you could do something like look for

Re: Questions about file object and close()

2004-12-09 Thread Peter Hansen
John Marshall wrote: It seems to me that a file.__del__() _should_ call a file.close() to make sure that the file is closed as a clean up procedure before releasing the object. I believe it does, but I tried your experiment with subclassing file and didn't ever see a call to close, so I can only

Re: results of division

2004-12-09 Thread Peter Hansen
Brad Tilley wrote: What is the proper way to limit the results of division to only a few spaces after the decimal? I don't need rocket-science like precision. Here's an example: 1.775 is as exact as I need to be and normally, 1.70 will do. The answer is what are you trying to do?. The others

Re: results of division

2004-12-09 Thread Peter Hansen
Brad Tilley wrote: Peter Hansen wrote: The answer is what are you trying to do?. The others have given options and good advice, but the right approach depends on what exactly you are doing. Is this just for display purposes, or is there more significant (though perhaps not precision-critical)

Re: Parse XML using Python

2004-12-09 Thread Jeremy Bowers
On Thu, 09 Dec 2004 06:00:27 -0800, Anil wrote: Thomas Guettler wrote: Hi, Here is an example how to use sax: http://pyxml.sourceforge.net/topics/howto/node12.html Thomas -- Thomas Gttler, http://www.thomas-guettler.de/ Could you please tell me how to achieve the below. I am

Re: Loading a file only once into an object and being able to access it from other modules - still have a problem

2004-12-09 Thread Philippe C. Martin
Hi, After all of you answers, I though I had it straight, yet . This is what I am doing: class SC_ISO_7816: __m_loaded = None .. def __init__(self): if SC_ISO_7816.__m_loaded == None: SC_ISO_7816.__m_loaded = True print 'LOADING'

mapping function to vars

2004-12-09 Thread jahurt
I need to map a function to several variables. I'm trying to use map and lambda to do this. Here's my attempt... #!/usr/bin/env python from random import * [fee, fye, foe, fum] = map(lambda n: random(), range(4)) print fee print fye print foe print fum ...I'm essentially trying to map a

Re: Upgrading Python Article

2004-12-09 Thread JanC
Fuzzyman schreef: On the other hand the microsoft compiler is *better* than gcc anyway :-) It's better at optimising, but it doesn't support standard C C++. ;-) -- JanC Be strict when sending and tolerant when receiving. RFC 1958 - Architectural Principles of the Internet - section 3.9 --

Re: How do I do this? (eval() on the left hand side)

2004-12-09 Thread Bengt Richter
On Tue, 07 Dec 2004 21:12:24 GMT, It's me [EMAIL PROTECTED] wrote: Caleb Hattingh [EMAIL PROTECTED] wrote in message news:[EMAIL PROTECTED] Hi It's me a = 3 y = a print eval(y) To get 'a' to be 4 here, you would say a = 4 Obviously but that's not what I wish to do.

Re: mapping function to vars

2004-12-09 Thread Brian Quinlan
[EMAIL PROTECTED] wrote: I need to map a function to several variables. I'm trying to use map and lambda to do this. Here's my attempt... #!/usr/bin/env python from random import * [fee, fye, foe, fum] = map(lambda n: random(), range(4)) from random import random fee = random() fye = random()

Re: Loading a file only once into an object and being able to access it from other modules - still have a problem

2004-12-09 Thread Peter Hansen
Philippe C. Martin wrote: class SC_ISO_7816: __m_loaded = None Please don't use tabs in code you post here. Many newsreaders have trouble displaying them, and make the code look like it does above (i.e. no indentation at all) which makes it hard to understand. .. def __init__(self):

Re: How do I do this? (eval() on the left hand side)

2004-12-09 Thread Jeff Shannon
Nick Coghlan wrote: Peter Hansen wrote: Nick, could you please comment on why you say this about globals()? I've never heard of any possibility of unreliability in updating globals() and, as far as I know, a large body of code exists which does in fact rely on this -- much of mine included. ;-)

Re: Parse XML using Python

2004-12-09 Thread Fredrik Lundh
[EMAIL PROTECTED] wrote: abcd label=ABC /abcd . . xyz label=A1 /xyz .. and so on an XML document can only have a single root element, but your example has at least two top-level elements (abcd and xyz). here is some elementtree code that handles this by wrapping your data in a root

Re: results of division

2004-12-09 Thread Christopher A. Craig
Paul McGuire [EMAIL PROTECTED] writes: Errr? How come round() is able to understand 1.775 correctly, whereas string interp is not? I'm guessing that round() adds some small epsilon to the value to be rounded, or perhaps even does the brute force rounding I learned in FORTRAN back in the

Calling a C program from a Python Script

2004-12-09 Thread Brad Tilley
Is it possible to write a file open, then read program in C and then call the C program from a Python script like this: for root, files, dirs in os.walk(path) for f in files: try: EXECUTE_C_PROGRAM If possible, how much faster would this be over a pure Python solution?

Re: Loading a file only once into an object and being able to access it from other modules - still have a problem

2004-12-09 Thread Philippe C. Martin
Well, from the looks of things, you don't seem to understand the basic idea of instances and instance attributes.  There is a key difference between SC_ISO_67816.__m_loaded and self.SW1_DICT, and that is that the former one is seen by *all instances*, while the latter is an attribute in *only a

Users

2004-12-09 Thread python1
Do you know of a way to list the users on a Win2K machine? I can't seem to find a module for this. Thanks. -- http://mail.python.org/mailman/listinfo/python-list

Re: ElementTree and XPATH

2004-12-09 Thread Istvan Albert
[EMAIL PROTECTED] wrote: it seems to be invalid syntax if I give /a/b[0] to the findall() method. Does anyone know the correct syntax? I think the proper mindset going in should be that elementtree does not support xpath but that there are some handy constructs that resemble the location steps of

Re: Calling a C program from a Python Script

2004-12-09 Thread Grant Edwards
On 2004-12-09, Brad Tilley [EMAIL PROTECTED] wrote: Is it possible to write a file open, then read program in C and then call the C program from a Python script like this: Huh? What do you mean write a file open? You want to read a C source file and execute the C source? If you have access

RE: Users

2004-12-09 Thread Tim Golden
[python1] | Do you know of a way to list the users on a Win2K machine? I | can't seem to find a module for this. Interpretation 1: who is in the user database of a given machine? Investigate the win32net module. Something like this: code import win32net import win32netcon MACHINE_NAME =

Re: Calling a C program from a Python Script

2004-12-09 Thread Istvan Albert
Brad Tilley wrote: If possible, how much faster would this be over a pure Python solution? It is like the difference between Batman and Ever. batman is faster than ever -- http://mail.python.org/mailman/listinfo/python-list

Re: Calling a C program from a Python Script

2004-12-09 Thread Brad Tilley
Grant Edwards wrote: Huh? What do you mean write a file open? You want to read a C source file and execute the C source? If you have access to a C interpreter, I guess you could invoke the interpreter from python using popen, and feed the C source to it. Alternatively you could invoke a

Re: Calling a C program from a Python Script

2004-12-09 Thread It's me
I would expect C to run circles around the same operation under Python. As a general rule of thumb, you should use C for time cirtical operations (computer time, that is), and use Python for human time critical situations (you can get a program developed much faster). I just discovered a

Re: Calling a C program from a Python Script

2004-12-09 Thread Fredrik Lundh
Brad Tilley wrote: for root, files, dirs in os.walk(path) for f in files: try: EXECUTE_C_PROGRAM http://docs.python.org/lib/module-subprocess.html this module in new in 2.4; for older version, os.system() or the os.popen() family might be what you're looking for.

Re: Calling a C program from a Python Script

2004-12-09 Thread Brad Tilley
Steven Bethard wrote: for root, files, dirs in os.walk(path) for f in files: try: x = file(f, 'rb') data = x.read() x.close() Remember that CPython is implemented in C, and so all the builtin types (including file) basically execute C code

Re: How do I do this? (eval() on the left hand side)

2004-12-09 Thread Peter Hansen
Jeff Shannon wrote: Of course, just because modifications of the dict returned by globals() *do* reliably result in modifications to the global namespace, doesn't mean it's a good idea. ;) The global namespace misses the possibility that doing this in a global namespace might be a good idea.

[Newby] Problem with compilation.

2004-12-09 Thread rootshell
Hi folks! Can't compile my file due to some problems with crypt module. My platform is WinXP: First I launch my Python Shell, Than I open the *.py file, Next I press F5 to 'run module' The message is:ImportError: No module named crypt Few lines of code for example: ... import posix import

Re: Users

2004-12-09 Thread python1
Tim Golden wrote: [python1] | Do you know of a way to list the users on a Win2K machine? I | can't seem to find a module for this. Interpretation 1: who is in the user database of a given machine? Sorry for the ambiguity. Yes #1 is correct. I'll try the code you've listed... Thanks.

Re: Users

2004-12-09 Thread Peter Hansen
python1 wrote: Do you know of a way to list the users on a Win2K machine? I can't seem to find a module for this. As a starting point, I played a moment and found this: import win32net dir(win32net) ['NetFileClose', 'NetFileEnum', 'NetFileGetInfo', ... 'NetUserEnum', 'NetUserGetGroups',

Re: Calling a C program from a Python Script

2004-12-09 Thread Grant Edwards
On 2004-12-09, Brad Tilley [EMAIL PROTECTED] wrote: You're going to have to explain clearly what you mean by EXECUTE_C_PROGRAM. If you want to, you can certainly run a binary executable that was generated from C source, (e.g. an ELF file under Linux or whatever a .exe file is under

Re: Calling a C program from a Python Script

2004-12-09 Thread Brad Tilley
Grant Edwards wrote: On 2004-12-09, Brad Tilley [EMAIL PROTECTED] wrote: Steven Bethard wrote: for root, files, dirs in os.walk(path) for f in files: try: x = file(f, 'rb') data = x.read() x.close() Remember that CPython is implemented in C, and so

Re: results of division

2004-12-09 Thread Donn Cave
In article [EMAIL PROTECTED], Brad Tilley [EMAIL PROTECTED] wrote: Brad Tilley wrote: What is the proper way to limit the results of division to only a few spaces after the decimal? I don't need rocket-science like precision. Here's an example: 1.775 is as exact as I need to be

Re: [Newby] Problem with compilation.

2004-12-09 Thread Fredrik Lundh
[EMAIL PROTECTED] wrote: Can't compile my file due to some problems with crypt module. My platform is WinXP: http://docs.python.org/lib/module-crypt.html Section 8: Unix Specific Services 8.4 crypt -- Function to check Unix passwords Availability: Unix. here's a portable crypt

Re: Ideas for projects

2004-12-09 Thread Caleb Hattingh
Here is something I would try but don't have the guts for: If you could write an extension to idle (yes, idle, not Boa, not Eric, etc) that pops up a small list of possible completions in a listbox when you type a '.' (period) after any object name or module name (including builtins), that

Re: [Newby] Problem with compilation.

2004-12-09 Thread rootshell
Can't compile my file due to some problems with crypt module. My platform is WinXP: http://docs.python.org/lib/module-crypt.html Section 8: Unix Specific Services 8.4 crypt -- Function to check Unix passwords Availability: Unix. here's a portable crypt implementation:

Re: updating locals() and globals() (WAS: How do I do this? (eval() on the left hand side))

2004-12-09 Thread Bengt Richter
On Wed, 8 Dec 2004 20:22:52 -0500, Terry Reedy [EMAIL PROTECTED] wrote: To respond to and summarize several posts in this discussion: Within a function, where the local namespace is distinct from the global (module) namespace, CPython usually implements the local namespace internally as a

Re: How do I do this? (eval() on the left hand side)

2004-12-09 Thread Jeff Shannon
Peter Hansen wrote: The main way I use this is in some sort of a const module, which provides access to a large set of constant information. In other words, in contrast to what you had in mind when you wrote the above, I'm dealing with neither variables nor information that _would_ best be put in

Re: creating generators from function

2004-12-09 Thread Mike Meyer
Isaac To [EMAIL PROTECTED] writes: Mike == Mike Meyer [EMAIL PROTECTED] writes: Mike I think it's a bit abnormal, because you have to scan the Mike loop body for breaks. I tend to write: Mike condition = True Mike while condition: # corrected Mike #code which

Re: [Newby] Problem with compilation.

2004-12-09 Thread j vickroy
The Python modules documentation indicates crypt is only available on Unix platforms. [EMAIL PROTECTED] wrote in message news:[EMAIL PROTECTED] Hi folks! Can't compile my file due to some problems with crypt module. My platform is WinXP: First I launch my Python Shell, Than I open the *.py

Re: Ideas for projects

2004-12-09 Thread Jeff Shannon
Caleb Hattingh wrote: Here is something I would try but don't have the guts for: If you could write an extension to idle (yes, idle, not Boa, not Eric, etc) that pops up a small list of possible completions in a listbox when you type a '.' (period) after any object name or module name

Re: Calling a C program from a Python Script

2004-12-09 Thread Jeff Shannon
Brad Tilley wrote: I just want to know the basics of using C and Python together when the need arises, that's all, I don't want to write a book about what exactly it is that I'm involved in. Well, there's several different ways of using C and Python together, so the only meaningful answer we

Re: Directory structure inside a ZipFile object

2004-12-09 Thread Bulba!
On Thu, 09 Dec 2004 07:42:57 -0800, Scott David Daniels [EMAIL PROTECTED] wrote: Look into the two-argument form of the write command: Well, I should have guessed that, it works. Thanks! import zipfile archive = zipfile.ZipFile('box.zip', 'w', zipfile.ZIP_DEFLATED)

Possible to insert variables into regular expressions?

2004-12-09 Thread Chris Lasher
Hello, I would like to create a set of very similar regular expression. In my initial thought, I'd hoped to create a regular expression with a variable inside of it that I could simply pass a string into by defining this variable elsewhere in my module/function/class where I compile the regular

Re: Loading a file only once into an object and being able to access it from other modules - still have a problem

2004-12-09 Thread Jeff Shannon
Philippe C. Martin wrote: Hi, After all of you answers, I though I had it straight, yet . This is what I am doing: class SC_ISO_7816: __m_loaded = None .. def __init__(self): if SC_ISO_7816.__m_loaded == None: SC_ISO_7816.__m_loaded = True print 'LOADING'

Re: results of division

2004-12-09 Thread Dan Bishop
Brad Tilley wrote: Hello, What is the proper way to limit the results of division to only a few spaces after the decimal? I don't need rocket-science like precision. Here's an example: If your only complaint is that it's ugly to display 17 digits, then use the % operator to display however

Re: Rationale behind the deprecation of __getslice__?

2004-12-09 Thread Fernando Perez
Fernando Perez wrote: Hi all, I was wondering if someone can help me understand why __getslice__ has been deprecated, yet it remains necessary to implement it for simple slices (i:j), while __getitem__ gets called for extended slices (i:j:k). [...] def __getitem__(self,key):

Re: Possible to insert variables into regular expressions?

2004-12-09 Thread Steven Bethard
Chris Lasher wrote: I would like to create a set of very similar regular expression. In my initial thought, I'd hoped to create a regular expression with a variable inside of it that I could simply pass a string into by defining this variable elsewhere in my module/function/class where I compile

Re: Rationale behind the deprecation of __getslice__?

2004-12-09 Thread Steven Bethard
Fernando Perez wrote: I was wondering if someone can help me understand why __getslice__ has been deprecated, yet it remains necessary to implement it for simple slices (i:j), while __getitem__ gets called for extended slices (i:j:k). I don't think this is true -- everything goes to __getitem__:

Re: Questions about file object and close()

2004-12-09 Thread John Marshall
On Thu, 2004-12-09 at 10:33 -0500, Peter Hansen wrote: John Marshall wrote: It seems to me that a file.__del__() _should_ call a file.close() to make sure that the file is closed as a clean up procedure before releasing the object. I believe it does, but I tried your experiment with

Re: Rationale behind the deprecation of __getslice__?

2004-12-09 Thread Steven Bethard
Fernando Perez wrote: classes which implement slicing must now do runtime type-checking inside __getitem__. Just in case you thought that they wouldn't have to do runtime type-checking otherwise: class C(object): ... def __getitem__(self, x): ... print type(x), x ... c = C() c[1]

Re: Possible to insert variables into regular expressions?

2004-12-09 Thread Chris Lasher
Thanks for the reply, Steve! That ought to work quite nicely! For some reason, I hadn't thought of using %-formatting. I probably should have, but I'm still learning Python and re-learning programming in general. This helps a lot, so thanks again. Chris --

Re: Calling a C program from a Python Script

2004-12-09 Thread Matt Gerrans
Brad Tilley [EMAIL PROTECTED] wrote: I'm dealing with a terabyte of files. Perhaps I should have mentioned that. I wouldn't automatically assume that recursing the directories with a Python script that calls a C program for each file is faster than doing the processing in Python. For

Re: How do I do this? (eval() on the left hand side)

2004-12-09 Thread Carl Banks
Peter Hansen wrote: In general I would say that mucking with globals() like this is probably best restricted to constants like in this case, if at all. Modifying globals() not even necessary for this. When I want to dynamically update the global namespace, I do it this way: mod =

Re: Calling a C program from a Python Script

2004-12-09 Thread Armin Steinhoff
Brad Tilley wrote: Is it possible to write a file open, then read program in C and then call the C program from a Python script like this: for root, files, dirs in os.walk(path) for f in files: try: EXECUTE_C_PROGRAM If possible, how much faster would this be over a pure

Re: Rationale behind the deprecation of __getslice__?

2004-12-09 Thread Fernando Perez
Steven Bethard wrote: Fernando Perez wrote: I was wondering if someone can help me understand why __getslice__ has been deprecated, yet it remains necessary to implement it for simple slices (i:j), while __getitem__ gets called for extended slices (i:j:k). I don't think this is true --

Re: Rationale behind the deprecation of __getslice__?

2004-12-09 Thread Fernando Perez
Steven Bethard wrote: Fernando Perez wrote: classes which implement slicing must now do runtime type-checking inside __getitem__. Just in case you thought that they wouldn't have to do runtime type-checking otherwise: class C(object): ... def __getitem__(self, x): ...

Re: Rationale behind the deprecation of __getslice__?

2004-12-09 Thread Carl Banks
Fernando Perez wrote: I was wondering if someone can help me understand why __getslice__ has been deprecated, yet it remains necessary to implement it for simple slices (i:j), while __getitem__ gets called for extended slices (i:j:k). The problem with this approach, besides a bit of code

Re: How can I change the timestamps of directories? (os.utime(), WinXP)

2004-12-09 Thread Matt Gerrans
Are you able change this directories attributes in a command shell or with explorer?If so, have you tried win32file.SetFileAttributes()? -- http://mail.python.org/mailman/listinfo/python-list

Re: Rationale behind the deprecation of __getslice__?

2004-12-09 Thread Steven Bethard
Fernando Perez wrote: Steven Bethard wrote: Fernando Perez wrote: I was wondering if someone can help me understand why __getslice__ has been deprecated, yet it remains necessary to implement it for simple slices (i:j), while __getitem__ gets called for extended slices (i:j:k). I don't think this

How to set condition breakpoints?

2004-12-09 Thread Christopher J. Bottaro
I have a script with a class in it: class Class: def f(x, y): # do something I start up the debugger like this: python /usr/lib/python2.3/pdb.py myscript.py I want to set a conditional breakpoint: b Class.f, x == 1 and y == 2 ...but that doesn't work. How can I do what

Re: [Newby] Problem with compilation.

2004-12-09 Thread Mike C. Fletcher
There is a work-alike cross-platform fcrypt.py module which can be used to replace crypt on non-unix platforms. Google to find it. HTH, Mike j vickroy wrote: The Python modules documentation indicates crypt is only available on Unix platforms. original problem with lib requiring crypt

Re: ANNOUNCE: Ice 2.0 released

2004-12-09 Thread Michi Henning
On Thu, 9 Dec 2004, Duncan Grisby wrote: In article [EMAIL PROTECTED], Michi Henning [EMAIL PROTECTED] wrote: [...] Instead of compiling the definition, you can write: Ice.loadSlice(Color.ice) import M print My favourite color is , M.Color.blue Just like this then?

Re: Python 2.4 Tix failing on Windows XP

2004-12-09 Thread Michael Auerswald
j vickroy wrote: Could someone tell me what I am doing incorrectly? All I can tell you is that I have the exact same problem (which I did not have with 2.3). Not much of a help, I know... -- http://mail.python.org/mailman/listinfo/python-list

Re: Rationale behind the deprecation of __getslice__?

2004-12-09 Thread Carl Banks
Steven Bethard wrote: Unfortunately, I don't think __getslice__ can be removed from list (and str and tuple) because of backwards compatibility constraints... Wouldn't it work to have __getslice__ call __getitem__? And, since that would be too much of a performance hit, have it check whether

Re: exec'ing functions

2004-12-09 Thread Mel Wilson
In article [EMAIL PROTECTED], Steven Bethard [EMAIL PROTECTED] wrote: Jeff Shannon wrote: I was referring to functions which have an internal exec statement, not functions which are created entirely within an exec -- i.e., something like this: Thanks for the clarification. Here's the results

Re: [Newby] Problem with compilation.

2004-12-09 Thread Fredrik Lundh
Mike C. Fletcher wrote: There is a work-alike cross-platform fcrypt.py module which can be used to replace crypt on non-unix platforms. Google to find it. (or read earlier posts to this thread) /F -- http://mail.python.org/mailman/listinfo/python-list

Re: Sorting in huge files

2004-12-09 Thread François Pinard
[Paul] Thanks! I definitely didn't want to go into any elaborate programming for this, and the Unix sort is perfect for this. It sorted a tenth of my data in about 8 min, which is entirely satisfactory to me (assuming it will take ~ 20 times more to do the whole thing). Your answer greatly

Re: Rationale behind the deprecation of __getslice__?

2004-12-09 Thread Steven Bethard
Carl Banks wrote: As for why list objects still use getslice--they probably shouldn't. I'd file a bug report. I'm not convinced this is actually a bug; it works just like the docs promise:

Re: Rationale behind the deprecation of __getslice__?

2004-12-09 Thread Steven Bethard
Carl Banks wrote: Steven Bethard wrote: Unfortunately, I don't think __getslice__ can be removed from list (and str and tuple) because of backwards compatibility constraints... Wouldn't it work to have __getslice__ call __getitem__? And, since that would be too much of a performance hit, have it

Re: Rationale behind the deprecation of __getslice__?

2004-12-09 Thread Steven Bethard
Fernando Perez wrote: I guess that conceptually it just felt natural to me to keep separate methods for dealing with a slice (get many elements out) and other types of indexing, which I tend to think of as 'scalar' indexing. Yeah, I can see that a bit. Ignoring dicts for the moment (and concerning

  1   2   >