Re: Select hangs after some reads

2006-06-08 Thread [EMAIL PROTECTED]
Steve Holden wrote: > [EMAIL PROTECTED] wrote: > > Hi, > > > > I'm building a multithreaded application and I encountered a tiny and > > annoying problem. I use a select to wait for data to be read from a > > socket, after some reads, the select simply block

Re: Select hangs after some reads

2006-06-08 Thread [EMAIL PROTECTED]
Grant Edwards escreveu: > On 2006-06-08, [EMAIL PROTECTED] <[EMAIL PROTECTED]> wrote: > > > Well, actually I´m using a very simple protocol wich sends only > > strings ended by newline. I need to send 3 chunks of information and a > > newline after them. On the

Re: Where is the ucs-32 codec?

2006-06-09 Thread [EMAIL PROTECTED]
Méta-MCI wrote: > Hi! > > Look at: http://cjkpython.berlios.de (iconvcodec) > > (Serge Orlov has built a version for Python 2.4 "special for me"; thanks to > him). > Thanks for the pointer. iconvcodec should do the job, but I still want a native implementation to be included with any python. --

Re: Where is the ucs-32 codec?

2006-06-09 Thread [EMAIL PROTECTED]
Martin v. Löwis wrote: > Erik Max Francis wrote: > >> The only reason is that nobody has needed one so far, and because > >> it is quite some work to do if done correctly. Why do you need it? > > Somebody asked me about generating UTF-32 (he didn't have choice of the output format). I was about to

Re: Select hangs after some reads

2006-06-09 Thread [EMAIL PROTECTED]
Grant Edwards escreveu: > On 2006-06-08, [EMAIL PROTECTED] <[EMAIL PROTECTED]> wrote: > > >>> Well, actually I´m using a very simple protocol wich sends > >>> only strings ended by newline. I need to send 3 chunks of > >>> information and a newli

Re: Getting start/end dates given week-number

2006-06-09 Thread [EMAIL PROTECTED]
see the calendar faq http://www.faqs.org/faqs/calendars/faq/part3/, look especially in section 6.7. Tim Chase wrote: > I've been trying to come up with a good algorithm for determining > the starting and ending dates given the week number (as defined > by the strftime("%W") function). > > My prefe

Re: removing dictionary key-pair

2006-06-09 Thread [EMAIL PROTECTED]
JD wrote: > Hello, > > I try to remove a dictionary key-pair (remove an entry), > but I'm unsuccessful. Does anyone know how to achieve this? > > Thanks Assuming you know the key: d = {"foo":1,"bar":2} print d del(d["foo"]) print d -- http://mail.python.org/mailman/listinfo/python-list

Re: removing dictionary key-pair

2006-06-09 Thread [EMAIL PROTECTED]
JD wrote: > Hello, > > I try to remove a dictionary key-pair (remove an entry), > but I'm unsuccessful. Does anyone know how to achieve this? > > Thanks d = dict(a=1, b=2, c=3) print d del d['a'] print d -- http://mail.python.org/mailman/listinfo/python-list

Interacting with a process that I ran with subprocess module

2006-06-09 Thread [EMAIL PROTECTED]
Hi folks, I'm trying to use the nmap runtime interaction feature while using it with the subprocess module. For those not familiar with nmap, the runtime interaction feature allow users to get informations about the scan stats during the nmap execution. More at: http://www.insecure.org/nmap/man/ma

Re: References and copying

2006-06-09 Thread [EMAIL PROTECTED]
> Where can I find a good explanation when does an interpreter copy the > value, and when does it create the reference. Any good Python book. I have Learning Python and Programming Python 2nd edition and they are very good IMO. > I thought I understand > it, but I have just typed in following comm

Re: Newbie question about updating multiple objects ...

2006-06-09 Thread [EMAIL PROTECTED]
[EMAIL PROTECTED] wrote: > All, > Hello and welcome to Python. > Apologies in advance: I'm new to Python and OO, and I'm sure this is a > really simple question, but I just can't seem to crack it on my own, or > through looking at examples. I'm

Re: References and copying

2006-06-09 Thread [EMAIL PROTECTED]
> Please verify before asserting: > > >>> a = [[1, 2], [3, 4]] > >>> b = a[1] > >>> b is a[1] > True > >>> id(b) > 46912496915448 > >>> id(a[1]) > 46912496915448 Right, I must have had slicing on the brain. -- http://mail.python.org/mailman/listinfo/python-list

Re: Interacting with a process that I ran with subprocess module

2006-06-09 Thread [EMAIL PROTECTED]
Well... I found pexpect as you said, but I also found that it doesn't work on windows. I need a cross-platform solution, as the program is going to run on several operating systems. Any other sugestion? Cheers! Diez B. Roggisch wrote: > [EMAIL PROTECTED] schrieb: > > Hi folk

More pythonic shell sort?

2006-06-09 Thread [EMAIL PROTECTED]
Disclaimer - I recognize this is not a practical exercise. There are many implementations around that would do the job better, more efficiently (Meaning in C) or whatever. I caught some thread about sorting and started thinking about shell sort and as part of my trying to pythonise my mind an

Re: More pythonic shell sort?

2006-06-09 Thread [EMAIL PROTECTED]
Fredrik Lundh wrote: > [EMAIL PROTECTED] wrote: > > > An aside - can anyone tell me where the use += and -= is documented? > > http://docs.python.org/ref/augassign.html > http://pyref.infogami.com/assignments > > Thanks!!! -- http://mail.python.org/mailman/listinfo/python-list

Re: __getattr__ question

2006-06-10 Thread [EMAIL PROTECTED]
Hello! > How can I determine if an attribute can be found in the usual places? print "item1" in dir(root) # False print "item3" in dir(root) # True Is it the behavior you wanted? -- http://mail.python.org/mailman/listinfo/python-list

Re: __getattr__ question

2006-06-10 Thread [EMAIL PROTECTED]
And yes, it is more to type ;) -- http://mail.python.org/mailman/listinfo/python-list

