modify dictionary while iterating

2005-11-10 Thread s99999999s2003
hi I wish to pop/del some items out of dictionary while iterating over it. a = { 'a':1, 'b':2 } for k, v in a.iteritems(): if v==2: del a[k] the output say RuntimeError: dictionary changed size during iteration how can i suppress this message in an actual script and still get the final

Re: how can i get system time?

2005-11-10 Thread Mike Meyer
"[EMAIL PROTECTED]" <[EMAIL PROTECTED]> writes: > Hi, Can I get a system date time? time.time() > I want to get current time, like > the target string should looks like: > the output of : `date +"%Y%m%d %H:%M:%S"` > > how can i do this? >>> time.strftime("%Y%m%d %H:%M:%S") '2005 02:44

Re: Recompile AST?

2005-11-10 Thread Bengt Richter
On 10 Nov 2005 16:07:56 -0800, "Paul Boddie" <[EMAIL PROTECTED]> wrote: >Bengt Richter wrote: >> I've also posted sporadic musings about the possibilities for >> AST-transforming >> custom import functions to do optimizations and macros and special forms >> etc., >> but no one seemed much intere

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

2005-11-10 Thread Svenn Are Bjerkem
In article <[EMAIL PROTECTED]>, [EMAIL PROTECTED] says... > Why does there need to be OO "in the core"? That is one thing I have > never understood. If you want OO, get a package that fits your style of > OO and "package require" you are off and running. That probably isn't > what you would be loo

Job - PYTHON Engineers, BitTorrent, Inc., San Francisco, CA

2005-11-10 Thread camdenjobs
PYTHON Engineers, BitTorrent, Inc., San Francisco, CA Interested candidates should forward their resumes to [EMAIL PROTECTED] for immediate consideration. No resume? No problem…..Tell us about your Python skills and how you may have contributed to the Open Source community. WHO WE ARE: BitT

PYTHON Engineers, BitTorrent, Inc. San Francisco, CA

2005-11-10 Thread dan_crask
PYTHON Engineers, BitTorrent, Inc. lace w:st="on">San Francisco, CAlace >Interested candidates should forward their resumes to [EMAIL PROTECTED]>>for immediate consideration.  No resume?  No problem…..Tell us about your Python skills and how you may have contributed to the Open Source community

Re: ANN: P(x) 0.2 applet builder

2005-11-10 Thread LB
>it looks like LB has configured his browser to pass all gz files to some >ancient VRML plugin; see e.g. You are right! And now it's fixed. But till yesterday I did download of .gz file with no problems at all... Thanks, LB -- http://mail.python.org/mailman/listinfo/python-list

Re: ANN: P(x) 0.2 applet builder

2005-11-10 Thread LB
>it looks like LB has configured his browser to pass all gz files to some >ancient VRML plugin; see e.g. You are right! And now it's fixed. But till yesterday I did download of .gz file with no problems at all... Thanks, LB -- http://mail.python.org/mailman/listinfo/python-list

Good python reference?

2005-11-10 Thread derek
Hello! I'm new to the group and am looking for a decent reference for information about the history / evolution of the Python language and its features. Typing, scoping, etc... I'd appreciate any good links. Thanks! - Derek -- http://mail.python.org/mailman/listinfo/python-list

Re: [ x for x in xrange(10) when p(x) ]

2005-11-10 Thread [EMAIL PROTECTED]
Bengt Richter wrote: > IOW, your "when condition(x)" (IIUIC) can be spelled "if condition(x) or > stop()" neat trick. -- http://mail.python.org/mailman/listinfo/python-list

how can i get system time?

2005-11-10 Thread [EMAIL PROTECTED]
Hi, Can I get a system date time? I want to get current time, like the target string should looks like: the output of : `date +"%Y%m%d %H:%M:%S"` how can i do this? thanks. -- http://mail.python.org/mailman/listinfo/python-list

Re: LARGE numbers

2005-11-10 Thread casevh
For more information on how the largest prime number was found, see www.mersenne.org. Python does support large numbers, but it's not very fast for such large numbers. There is a Python module called GMPY that uses the GMP (Gnu Multiple Precision) library for faster operations on large numbers. B

Re: [ x for x in xrange(10) when p(x) ]

