Re: recursion depth problem

2007-04-22 Thread tac-tics
Yes, you should use a for loop in this situation. Certain functional languages, such as Scheme and various LISP dialects allow for what is called "tail recursion" which effectively eliminates this problem by internally converting recursion to iteration. Python isn't really cut out for heavy recurs

Re: How can i compare a string which is non null and empty

2007-04-01 Thread tac-tics
str != "" returns true if str is NOT the empty string. str is not None returns true if str is null (or None as it's called in python). To check to make sure a string is nonnull and nonempty, do: str is not None and str != "" -- http://mail.python.org/mailman/listinfo/python-list

Re: problem at installing phyton on windows

2007-03-25 Thread tac-tics
On Mar 25, 1:06 pm, "gslm" <[EMAIL PROTECTED]> wrote: > Hi! > I'm too new on phyton.I have installed phyton.But when I write phyton > command, unfortunately, i can't run.I suppose that it is bacause of > setting path.But i can't solve. > Can you help? You need to set what is called your PATH envir

Re: is it possible to remove the ':' symbol in the end of lines starting with 'if', 'while' etc?

2007-02-22 Thread tac-tics
Tip: don't try learning perl. I agree the colon is largely redundant, but it's not unreasonable. -- http://mail.python.org/mailman/listinfo/python-list

Re: arrow keys don't work

2007-01-22 Thread tac-tics
It looks like I got readline working. Thanks for the help! -- http://mail.python.org/mailman/listinfo/python-list

Re: arrow keys don't work

2007-01-22 Thread tac-tics
> Have you changed your terminal (either the program itself or its config) > so that it is no longer sending the correct codes? I doubt this is the case. Everything works for the bash shell and common lisp. It's just python acting up. > When you hit the arrow key, what happens? Do you just get no

Re: arrow keys don't work

2007-01-22 Thread tac-tics
Robert Kern wrote: > tac-tics wrote: > > I've noticed that in Python 2.5, the interactive prompt does not > > support intelligent use of arrow keys like 2.4 did (up/down for > > previous/next statement, left/right for moving the cursor). What > > exactly is the

arrow keys don't work

2007-01-22 Thread tac-tics
I've noticed that in Python 2.5, the interactive prompt does not support intelligent use of arrow keys like 2.4 did (up/down for previous/next statement, left/right for moving the cursor). What exactly is the reason for this and is there an easier fix than downgradinig to 2.4? Thanks. -- http://m

Re: Question about compiling.

2007-01-10 Thread tac-tics
> That's not the whole truth. :) The whole truth is that from a developer's POV, .pyc files are unimportant. -- http://mail.python.org/mailman/listinfo/python-list

Re: Slowdown in Jython

2006-12-29 Thread tac-tics
> Jython is a Java application That was the intellectual leap I needed to solve the problem. I forgot that I have total access to Java memory management. It turns out at the point of slowdown, Java was continually running full GC, causing the awful loss of performance. I figured out that I was not

Slowdown in Jython

2006-12-28 Thread tac-tics
I have an application written in jython which has to process a number of records. It runs fine until it gets to about 666 records (and maybe that's a sign), and then, it's performance and responsiveness goes down the toilet. It looks like it's running out of memory and is being forced to use extend

Superclass for Errors?

2006-12-27 Thread tac-tics
I have a program which has a GUI front-end which that runs a separate thread to handle all the important stuff. However, if there is a problem with the important stuff, I want the GUI to raise a MessageBox alert to indicate this. For exceptions, I can simply use a catch-all except statement like:

Re: Newbie: what is a usefull IDE for Python on Windows ?

2006-12-26 Thread tac-tics
On Dec 26, 8:53 am, Larry Bates <[EMAIL PROTECTED]> wrote: > Osiris wrote: > > what is a usefull IDE for Python on Windows ? I am a happy user of jEDIT. -- http://mail.python.org/mailman/listinfo/python-list

Re: skip last line in loops

2006-12-14 Thread tac-tics
Try: afile = open(filename) lines = afile.readlines()[:-1] # assigns all except the last element to a list "lines" for line in lines: print line -- http://mail.python.org/mailman/listinfo/python-list

Re: merits of Lisp vs Python

2006-12-13 Thread tac-tics
> > I use 'French units' instead of the term 'metric system' because the > > latter means 'measurement system,' and of course could validly be > > applied to _any_ system.Now we know how one contractor ended up using > > English units when the > other was using French units and an entire Mars miss

Re: merits of Lisp vs Python

2006-12-11 Thread tac-tics
> In musical terms, Python is like a Beatles song, very popular > and easy to sway and dance to. Lisp is like a Bach fugue. Very nice analogy. -- http://mail.python.org/mailman/listinfo/python-list

Re: merits of Lisp vs Python

2006-12-09 Thread tac-tics
I think the lesson here is that LISP is the language you use when you want mathematical elegance and perfection and Python is the language you use if you want to actually program stuff. -- http://mail.python.org/mailman/listinfo/python-list

Re: len() and PEP 3000

2006-12-09 Thread tac-tics
> __len__ is not very special and the > property len eliminates the redundant parentheses. One might say the current syntax eliminates the redundant dot. -- http://mail.python.org/mailman/listinfo/python-list

Re: pdb question

2006-11-26 Thread tac-tics
Strange. It seems to be working just fine now. Maybe I wasn't waiting for all the symbols to be defined before setting my breakpoint. On Nov 26, 2:41 pm, Fredrik Lundh <[EMAIL PROTECTED]> wrote: > tac-tics wrote: > > In the Python debugger (pdb), how do you designate breakpoi

pdb question

2006-11-26 Thread tac-tics
In the Python debugger (pdb), how do you designate breakpoints at the start of methods? I've tried: break methodName break class.methodName break object.methodName but none of these seem to work. What is the trick? -- http://mail.python.org/mailman/listinfo/python-list

Re: Static Variables in Python?

2006-07-31 Thread tac-tics
> But of course: > > >>> def fun(): > global x = 10 > > SyntaxError: invalid syntax > >>> global x x = 10 Close enough ^^; -- http://mail.python.org/mailman/listinfo/python-list

Re: Static Variables in Python?

2006-07-31 Thread tac-tics
Michael Yanowitz wrote: > Is it possible to have a static variable in Python - > a local variable in a function that retains its value. > > For example, suppose I have: > > def set_bit (bit_index, bit_value): >static bits = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0] >bits [bit_index

Re: PIL - transparent ImageDraw.text()

2006-07-19 Thread tac-tics
aljosa wrote: > is it possible to create transparent text (~50% transparency) on image? > i'm using the following code to draw text on image: > > >>> > font = ImageFont.truetype(str(self.font_family)+".ttf", self.font_size) > draw = ImageDraw.Draw(img) > draw.text((10, 10), self.text, font=font,fil

Re: range() is not the best way to check range?

2006-07-18 Thread tac-tics
Simon Forman wrote: > To me, and perhaps others, "T = > set(xrange(0, 1, 23))" and "n in T" are somewhat easier to read > and write than "not n % 23 and 0 <= n < 1", YMMV. Eh? How is the first easier to read than the second?? You have a nested function call in the first! Regardless, test

Re: question about what lamda does

2006-07-18 Thread tac-tics
[EMAIL PROTECTED] wrote: > Hey there, > i have been learning python for the past few months, but i can seem to > get what exactly a lamda is for. What would i use a lamda for that i > could not or would not use a def for ? Is there a notable difference ? > I only ask because i see it in code sample

Re: Python linker

2006-07-18 Thread tac-tics
[EMAIL PROTECTED] wrote: > I love python - I use it as a utility language to complement my C# > programming every day. However, the reason I do not use it as my > primary language is - surprise, surprise - not its lack of static type > checking, but the size of standalone executes (which embed th

Re: range() is not the best way to check range?

2006-07-17 Thread tac-tics
Grant Edwards wrote: > for pete's sake use the comparison operator like god intended. > > if 0 <= i <= 1: I'm assuming you used Python's compound comparison as opposed to the C-style of and'ing two comparisons together to emphasize the fact it is god's chosen way of doing this ;-) -- htt

Re: Coding style

2006-07-17 Thread tac-tics
dwelch91 wrote: > tac-tics wrote: > > > > I'd say the second one. Empty lists are not false. They are empty. Long > > live dedicated boolean data types. > > > Uh, no, empty lists are False in a boolean context: > > http://docs.python.org/lib/truth.html >

Re: Coding style

2006-07-17 Thread tac-tics
> Or even just: > > lst = [] > > ;-) Indeed. I'd say the second one. Empty lists are not false. They are empty. Long live dedicated boolean data types. -- http://mail.python.org/mailman/listinfo/python-list

Re: Embedding exe file

2006-07-17 Thread tac-tics
Bayazee wrote: > hi,ThanX > but i dont want to save the exe file in temp file and run it . i want > to run it directly from python . maybe such this : > exec("file("test.exe","rw").read())") > i want write a cd lock with python tp protect an binary file . and so i > dont want save it in other temp

Re: {} for set notation

2006-07-14 Thread tac-tics
Nick Vatamaniuc wrote: > I really like the set notation idea. Now that sets are first class > "citizens" along with dicts, lists and tuples I think they should be > used when it makes sense to use them In actual usage, though, how often is it strictly required one uses a set over a list? It is sim

Re: free python hosting!

2006-07-10 Thread tac-tics
I provide the link below with the conditions that you don't put spaces between your sentences and the periods which terminate them. http://wiki.python.org/moin/PythonHosting -- http://mail.python.org/mailman/listinfo/python-list

Re: function that modifies a string

2006-07-10 Thread tac-tics
> >> What's wrong about arrays of chars? > > > > Arrays of chars are dangerous. If you insist, use Python lists of > > Python "chars" (strings of length 1). > > Why are they more dangerous than a self-written mutable string? I didn't say that. I meant that arrays in the C++ sense are dangerous.

Re: PIL - Transparency Nightmares

2006-07-10 Thread tac-tics
I RTFM harder, and found that paste with an image mask (using the watermark as the mask) does the trick. -- http://mail.python.org/mailman/listinfo/python-list

PIL - Transparency Nightmares

2006-07-10 Thread tac-tics
I'm trying to make a simple script which attaches watermarks to every image in one directory and saves the output image to another. However, while I understand (in theory at least) what I need to be doing, I can't figure out where to go from here. First of all, I have a watermark image and a list

Re: function that modifies a string

2006-07-10 Thread tac-tics
Diez B. Roggisch wrote: > > Of course, another right way would be to have mutable strings in Python. > > I understand why strings need to be immutable in order to work with dicts, > > but is there any reason why (hypothetical) mutable strings should be > > avoided in situations where they aren't n

Full splitting of a file's pathname

2006-07-10 Thread tac-tics
I know about os.path.split(), but Is there any standard function for "fully" splitting a file's pathname? A function that is the opposite of the os.path.join() function? For example: >>> ret = myster_function(./foo/bar/moo/lar/myfile.txt) >>> print ret ['.', 'foo', 'bar', 'moo', 'lar', 'myfile.txt

Re: array of array of float

2006-07-09 Thread tac-tics
Use nested list comprehensions: matrix = [[0.0 for x in xrange(n)] for y in xrange(m)] This is similar to "float matrix[m][n]" in C. All cells are independent of each other in doing this. -- http://mail.python.org/mailman/listinfo/python-list

Re: first book about python

2006-07-08 Thread tac-tics
Philippe Martin wrote: > I don't know, if I were the genious that made up Python I would not believe > in any bible (small b) Take it to alt.religion please. > I want to learn python. > I plan to buy a book. I always find printed material more convenient than > reading on-line tutorials. I had t

Re: Attaching functions to objects as methods

2006-07-07 Thread tac-tics
Experimenting, I found that >>> x.fun = lambda: fun(x) works as well. Any comments on this way? -- http://mail.python.org/mailman/listinfo/python-list

Re: Attaching functions to objects as methods

2006-07-07 Thread tac-tics
> Functions are descriptors[1], and their __get__ method is used to bind > them to a particular instance:: Thank you muchly. -- http://mail.python.org/mailman/listinfo/python-list

Attaching functions to objects as methods

2006-07-07 Thread tac-tics
Python is a crazy language when it comes to object versatility. I know I can do: >>> class test: ...def __init__(self): ... pass >>> x = test() >>> def fun(): ... print "fun" >>> x.fun = fun >>> x.fun() fun >>> However, experimenting shows that these attached functions are not bou

Re: defining multi dimensional array

2006-07-04 Thread tac-tics
bruce wrote: > hi... > > basic question.. > > how do i define a multi dimensional array > > a[10][10] I find that list comprehensions are useful for this. [ [None for x in xrange(10)] for y in xrange(10)] You could easily write a wrapper for it to clean the syntax a bit. -- http://mail.pytho

Re: Chapter 9 Tutorial for Classes Not Working

2006-06-30 Thread tac-tics
> x = MyClass > xf = x.f > while True: >print xf() Python has some VERY nasty gotchas concerning parenthesis (or lack there of). In the first line here, you assign x = MyClass. That means x becomes an alias for the class MyClass. not an object like you intended. Look back

Re: print shell output in a file

2006-06-30 Thread tac-tics
It sounds like you want to use print >> If you have an open object with a "write" property, you can do print >> thefile, mystring and Python will simply redirect the output to "thefile" instead of sys.stdout. -- http://mail.python.org/mailman/listinfo/python-list

Re: list comprehension

2006-06-29 Thread tac-tics
a wrote: > can someone tell me how to use them > thanks sigh... You do a google on them: http://docs.python.org/tut/node7.html#SECTION00714 They are the program equivalent of set builder notation in math: {x | x in S} would be written [x for x in S] in python. -- http://

Re: Freezing Python with jythonc

2006-06-26 Thread tac-tics
> What am I doing wrong? Nevermind, I figured it out. -classpath overwrites the classpath not augments. I needed to use -classpath ".;jython.jar" and it works fine. -- http://mail.python.org/mailman/listinfo/python-list

Freezing Python with jythonc

2006-06-26 Thread tac-tics
I've got a nice jython application that I wish to freeze. After playing around with flag settinsg on jythonc, I managed to get it to compile without warnings or errors, but when I try to run my main class file, I keep getting the error: Exception in "main" thread, NoClassDefFoundError. When I just

Re: Opening a file with system default application

2006-06-23 Thread tac-tics
BartlebyScrivener wrote: > don't know Jython, but in Python, I think you want: > > import os > > os.system('mytextfile.txt') > > Whatever file you reference should open in the application associated > with it. At least that's the way it works on Win XP > > rd I didn't think about that. It would pr