Re: os.link makes a copy, not a link

2006-06-10 Thread [EMAIL PROTECTED]
I had good results with os.symlink on Solaris, see http://docs.python.org/lib/os-file-dir.html Dan M wrote: > I'm a little bit confused. According to the sources I've looked at on the > net, > os.link('file1', 'file2') > should make a hard link from file1 to file2. But what I'm finding is that

Re: More pythonic shell sort?

2006-06-10 Thread [EMAIL PROTECTED]
Thanks for the critique. John Machin wrote: > On 10/06/2006 7:00 AM, [EMAIL PROTECTED] wrote: > > Disclaimer - I recognize this is not a practical exercise. There are > > many implementations around that would do the job better, more > > efficiently (Meaning in C) or whate

Re: Most elegant way to generate 3-char sequence

2006-06-10 Thread [EMAIL PROTECTED]
I'm not sure if you ever got a good answer. I for one am too lazy to look up the pages I found... but - check out http://aspn.activestate.com/ASPN/search?query=combinations§ion=PYTHONCKBK&type=Subsection Tons of nice recipes... Personally I liked the one that dynamically generated a nested functi

Re: "parent" in a class __init__ def?

2006-06-10 Thread [EMAIL PROTECTED]
I'm not sure how it's a comparison to class variables. So I wouldn't worry about that. I think there are some advantages to having the parent as an instance member. Intuitively, the name lookup on self.parent.foo would be faster than if you passed in the object in question - although I haven't t

ANN: Dao 1.0.0-alpha is released

2006-06-11 Thread [EMAIL PROTECTED]
Hello, It is a pleasure to announce in this mailing list the newly released Dao. This is the first release after the Dao interpreter being re-designed and re-implemented as a virtual register machine since the beginning of this year. There have been many great improvements on both the language and

Re: Function to remove elements from a list not working (corrected)

2006-06-12 Thread [EMAIL PROTECTED]
Girish Sahani wrote: > Hi, > I am trying to modify a list of pairs (l4) by removing those > pairs which are not present in a third list called pairList. > The following is a simplified part of the routine i have written. However > it does not give the correct output. Please help! > Its possible

logging magic