2005-11-10 Thread [EMAIL PROTECTED]
oops, stand corrected. I was under the impression that an exception would break out of the current expression and forgot that the "for" would contain it(that StopIteration is a condition to it expects to stop it). thanks, this is the functionality I am looking for. Alex Martelli wrote: > Can you

Re: gmpy 1.01 rc near... anybody wanna test>

2005-11-10 Thread casevh
I've created Windows binaries for Python 2.3 and 2.4. It should be compatible with PentiumPro or later processors. They can be found at http://home.comcast.net/~casevh/ Case -- http://mail.python.org/mailman/listinfo/python-list

Re: Change directory not successfully done

2005-11-10 Thread Samuel Yin
Thanks for your answer. I know why the why os.system or os.chdir failed change my directory. But Sorry for my un-clear description of my problem. Currently I work in window platform, use cmd.exe instead of bash. I mentioned bash just as a example to illustrate my problem.     Thanks and Reg

LARGE numbers

2005-11-10 Thread Tuvas
I've been thinking about writing a program to generate the world's largest prime numbers, just for the fun of it. This would require being able to hold an 800 digit number into memory (25 megabits, or a little over 3 megs of memory for just one variable...) I would also need several smaller var

Re: [ x for x in xrange(10) when p(x) ]

2005-11-10 Thread Alex Martelli
[EMAIL PROTECTED] <[EMAIL PROTECTED]> wrote: > > >>> list (x for x in xrange(20) if x<5 or iter([]).next()) > > [0, 1, 2, 3, 4] > > > > Or a bit more readably: > > >>> def stop(): raise StopIteration > > ... > > >>> list (x for x in xrange(20) if x<5 or stop()) > > [0, 1, 2, 3, 4] > > > > IO

Re: Python obfuscation

2005-11-10 Thread Alex Martelli
Yu-Xi Lim <[EMAIL PROTECTED]> wrote: ... > My brother is bugged by Civilization IV's copy protection. A couple of > days ago, after consulting me on what other options he could try, he > finally said in frustration, "Maybe I should go buy the game." It's interesting, in this context, that Civi

Re: Python obfuscation

2005-11-10 Thread Alex Martelli
petantik <[EMAIL PROTECTED]> wrote: ... > I think that is not workable because it is easy to say the the internet > is available everywhere. This implies that, if it were difficult to say it, then the scheme WOULD be workable... which I doubt is what you mean, of course;-) > It is not availab

Re: need an example of Python numarray to C++ and back again, Boost / SWIG?

2005-11-10 Thread Fernando Perez
PL wrote: > I looked at Stefan's post - but he remarks that "Unfortunately, Blitz > jealously guards its data (restricted pointers), so that it is not so > easy to do the conversion in the other direction. If anyone knows an > answer to this problem, I'd be glad to hear it" > > I've previously l

Re: How to set program name in Python? ($0 in Perl)

2005-11-10 Thread jmdeschamps
This is not directly what the OP wanted in regards to Perl, but to see what one could do if one needed to change the name of the running program, I wrote this: ## START PROGRAM import sys import os.path import shutil import os def testChangingName(appname): hopedfornameis = appname mylongn

Re: : detecting modifier keys?

2005-11-10 Thread MackS
Hi Dennis, Thanks for your help, what is happening is clear now. Just found that calling curses.raw() lets you get all scan codes. Cheers Mack -- http://mail.python.org/mailman/listinfo/python-list

Re: exceptions, internals (introspection?)

2005-11-10 Thread Fernando Perez
ej wrote: > I have often wondered how to get at other internals, such as the name of > the current function, file, line number I am in? The arguments to the > current function, etc. I browsed through the table of contents of both the > Library Reference & Language Reference. I see section 18

Re: Command-line tool able to take multiple commands at one time?

2005-11-10 Thread Fernando Perez
Peter A.Schott wrote: > Per subject - I realize I can copy/paste a line at a time into an interactive > session when I'm trying to debug, but was wondering if there is any tool out > there that allows me to copy sections of working Python scripts to paste into > my interactive console and let thos

Re: Abstract Base Classes

2005-11-10 Thread Ben Finney
Mike Meyer <[EMAIL PROTECTED]> wrote: > class FooException(Exception): > def __init__(self): > if self.__class__ == FooException: > raise NotImplementedError, >"FooException is an abstract class for exceptions" Shall try this when I get the chance.