2006-06-12 Thread [EMAIL PROTECTED]
Hi everyone. I've just been trying to add a bit more granularity to my logging code, as the jump from INFO (level 20) to DEBUG (level 10) is a bit too big. I was thinking of borrowing a few levels from java: fine (18), finer (16) and finest(14). This is what I've tried: log = logging.getLogger(a

Re: "parent" in a class __init__ def?

2006-06-12 Thread [EMAIL PROTECTED]
bruno at modulix wrote: > [EMAIL PROTECTED] wrote: > (meta : please don't top-post) > > Intuitively, the name lookup on > > self.parent.foo would be faster than if you passed in the object in > > question > > > Each dot means doing a lookup in a namespace.

Re: TONIGHT! Lisp group beerfest in NYC, PyCells to be discussed

2006-06-13 Thread [EMAIL PROTECTED]
Ken Tilton wrote: > The royal We has just learned that His Kennyness will be honoring the > boozehounds of LispNYC with His Presence tonight (deets below). > > He will come bearing Celtk and news of PyCells, though the top billing > tonight goes to SoC student Extraordinaire Samantha Kleinberg. >

Re: Trace KeyboardInterrupt exception?

2006-06-15 Thread [EMAIL PROTECTED]
if you want to interrupt the code to find out where it is, you can instead connect to it in gdb and get the python traceback of each thread. if you're interested I'll post the necesary gdb-macro for that (didn't put it on the net yet) -- http://mail.python.org/mailman/listinfo/python-list

Re: Numerics, NaNs, IEEE 754 and C99

2006-06-15 Thread [EMAIL PROTECTED]
Nick Maclaren wrote: > ... > Now, I should like to improve this, but there are two problems. The > first is political, and is whether it would be acceptable in Python to > restore the semantics that were standard up until about 1980 in the > numerical programming area. I.e. one where anything tha

Re: Pycrypto

2006-06-16 Thread [EMAIL PROTECTED]
luca72 wrote: > Hello > I have to make an easy operation but reading the pycrypto doc. a never > see AES example > I have to cript this key 'ea523a664dabaa4476d31226a1e3bab0' with the > AES. > Can you help me for make it with pycrypto > > Regards Luca You can do this as follows: py> from Crypto.C

Re: Pycrypto

2006-06-16 Thread [EMAIL PROTECTED]
Laszlo Nagy wrote: > > You can do this as follows: > > > > py> from Crypto.Cipher import AES > > py> # key has to be 16, 24 or 32 bytes for AES > > py> crypt = AES.new('abcdefghijklmnop', AES.MODE_ECB) > > # we're lucky, the string to encrypt is a multiple of 16 in length > > py> txt = 'ea523a664d

copyfile avoiding overwrites and race conditions

2006-06-16 Thread [EMAIL PROTECTED]
Here is a code fragment, where I am trying to copy a file, avoiding overwrites and race conditions. The filename gets a '02','03','04' etc appended to the end if a file with that name already exists. I know the writing of the single space is overkill, but I am surprised I cannot find an example o

Re: any subway experiences

2006-06-17 Thread [EMAIL PROTECTED]
a wrote: > thanks for reading Their bread is awful. -- http://mail.python.org/mailman/listinfo/python-list

PyObject_SetItem(..) *always* requires a Py_INCREF or not?

2006-06-17 Thread [EMAIL PROTECTED]
I would think everytime you add an item to a list you must increase reference count of that item. http://docs.python.org/api/refcountDetails.html has an example that seems to contradict that int set_all(PyObject *target, PyObject *item) { int i, n; n = PyObject_Length(target); if

Re: maximum integer length?

2006-06-18 Thread [EMAIL PROTECTED]
nate wrote: > Hey everyone, > > I am trying to figure out what is the largest integer I can. Lets say > for 400 megabytes of memory at my disposal. > > I have tried a few things > c = 2**100 > d = 2**200 > print c**d > > Obviously I didn't have enough memory for that, but I was able to c**3

Re: Tetris

2006-06-19 Thread [EMAIL PROTECTED]
pygame.org is what you need it has tutorials it's cool -- http://mail.python.org/mailman/listinfo/python-list

Re: Installing Python on Windows Vista

2006-06-19 Thread [EMAIL PROTECTED]
Padraig wrote: > Hi all, > > Just a quick question... when I try to install Python on Windows Vista > Beta 2 the installer seems to hang after I select the destination > folder, saying that it will "return when it has finished calculating > disk space requirements". I just can't seem to get past t

Re: copyfile avoiding overwrites and race conditions

2006-06-19 Thread [EMAIL PROTECTED]
Larry Bates wrote: > I guess my approach would be different. To eliminate any race > conditions, I would keep a small text file that always contained > the next filename that is to be written. Something like: > > nextfiletowrite=/path/filename006.dat > > I would try to get a lock on this file, r

Overriding a function...

2006-06-19 Thread [EMAIL PROTECTED]
Suppose I have this module `mymodule.py' - # mymodule.py - begin def test(): print "original" # mymodule.py - end Now assume that I do this in some arbitrary module -> def override(): print "test is overridden" import mymodule mymodule.test = override Two questions - 1) If mymodule is

Re: Overriding a function...

2006-06-19 Thread [EMAIL PROTECTED]
[EMAIL PROTECTED] wrote: > Suppose I have this module `mymodule.py' - > > # mymodule.py - begin > def test(): > print "original" > # mymodule.py - end > > Now assume that I do this in some arbitrary module -> > > def override(): >

Re: Simple script to make .png thumbnails from .zip archive...

2006-06-20 Thread [EMAIL PROTECTED]
K P S wrote: > Thanks everyone. > routines to list all the files in a zip archive, but I don't see any to > list only the first, or only the second, etc. It doesn't look like If you can list all the files, then you can list only the first. :-) Don't worry about python internal allocation proced

Psyco performance

2006-06-20 Thread [EMAIL PROTECTED]
I'm not seeing much benefit from psyco (only 5-10% faster). Maybe this example is too trivial? Can someone give me some pointers as to what kind of code would see a dramatic benefit? Here's the code: import time import psyco n = 10 t1 = time.clock() l = list(range(0,n)) l2 = [x**2 for x in

Re: Psyco performance

2006-06-20 Thread [EMAIL PROTECTED]
> Place all the code in a function. Even without psyco you might get > somewhat better performances then. And I doubt psyco can optimise code > that isn't in a function anyway. > > And lastly, most of the code is probably spend computing x**2 which is > already optimised C code. I've changed the c

Re: need all python dialog equivalent

2006-06-20 Thread [EMAIL PROTECTED]
dialog binary is 110 KB. Won't it fit ? Eric S. Johansson wrote: > I'm creating a dialogue style interface for an application on a > dedicated system. All I have is basic Python 2.3. Is there anything > like an all Python dialog equivalent floating around? I'm currently > hacking away in curse

Re: Psyco performance

2006-06-21 Thread [EMAIL PROTECTED]
> > > Place all the code in a function. Even without psyco you might get > > > somewhat better performances then. And I doubt psyco can optimise code > > > that isn't in a function anyway. Another thing I wasn't considering is that the first call with psyco enabled might be slower. The 2nd time th

Re: returning index of minimum in a list of lists

2006-06-21 Thread [EMAIL PROTECTED]
[EMAIL PROTECTED] wrote: > Hi all, > Is there a simple python function to return the list index of the > minimum entry in a list of lists? > ie, for [[3,3,3,3], [3,3,3,1], [3,3,3,3]] to return 2,4. > Or, same question but just for a list of numbers, not a list of lists. >

Re: returning index of minimum in a list of lists

2006-06-21 Thread [EMAIL PROTECTED]
Thanks so much for your help. I was wondering if there was anything even simpler, but this will be great. [EMAIL PROTECTED] wrote: > [EMAIL PROTECTED] wrote: > > Hi all, > > Is there a simple python function to return the list index of the > > minimum entry in a list

Re: returning index of minimum in a list of lists

2006-06-22 Thread [EMAIL PROTECTED]
[EMAIL PROTECTED] wrote: > Hi all, > Is there a simple python function to return the list index of the > minimum entry in a list of lists? > ie, for [[3,3,3,3], [3,3,3,1], [3,3,3,3]] to return 2,4. > Or, same question but just for a list of numbers, not a list of lists. &

Standard names for common keyboard events

2006-06-22 Thread [EMAIL PROTECTED]
Hello, I thought that I should ask here for comments on a blog entry that I wrote some weeks ago. I am sure that other people have been thinking about this, but I didn't yet find them. The Python standard library unfortunately doesn't provide a module that gives unique names to common keyboard ev

Re: Network Programming in Python

2006-06-22 Thread [EMAIL PROTECTED]
[EMAIL PROTECTED] wrote: > I am a newbie in python. I want to learn and implement a small > networking concept. Please help me. Every help is appreciated. (hums the Batman Theme song replacing the words Batman with Google)... http://www.amk.ca/python/howto/sockets/ http://www.devshed.c

Re: Help req: Problems with MySQLdb

2006-06-23 Thread [EMAIL PROTECTED]
for x in range(self.MAX_CRAWL_THREADS+1): self.con.append( [MySQLdb.connect(host,username,passwor,database,PORT),0]) PORT is an extra argument you might not have perhaps rodmc wrote: > I have written an application that connects to a database on a remote > machine which uses MySQLdb 1.

Is there any good methods to read a encrypted password file?

2006-06-23 Thread [EMAIL PROTECTED]
Is there any good methods to read a encrypted password file? hi, all: I've a zipped file with a password . currently i use it by this method: $ unzip -p secret.zip | python my-pexpect.py but i want to remove the unzip -p secret.zip process. that is : $ python my-pexpect.py [whe py

Re: what exceptions may file() and read() throw?

2006-06-23 Thread [EMAIL PROTECTED]
Daniel Schüle wrote: > Hello, > > currently I am using this instance method > > def getFilecontent(self, filename): > try: > return file(filename).read() > except IOError, err_msg: > print err_msg >

Opening a file with system default application

2006-06-23 Thread [EMAIL PROTECTED]
I'm writing a GUI application in Jython which takes a database text file and performs some operations on the data, finally spitting out a group of CSV files. I generate a log file and several CSV files and I thought it would be helpful if I could add a button the user could click on to automatical

Re: Python in HTML

2006-06-23 Thread [EMAIL PROTECTED]
Bruno Desthuilliers wrote: > [EMAIL PROTECTED] wrote: > > Does anyone know of a way to embed python scripts into html, much like > > you would javascript or php? > > I think you'd better learn the profound difference between client-side > and server-side scriptin

Re: Beginner Programmer Question

2006-06-26 Thread [EMAIL PROTECTED]
Claudio Grondi wrote: > [EMAIL PROTECTED] wrote: > > I am doing alot of reading and trying to teach myself how to program. > > I can not figure out how to make "Write a program that continually > > reads in numbers from the user and adds them together until the sum >

Re: Beginner Programmer Question

2006-06-26 Thread [EMAIL PROTECTED]
[EMAIL PROTECTED] wrote: > Claudio Grondi wrote: > > [EMAIL PROTECTED] wrote: > > > I am doing alot of reading and trying to teach myself how to program. > > > I can not figure out how to make "Write a program that continually > > > reads in numbers from

Re: Beginner Programmer Question

2006-06-26 Thread [EMAIL PROTECTED]
Rune Strand wrote: > > > > I am doing alot of reading, and the problem didnt come with an answer. > > I dont understand how to get it to continually input numbers and add > > all those together > > Use while, raw_input, sys.argv[1] and int() and break the loop when the > sum is above 100. > > ;-)

Re: Beginner Programmer Question

2006-06-26 Thread [EMAIL PROTECTED]
Rune Strand wrote: > [EMAIL PROTECTED] wrote: > > Rune Strand wrote: > > > > > > > > I am doing alot of reading, and the problem didnt come with an answer. > > > > I dont understand how to get it to continually input numbers and add > > >

Re: Beginner Programmer Question

2006-06-26 Thread [EMAIL PROTECTED]
Tim Chase wrote: > > bigone = 100 > > > > number = input("Whats the first number?") > > number2 = input ("Whats the second number?") > > nu3 = number+number2 > > while nu3 < bigone: > > print ("Not there yet, next number please") > > > > print "Finally there!" > > > > thats what i thought mayb

Re: Find the context of importer

2006-06-26 Thread [EMAIL PROTECTED]
I find the answer to my own question. The inspect module have what I need. Here is the sample code: a.py import b print 'hello world from module a' b

Can I load and run modules inside threads....

2006-06-26 Thread [EMAIL PROTECTED]
and is it a good idea??? I am thinking of writing a controlling module - call it a postmaster if you will - that will start submodules and pass them work via queues - one input queue per module. The modules will send their results back to the postmaster via its queue. The postmaster will the

web Develop question

2006-06-28 Thread [EMAIL PROTECTED]
hi guys , I' m new to python ...and I would like to ask you , wich is the best template for developing dinamic generated pages using python ? I would like to use something easy to install and develop like php tags and with a lots of features . thanks in advance and sorry for this silly questio

Generator naming convention?

2006-06-28 Thread [EMAIL PROTECTED]
I use generators a lot. E.g. def gen_words(text) ... parse text ... yield each word in text for word in gen_words(text): print word I don't like the name gen_xxx() very much. Looking for some inspiration to name generators. Here are some of my ideas: enumerate_words gen_words gene

for and while loops

2006-06-28 Thread [EMAIL PROTECTED]
i was wondering if anyone could point me to some good reading about the for and while loops i am trying to write some programs "Exercise 1 Write a program that continually reads in numbers from the user and adds them together until the sum reaches 100. Write another program that reads 100 numbers

Re: Generator naming convention?

2006-06-28 Thread [EMAIL PROTECTED]
iter- clicks for me, thanks :) wy infidel wrote: > > Any idea? Do you have a naming convention for generators? > > Sometimes I use the prefix 'iter', like dictionaries have .items() and > .iteritems(). sometimes I use 'x', like range() vs. xrange(). You > could simply use 'i' like some of the

Re: web Develop question

2006-06-28 Thread [EMAIL PROTECTED]
Dear Luis , Thanks for your kindly answer , so you say that installing mod_python and a template like chetaah or dyango I can do like as I do with php and Apache ? < ? print ?> Thanks , regards Richard Luis M. González ha escrito: > [EMAIL PROTECTED] wrote: &g

Re: list comprehension

2006-06-30 Thread [EMAIL PROTECTED]
Andy Dingley <[EMAIL PROTECTED]> wrote: > Simon Forman wrote: > > > There's more to it, but that's the basic idea. > > This much I knew, but _why_ and _when_ would I choose to use list > comprehension (for good Python style), rather than using a simple > &

ANN: nose 0.9 released

2006-06-30 Thread [EMAIL PROTECTED]
I'm pleased to announce the release of nose 0.9. nose provides an alternate test discovery and running process for unittest, one that is intended to mimic the behavior of py.test as much as is reasonably possible without resorting to too much magic. nose can be installed via easy_install: easy_ins

Re: efficiency question

2006-06-30 Thread [EMAIL PROTECTED]
Fredrik Lundh wrote: > > when in doubt, ask the compiler: > > def code(x): > if x in ("abc", "def", "xyz"): > doStuff() > elif x in ("pqr", "tuv", "123"): > doOtherStuff() > > import dis > dis.dis(code) > > prints: > > 2 0 LOAD_FAST0 (x) >

Re: list comprehension

2006-07-01 Thread [EMAIL PROTECTED]
I found the Wiki article on list comprehensions useful for understanding the general concept. See it at: http://en.wikipedia.org/wiki/List_comprehension It talks about how a list comprehension can be thought of as equivalent to a traditional set-builder notation in math. For example in math notatio

Re: Immutability

2006-07-01 Thread [EMAIL PROTECTED]
That is why I don't like the use of @property. Even though the decorator is a nice short-hand notation, it is more confusing in my oppinion. So someone is more likely still call the property as a function when looking at: class C: @property def data(self): return 42 rather than if

Dictionary .keys() and .values() should return a set [with Python 3000 in mind]

2006-07-01 Thread [EMAIL PROTECTED]
This has been bothering me for a while. Just want to find out if it just me or perhaps others have thought of this too: Why shouldn't the keyset of a dictionary be represented as a set instead of a list? I know that sets were introduced a lot later and lists/dictionaries were used instead but I thi

Odd behavior with staticmethods

2006-07-01 Thread [EMAIL PROTECTED]
I'm getting rather inconsistent behavior with staticmethod. @staticmethod has the same problems, but I'm demonstrating it with staticmethod() because it shows things more clearly --- >>> class A: def orig(): print "hi"

Re: Dictionary .keys() and .values() should return a set [with Python 3000 in mind]

2006-07-01 Thread [EMAIL PROTECTED]
There's a few good reasons. 1 - golden handcuffs. Breaking old code is bad 90% of the time 2 - creating a set MAY be slower. Python's sets seem to imply to that they will always be a hash map. in this case, some creative hash map "mapping" could allow one to create a set without calculating hash

Re: I have 100 servers which need a new backup server added to a text file, and then the backup agent restarted.

2006-07-01 Thread [EMAIL PROTECTED]
I would sugest looking at http://pexpect.sourceforge.net/ The Expect metalanguage was specifically designed for the kind of things you are trying to do. I used it recently on a project to configure 25 instances of an application, remotly, half over ssh half over telnet. -- http://mail.python.or

Re: Odd behavior with staticmethods

2006-07-01 Thread [EMAIL PROTECTED]
sses. Anyone have a URL? Scott David Daniels wrote: > [EMAIL PROTECTED] wrote: > > I'm getting rather inconsistent behavior with staticmethod. > Not really. > > >>>> class A: > > def orig(): > > print "hi" > > s

Re: Odd behavior with staticmethods

2006-07-02 Thread [EMAIL PROTECTED]
THANK YOU! Now I can actually worry about the advantages/disadvantages! -- http://mail.python.org/mailman/listinfo/python-list

Python Challenge - thesamet unreachable?

2006-07-02 Thread [EMAIL PROTECTED]
If anyone has a way to contact thesamet, please tell him to check his private messages at the Python Challenge website; I have a couple of ideas for more challenges. Cheers all. -- http://mail.python.org/mailman/listinfo/python-list

Re: Can I do it using python?? about xterm and telnet

2006-07-02 Thread [EMAIL PROTECTED]
I used this _EXACT_ solution(copied below) at work a month ago, to start 20ish programs, each with different settings. In this case I HAD to use telnet for some of them, because they were on an embedded machine, 4 of them used SSH(across the internet), and the rest were local programs. It worked

Re: Can I do it using python?? about xterm and telnet

2006-07-03 Thread [EMAIL PROTECTED]
agreed, SSH is advisable over telnet in nearly all situations. However, there are a few times where telnet is better. 1. Embeded machines often have stripped down OS's. Telnet is much smaller and cheaper than a full blown SSH install. When every byte counts, you wont find SSH 2. He may have a pre

Re: I have 100 servers which need a new backup server added to a text file, and then the backup agent restarted.

2006-07-03 Thread [EMAIL PROTECTED]
Code - # assumes hosts is a list of hostnames for host in hosts: child = pexpect.spawn("ssh [EMAIL PROTECTED]" % host) child.expect ('Password:') child.sendline ("the correct root password") child.expect ('#') # root prompt

Re: Dictionary .keys() and .values() should return a set [with Python3000 in mind]

2006-07-03 Thread [EMAIL PROTECTED]
Yes, this is what he's saying. Its not "broken," just a bit different. After all, you dont have a problem with: lst = [1, 2, 3] ptr = lst lst.append(4) # this changes ptr And a "view" of the dictionary is orders faster than creating a copy of it (which is required to keep k0 from changing in you

Re: For a fast implementation of Python

2006-07-03 Thread [EMAIL PROTECTED]
ur code up. Bruno Desthuilliers wrote: > . wrote: > > What is the fast way for a fast implementation of Python? > > Please define "fast". > > -- > bruno desthuilliers > python -c "print '@'.join(['.'.join([w[::-1] for w in p.split('.

Re: how to stop python...

2006-07-03 Thread [EMAIL PROTECTED]
Wow, so many people with the same solution... where's the creativity folks? Whenever sys.exit() doesn't work for me, I find that a good solid thump on the side of the computer case with a large mallet tends to do the job. And there's always threatening the computer with a degaussing gun! -- htt

Re: Dictionary .keys() and .values() should return a set [with Python3000 in mind]

2006-07-03 Thread [EMAIL PROTECTED]
Ooh, can you point me to them? This sounds very interesting. The only way I can think of doing it is to have some fun with pointers and not make the final copy until a change is made to the table. I'd love to read about an algoritm which can get around this! I feel so behind in the times, I st

Re: sys.stdin and two CTRL-Ds

2006-07-03 Thread [EMAIL PROTECTED]
I may be wrong, but I've never heard of Windows being fully posix compliant. I guarentee you that they dont support pthreads. It is possible that by "posix compliant" the marketting execs mean "supports all posix commands which dont interfere with our way of doing things" Windows version of pyth

Re: No error while sending via TCP Socket

2006-07-03 Thread [EMAIL PROTECTED]
Q: I have been looking through Volume 1 & 2 on the topics of TCP timeouts. I have been looking in the section on "Timeout And Retransmission" where you talk about round trip times. My question to you would be what would make a tcp connection timeout? Is there a certain number of retries that need t

Problem when import C model

2006-07-03 Thread [EMAIL PROTECTED]
Hi, all I am learning how to import c code in python. Here is my simple code foo.c: = #include void bar() { printf("Hello! C wrap!"); } static PyObject *foo_bar(PyObject *self, PyObject *args) { /* Do something interesting here. */ bar(); Py_RETURN_NONE; } static PyMethod

Re: Problem when import C model

2006-07-03 Thread [EMAIL PROTECTED]
indicate this, and linux's library loading code will ignore it when loading libraries for 64-bit programs. I think there' might be a trick that lets you compile ELF files with both 64-bit and 32-bit code, but actually doing so is outside of my expertise. [EMAIL PROTECTED] wrote: > H

Re: Extending built-in objects/classes

2006-07-03 Thread [EMAIL PROTECTED]
My experiance is mostly with old-style classes, but here goes. first off, the question is actually easier than you think. After all, self is an instance of a string, so self[3:4] would grab the slice of characters between 3 and 4 =) as for __init__, what I have found is that if you do not incl