Re: Abstract Base Classes

2005-11-10 Thread Mike Meyer
Ben Finney <[EMAIL PROTECTED]> writes: > I've tried doing this in the __init__(): > > class FooException(Exception): > """ Base class for all FooModule exceptions """ > def __init__(self): > raise NotImplementedError, \ > "%s is an abstract class for

Re: Hi, from my login i want to login as a other user ,

2005-11-10 Thread Ganesan Rajagopal
> sumi <[EMAIL PROTECTED]> writes: > Hi, i am very new to python , it is just 2 days i started reading abt > it. I did not understand the above statement. Just read the document at the URL given to you. > what i want to do is , i want to login as a super user eg : $su xyz , and > then i n

Re: Change directory not successfully done

2005-11-10 Thread Mike Meyer
Samuel Yin <[EMAIL PROTECTED]> writes: > Hi, guys, > > This should be a simple problem, but I just can not resolve it. I just > want to use a python script to change my working directory. see my > following code: > > # mycd.py > 1) destdir = "" > 2) command = "cd "+ destdir > 3) os.system(c

Abstract Base Classes

2005-11-10 Thread Ben Finney
Howdy all, Okay, so Guido doesn't like Abstract Base Classes[0], and interfaces are the way of the future[1]. But they're not here now, and I understand ABCs better. I want my modules to (sometimes) define an abstract base exception class, that all other exceptions in that module inherit from.

Re: derived / base class name conflicts

2005-11-10 Thread Ben Finney
[EMAIL PROTECTED] wrote: > Suppose you want to write a subclass of some existing class you are > importing from a module you didn't write and that you don't want to > study the internals of No need to study its internals. Fire up a Python interpreter and inspect its outside: >>> import foomod

Re: Printing current time to a file