Re: Dictionary .keys() and .values() should return a set [withPython3000 in mind]

2006-07-03 Thread [EMAIL PROTECTED]
() created an independant list, python would first need to create a list, then create a set. Paul Rubin wrote: > "Delaney, Timothy (Tim)" <[EMAIL PROTECTED]> writes: > > If you want an independent data set, you have to take a snapshot. For > > the above, that's d

Re: Turning a callback function into a generator

2006-07-03 Thread [EMAIL PROTECTED]
Peter Otten wrote: > Kirk McDonald wrote: > > > Let's say I have a function that takes a callback function as a > > parameter, and uses it to describe an iteration: > > > > def func(callback): > > for i in [1, 2, 3, 4, 5]: > > callback(i) > > Which object is immutable? the callback

Re: Can I do it using python?? about xterm and telnet

2006-07-03 Thread [EMAIL PROTECTED]
I can get to my code on wednesday, I'll upload it somewhere you can get a copy of it. But do look into using SSH, because in the long run it is a far better tool. A properly configured SSHD also opens the way to scp. Without scp, copying files means ftp, or unsecured rsync. Do you want tabbed w

Re: list comprehension

2006-07-03 Thread [EMAIL PROTECTED]
I woulkdn't interate at the same time. zip takes two lists, and makes a single list of tuples, not the other way around. The easilest solution is feed_list = [ix.url for ix in feeds_list_select] feed_id = [ix.id for ix in feeds_list_select] Also, a big feature of list comprehension is it filters