2005-11-10 Thread Peter Hansen
[EMAIL PROTECTED] wrote: > I am trying to print the current system time to a file. I know only a > little bit about Python. I have gotten the very simple: > > Print time.time() > > to work properly. From what I gather the line to print it to a file > should look like: > > self.log.write(time.

Re: testing C code with python

2005-11-10 Thread Peter Hansen
[EMAIL PROTECTED] wrote: > A simple question - Is it common/good practice to test C code using > Python? For example one could wrap individual C functions, and test > each of them using python, maybe not for low-level things but at least > for algorithmic correctness. Anyone effectively doing this

Re: How to set program name in Python? ($0 in Perl)

2005-11-10 Thread Bengt Richter
gt; >given that Swaroop has written a nice book about Python, I somehow >suspect that he knows how sys.argv works: > > http://tinyurl.com/9s7bz > Sorry, I wasn't familiar with that (or Swaroop ;-) >or are you saying that "ps" looks inside sys.argv on your mac

Re: derived / base class name conflicts

2005-11-10 Thread christopherlmarshall
Fredrik Lundh wrote: > [EMAIL PROTECTED] wrote: > > > Now, 'i' might have already been defined by A or by the call to > > A.__init__() so if you define it without knowing that, you could be > > changing the behavior of A's methods in unknown ways, which is > > obviously a bad thing. > > http://doc

Re: Printing current time to a file

2005-11-10 Thread skip
zolaris> self.log.write(time.ctime(time.time())) zolaris> But that prints nothing in the file assigned to log. Is there zolaris> something I should be doing extra? There's no newline in there. You probably need to flush the file: self.log.write(time.ctime(time.time())) self

Curses & Keypress

2005-11-10 Thread ale . of . ginger
Now that I have gotoxy() down for moving the cursor around, I want that to be a result of keypresses (namely from the numpad -- 7 = NorthWest, 8 = North, 9 = NE, etc...). I have little clue how to do this. After searching google, I've come upon this; include: import curses in the header. Howev

Re: derived / base class name conflicts

2005-11-10 Thread christopherlmarshall
Steve Juranich wrote: > This should prove most enlightening: > > import Tkinter > dir(Tkinter.Canvas) > > Huh? Chris Marshall -- http://mail.python.org/mailman/listinfo/python-list

Re: [ x for x in xrange(10) when p(x) ]

2005-11-10 Thread [EMAIL PROTECTED]
Bengt Richter wrote: > If you want to terminate a generator expression after the first sequence of > elements > satisfying a condition, and you don't want to use takewhile, I don't know of > a gotcha > to prevent you from just raising StopIteration, using an expression that will > do that, e.g.

Change directory not successfully done

2005-11-10 Thread Samuel Yin
Hi, guys, This should be a simple problem, but I just can not resolve it. I just want to use a python script to change my working directory. see my following code: # mycd.py 1) destdir = "" 2) command = "cd "+ destdir 3) os.system(command) 4) os.chdir(destdir) But neither 3) nor 4) is us

Re: SuSe 10.0 missing Idle

2005-11-10 Thread Steve
Joseph Garvin wrote: > Steve wrote: > >>Hello, >> >>Hopefully this is not to of topic. I just installed SuSe >>10.0 >> and although python installed but no Idle. I can't seem to find it >> in >>the list of available packages either. I was wondering if someone >>might steer me in t

Re: Recompile AST?

2005-11-10 Thread Chris Spencer
Leif K-Brooks wrote: > [EMAIL PROTECTED] wrote: > >>Is it possible to recompile the AST generated by compiler.parse, back >>into code or an executable code object? > > > Into a bytecode object: > > >>> from compiler.pycodegen import ModuleCodeGenerator > >>> from compiler.misc import set_file

Re: Command-line tool able to take multiple commands at one time?

2005-11-10 Thread Mike Meyer
Peter A. Schott <[EMAIL PROTECTED]> writes: > Per subject - I realize I can copy/paste a line at a time into an interactive > session when I'm trying to debug, but was wondering if there is any tool out > there that allows me to copy sections of working Python scripts to paste into > my > interact

Re: Python obfuscation

2005-11-10 Thread Mike Meyer
Yu-Xi Lim <[EMAIL PROTECTED]> writes: > Bill Mill wrote: >> Your only solution, then, is to write unpopular code. Because, as Alex >> said, it will otherwise be broken into. Let's look at two very popular >> pieces of code: Half-Life 2 and Windows XP. How are they secured? >> Previous version of th

Re: SuSe 10.0 missing Idle

2005-11-10 Thread Joseph Garvin
Steve wrote: >Hello, > >Hopefully this is not to of topic. I just installed SuSe 10.0 > and although python installed but no Idle. I can't seem to find it in >the list of available packages either. I was wondering if someone might >steer me in the right direction. I've just started learni

Printing current time to a file

2005-11-10 Thread zolaris
I am trying to print the current system time to a file. I know only a little bit about Python. I have gotten the very simple: Print time.time() to work properly. From what I gather the line to print it to a file should look like: self.log.write(time.ctime(time.time())) But that prints nothin

Re: Stopping Execution

2005-11-10 Thread gblais
surely you mean sys.exit() Gerry -- http://mail.python.org/mailman/listinfo/python-list

Re: Command-line tool able to take multiple commands at one time?

2005-11-10 Thread Devan L
Peter A. Schott wrote: > Per subject - I realize I can copy/paste a line at a time into an interactive > session when I'm trying to debug, but was wondering if there is any tool out > there that allows me to copy sections of working Python scripts to paste into > my > interactive console and let

Re: Python obfuscation

2005-11-10 Thread Yu-Xi Lim
Bill Mill wrote: > Your only solution, then, is to write unpopular code. Because, as Alex > said, it will otherwise be broken into. Let's look at two very popular > pieces of code: Half-Life 2 and Windows XP. How are they secured? > Previous version of these software products used sophisticated > c

Re: Stopping Execution

2005-11-10 Thread Steve Holden
Fredrik Lundh wrote: > [EMAIL PROTECTED] wrote: > > >>import sys >>sys.exit > > > $ more test.py > import sys > print "should get here" > sys.exit > print "should never get here" > > $ python test.py > should get here > should never get here > Which is Fredrik's way of telling you you need to

Re: CherryPy not playing nicely with win32com?

2005-11-10 Thread Irmen de Jong
infidel wrote: > I've been trying to get my CherryPy server to authenticate users > against our network. I've managed to cobble together a simple function > that uses our LDAP server to validate the username and password entered > by the user: [...] > moniker, i, bindCtx = pythoncom.MkParseD

Command-line tool able to take multiple commands at one time?

2005-11-10 Thread Peter A.Schott
Per subject - I realize I can copy/paste a line at a time into an interactive session when I'm trying to debug, but was wondering if there is any tool out there that allows me to copy sections of working Python scripts to paste into my interactive console and let those run so I don't have to copy l

SuSe 10.0 missing Idle

2005-11-10 Thread Steve
Hello, Hopefully this is not to of topic. I just installed SuSe 10.0 and although python installed but no Idle. I can't seem to find it in the list of available packages either. I was wondering if someone might steer me in the right direction. I've just started learning python and would

Re: Recompile AST?

2005-11-10 Thread Leif K-Brooks
[EMAIL PROTECTED] wrote: > Is it possible to recompile the AST generated by compiler.parse, back > into code or an executable code object? Into a bytecode object: >>> from compiler.pycodegen import ModuleCodeGenerator >>> from compiler.misc import set_filename >>> from compiler import parse >

Re: ANN: P(x) 0.2 applet builder

2005-11-10 Thread Steve Holden
Fredrik Lundh wrote: > Mike Meyer wrote: > > >>Since following standards is optional on the web, at least if things >>work in the most popular browser of the day, I probably should have >>seen this coming. > > > IE has no problems handling that link, if that's what you mean. > > judging from >

Re: Circe

2005-11-10 Thread nick125
Actually, Circe was being developed before the emacs circe was developed. -- http://mail.python.org/mailman/listinfo/python-list

Re: Recompile AST?

2005-11-10 Thread Paul Boddie
Bengt Richter wrote: > I've also posted sporadic musings about the possibilities for AST-transforming > custom import functions to do optimizations and macros and special forms etc., > but no one seemed much interested (or maybe they quietly went off to do > something of their own ;-) For an examp

Re: thread variable scope with start_new_thread

2005-11-10 Thread Fredrik Lundh
"Luxore" <[EMAIL PROTECTED]> wrote: > I am trying to create threaded python project and I'm running into some > weird Python variable scoping. the "weird scoping" you're seeing has nothing to do with threads (read on) > I am using the "thread" module (I know, it's old and I should be using > thr

Re: Recompile AST?

2005-11-10 Thread Bengt Richter
On 10 Nov 2005 13:21:56 -0800, [EMAIL PROTECTED] wrote: >Is it possible to recompile the AST generated by compiler.parse, back >into code or an executable code object? My aim here is to allow a >script to manipulate Python code as elements within a list. However, it >doesn't look like the module h

thread variable scope with start_new_thread

2005-11-10 Thread Luxore
Hello, I am trying to create threaded python project and I'm running into some weird Python variable scoping. I am using the "thread" module (I know, it's old and I should be using threading)... but for example: import thread def extract_archive(session, user, archive, dest=None): job_id =

Re: derived / base class name conflicts

2005-11-10 Thread Fredrik Lundh
[EMAIL PROTECTED] wrote: > Now, 'i' might have already been defined by A or by the call to > A.__init__() so if you define it without knowing that, you could be > changing the behavior of A's methods in unknown ways, which is > obviously a bad thing. http://docs.python.org/tut/node11.html#SECTION

Re: derived / base class name conflicts

2005-11-10 Thread Steve Juranich
This should prove most enlightening: import Tkinter dir(Tkinter.Canvas) On 10 Nov 2005 14:53:04 -0800, [EMAIL PROTECTED] <[EMAIL PROTECTED]> wrote: > Suppose you want to write a subclass of some existing class you are > importing from a module you didn't write and that you don't want to > study

Re: Newb ??

2005-11-10 Thread Fredrik Lundh
Steven D'Aprano wrote: > Dude, that's what my code does, although I admit I took zero care to get > the awkward boundary conditions right, nor did I put code in to stop the > game after five attempts. as my simulator shows, your code needs 5.87 attempts to make a correct guess, on average. if yo

derived / base class name conflicts

2005-11-10 Thread christopherlmarshall
Suppose you want to write a subclass of some existing class you are importing from a module you didn't write and that you don't want to study the internals of, and you want to define a data member i in your constructor. As in the following: from module1 import A class B(A): def __init__(self)

Re: [Tutor] triangulation

2005-11-10 Thread Robert Kern
Shi Mu wrote: > the Internet is down for one day and so wonderful to have so many > responses. i have checked all the links you guys mentioned. what i > want is delaunay triangulation and the available ones online are > written in C, Java and FORTRAN. I want to see some in Python because > it is h

Re: Newb ??

2005-11-10 Thread Steven D'Aprano
On Thu, 10 Nov 2005 17:31:18 +, Steve Holden wrote: > Effectively you want to start with a minposs and maxposs, which are set > to 0 and 100 respectively. Your guess should bisect the range (as nearly > as it can given that you are dealing with integers, and you have to be > careful to get

Re: Stopping Execution

2005-11-10 Thread James Colannino
Fredrik Lundh wrote: > the usual way: > >sys.exit() # or "raise SystemExit" >[...] > Ah, thank you. I wasn't aware that I'd have to import a module to have that ability. I'm still very new, so I have a lot to get used to :-P James -- My blog: http://www.crazydrclaw.com/ My homepage: htt

CherryPy not playing nicely with win32com?

2005-11-10 Thread infidel
I've been trying to get my CherryPy server to authenticate users against our network. I've managed to cobble together a simple function that uses our LDAP server to validate the username and password entered by the user: # ldap.py from win32com.client import GetObject ADS_SECURE_AUTHENTICATION =

Re: different binding behavior

2005-11-10 Thread Paul Rubin
Steven D'Aprano <[EMAIL PROTECTED]> writes: > Imagine that ints could be changed in place. Then you could do this: > > x = 0 > x += 1 No nothing like that. Nothing stops you from having multiple int objects with the same value. Lists, for example, are mutable, but x = [0,1] x += [2,3] doe

Re: How to set program name in Python? ($0 in Perl)

2005-11-10 Thread Fredrik Lundh
Bengt Richter wrote: > >> > Is there a way to set the program name in Python, similar to $0 in > >> > Perl? > >> > > >> >>From `man perlvar`: > >> > > >> > $0 Contains the name of the program being executed. On some oper- > >> > ating systems assigning to "$0" modifies the argument area that

Re: exceptions, internals (introspection?)

2005-11-10 Thread Paul Rubin
"ej" writes: > for key in dir(traceback_): > print "traceback_.%s =" % key, eval("traceback_.%s" % key) Don't use eval for this. Use getattr(traceback_, key). > traceback_.tb_frame = > traceback_.tb_lasti = 18 > traceback_.tb_lineno = 6 > traceback_.tb_next = None Yeah. As /F men

Re: different binding behavior

2005-11-10 Thread Steven D'Aprano
On Thu, 10 Nov 2005 22:43:53 +0100, Gabriel Zachmann wrote: > It seems to me that the following behavior of python (2.4.1) is inconsistent: We've just had a HUGE thread arguing about this behaviour, just three or five days ago. Let's not start it again. In a nutshell, the behaviour is because i

Re: different binding behavior

2005-11-10 Thread Fredrik Lundh
Gabriel Zachmann wrote: > It seems to me that the following behavior of python (2.4.1) is > inconsistent: > > >>> a=1 > >>> b=a > >>> a+=1 > >>> b > 1 > >>> a > 2 > >>> a=[1,2] > >>> b=a > >>> b+=[3] > >>> a > [1, 2, 3] > >>> b > [1, 2, 3] > > Why was it implemented like this?? assuming

testing C code with python

2005-11-10 Thread Bilgehan . Balban
Hi, A simple question - Is it common/good practice to test C code using Python? For example one could wrap individual C functions, and test each of them using python, maybe not for low-level things but at least for algorithmic correctness. Anyone effectively doing this as common practice? Thanks,

Re: exceptions, internals (introspection?)

2005-11-10 Thread ej
"Fredrik Lundh" <[EMAIL PROTECTED]> wrote in message news:[EMAIL PROTECTED] > the second example on this page shows you how to do that: > > http://effbot.org/librarybook/traceback I am looking at it. Thanks for your prompt reply, Mr. Lundh! :) -ej -- http://mail.python.org/mailman/listinf

Re: Stopping Execution

2005-11-10 Thread Fredrik Lundh
[EMAIL PROTECTED] wrote: > import sys > sys.exit $ more test.py import sys print "should get here" sys.exit print "should never get here" $ python test.py should get here should never get here -- http://mail.python.org/mailman/listinfo/python-list

Re: exceptions, internals (introspection?)

2005-11-10 Thread ej
"Paul Rubin" wrote in message news:[EMAIL PROTECTED] > It's messy. Look at sys.exc_info() and go from there. Yeah, I think I am starting to see what you mean... #! /usr/local/bin/python import sys try: {}['foo'] except Exception, x: print "class of x =", x._

Re: How to set program name in Python? ($0 in Perl)

2005-11-10 Thread Bengt Richter
On Thu, 10 Nov 2005 08:06:27 +0100, "Fredrik Lundh" <[EMAIL PROTECTED]> wrote: >Steve Holden wrote: > >> > Is there a way to set the program name in Python, similar to $0 in >> > Perl? >> > >> >>From `man perlvar`: >> > >> > $0 Contains the name of the program being executed. On some oper- >

Re: Python music interfaces

2005-11-10 Thread Lonnie Princehouse
Are you talking about audio files (wav, mp3) or MIDI? Converting audio files into discrete notes ("music recognition") is seriously non-trivial, although there are some commercial products you might be able to use for this. On the other hand, you could draw a spectrographs without too much troub

Re: Python obfuscation

2005-11-10 Thread Carsten Haese
On Thu, 2005-11-10 at 16:53, Steven D'Aprano wrote: > Dude, a comprehension protection for *any* software can never be built > because of the fundamental nature of computers. Trying to stop bytes from > being copyable is like trying to stop water from being wet, and once > copied, all copies are id

Re: Python obfuscation

2005-11-10 Thread Mike Meyer
"Ben Sizer" <[EMAIL PROTECTED]> writes: > For example, I'd like to write a game in Python. I'd like to give the > game away free and charge for extra content. In C++ I can make it > difficult for users to share content with others who haven't paid for > it, with cryptographic hashes and the like. N

Re: different binding behavior

2005-11-10 Thread David Wahler
Gabriel Zachmann wrote: > It seems to me that the following behavior of python (2.4.1) is inconsistent: [snip] > Why was it implemented like this?? Lists are mutable objects; integers are not. For a list, a += b is equivalent to a.__iadd__(b), which is an in-place modification. For an integer, no

Re: [ x for x in xrange(10) when p(x) ]

2005-11-10 Thread Bengt Richter
On 10 Nov 2005 04:56:34 -0800, "[EMAIL PROTECTED]" <[EMAIL PROTECTED]> wrote: > >Peter Hansen wrote: >> (I say "readable or somehow better" since you stated in another post "I >> just try to use list/generator expression when possible" but you didn't >> explain your reason for doing so. I assume

RE: [ x for x in xrange(10) when p(x) ]

2005-11-10 Thread Delaney, Timothy (Tim)
Colin J. Williams wrote: > Are there generally accepted guidelines on what is appropriate for the > builtin namespace? Yes. If Guido can be convinced it should be in builtins, it should be. Tim Delaney -- http://mail.python.org/mailman/listinfo/python-list

Re: Python obfuscation

2005-11-10 Thread Steven D'Aprano
On Thu, 10 Nov 2005 08:23:07 -0800, petantik wrote: > Perhaps a comprehensive protection for interpreted languages can never > be built because of their high level nature? Dude, a comprehension protection for *any* software can never be built because of the fundamental nature of computers. Trying

Re: Python obfuscation

2005-11-10 Thread Timothy Smith
> Reliability is >important but so is protecting your code in an effective manner > > there is no way to prevent people disassembling your code compiled or otherwise. once you give then the program they can easily take it apart. no if's, no but's; do NOT rely on binary's for security. > >the

Re: Stopping Execution

2005-11-10 Thread robert . dowell
import sys sys.exit -- http://mail.python.org/mailman/listinfo/python-list

Re: Addressing the last element of a list

2005-11-10 Thread Steven D'Aprano
On Thu, 10 Nov 2005 08:19:36 -0800, [EMAIL PROTECTED] wrote: > This mutable/immutable object and name/variable is confusing. It is a source of confusion to newbies, because it is a distinction that may not be intuitively obvious, and it is a programming model that isn't quite the same as many peo

Re: Stopping Execution

2005-11-10 Thread Fredrik Lundh
James Colannino wrote: > Hey everyone. I remember from my C programming that I can either use > the exit() or return() functions to end execution of the main code > block. My question is, is there a way for me to do this in Python? I > know there has to be, but I can't for the life of me figure

different binding behavior

2005-11-10 Thread Gabriel Zachmann
It seems to me that the following behavior of python (2.4.1) is inconsistent: >>> a=1 >>> b=a >>> a+=1 >>> b 1 >>> a 2 >>> a=[1,2] >>> b=a >>> b+=[3] >>> a [1, 2, 3] >>> b [1, 2, 3] Why was it implemented like this?? Best regards, Gabriel. -- /

Re: [Tutor] triangulation

2005-11-10 Thread Shi Mu
On 11/10/05, Alex Hunsley <[EMAIL PROTECTED]> wrote: > Alan Gauld wrote: > > >>As in Pythagoras? > >> > >> > > > > > > > >>Or as in triangulation on a 2D surface, navigation etc.? > >> > >> > > > > > > > >>Or, do you mean radio triangulation by directional signal propagation > >> > >> > > > > > > >

Re: Python obfuscation

2005-11-10 Thread Mike Meyer
"petantik" <[EMAIL PROTECTED]> writes: > Perhaps a comprehensive protection for interpreted languages can never > be built because of their high level nature? Nah. Compiling/interpreting is an implementation detail, and orthogonal to the issue of "high level". There are compilers for high level la

Re: Recompile AST?

2005-11-10 Thread François Pinard
[EMAIL PROTECTED] > Is it possible to recompile the AST generated by compiler.parse, back > into code or an executable code object? My aim here is to allow > a script to manipulate Python code as elements within a list. However, > it doesn't look like the module has any native methods designed

Stopping Execution

2005-11-10 Thread James Colannino
Hey everyone. I remember from my C programming that I can either use the exit() or return() functions to end execution of the main code block. My question is, is there a way for me to do this in Python? I know there has to be, but I can't for the life of me figure out what it is. The reason

Re: how to modify code while debugging it without having to stop and then restart debugger

2005-11-10 Thread Mike Meyer
Magnus Lycka <[EMAIL PROTECTED]> writes: > Mike Meyer wrote: >> In that case, you're using the wrong IDE. I run the Python interpeter >> inside of Emacs. I edit my code in another buffer. In the source code >> buffer, I hit M-C-x, and the current version of the function I'm >> currently editing ge

Re: Python obfuscation

2005-11-10 Thread Bill Mill
On 10 Nov 2005 08:40:17 -0800, Ben Sizer <[EMAIL PROTECTED]> wrote: > Alex Martelli wrote: > > > This is (a minor) one of the many reasons that make webservices the way > > of the future (hey, even *MSFT* noticed that recently, it seems...). > > But they are not suitable for all applications, and p

Recompile AST?

2005-11-10 Thread chrisspen
Is it possible to recompile the AST generated by compiler.parse, back into code or an executable code object? My aim here is to allow a script to manipulate Python code as elements within a list. However, it doesn't look like the module has any native methods designed to do this. Chris -- http:/

Re: Addressing the last element of a list

2005-11-10 Thread Donn Cave
In article <[EMAIL PROTECTED]>, Mike Meyer <[EMAIL PROTECTED]> wrote: ... > Most OO languages do the name/variable thing, but some of the popular > ones aren't consistent about it, giving some types "special" status, > so that sometimes "a = b" causes b to be copied onto a, and sometimes > it caus

Python music interfaces

2005-11-10 Thread James Harris
Hi, I am wanting to develop some software that a) Reads existing files of music of a few well known types b) Displays the music in traditional notation - i.e. on a stave c) Displays the same music in my own notation that I am playing with d) Allows both to be printed I guess I ca

Re: exceptions, internals (introspection?)

2005-11-10 Thread Paul McNett
ej wrote: > I have often wondered how to get at other internals, such as the name of > the current function, file, line number I am in? The arguments to the > current function, etc. Others have given you information on how to get at the stack trace. But regarding getting at some of the othe

Re: append to non-existing list

2005-11-10 Thread Mike Meyer
Yves Glodt <[EMAIL PROTECTED]> writes: > Which raises another question... :-) > > Is there a possibility to bring together apache and python in a way > that I can embed python into html? Lots of ways. Most of them aren't really Python, but look a lot like it. PSP is most like PHP/ASP/etc., and I

  1   2   3   >