built in zip function speed

2006-07-04 Thread [EMAIL PROTECTED]
I hope I am not being too ignorant :p but here goes... my boss has written a bit of python code and asked me to speed it up for him... I've reduced the run time from around 20 minutes to 13 (not bad I think ;) to speed it up further I asked him to replace a loop like this:- index = 0 for element

Re: built in zip function speed

2006-07-04 Thread [EMAIL PROTECTED]
Rune Strand wrote: > itertools.izip is usually faster than zip. You can try that. Thanks very much timing for itertools.izip for av, bv, cv, dv in itertools.izip(a, b, c, d): avbv = (av-bv) * (av - bv) diff = cv - dv e.append(diff - avbv) on a 4 million element aray: slice: 8.06299

Re: built in zip function speed

2006-07-04 Thread [EMAIL PROTECTED]
Steven D'Aprano wrote: > On Tue, 04 Jul 2006 07:18:29 -0700, [EMAIL PROTECTED] wrote: > > > I hope I am not being too ignorant :p but here goes... my boss has > > written a bit of python code and asked me to speed it up for him... > > I've reduced the run time fro

Re: built in zip function speed

2006-07-04 Thread [EMAIL PROTECTED]
Fredrik Lundh wrote: > [EMAIL PROTECTED] wrote: > > > ## just for a laugh my own zip function > > ## the joke is it runs faster than built in zip ?? > > since it doesn't do the same thing, it's not a very good joke. > > > def myzip(*args): &

Re: fonction in python

2006-07-04 Thread [EMAIL PROTECTED]
aliassaf wrote: > Hello, > > If we write = x^2 and if I give to the program the values of x, it will > going to calculate the values of y, and also for x. > > But it is possible ? that is if I give to the program the values of X and Y, > it will indicate to me the relation between the two variabl

PyList_Append requires explicit Py_INCREF after?

2006-07-05 Thread [EMAIL PROTECTED]
PyList_Append requires explicit Py_INCREF after? (I didn't see in docs where it said if appends a new reference or a borrowed reference like other APIs.) thanks! Chris -- http://mail.python.org/mailman/listinfo/python-list

<    13   14   15   16   17   18   19   20   21   22   >