Re: How do I not make a list?

2007-11-29 Thread Amit Khemka
rator or whatever it's called, with a passed in > operation? Well I think what you want is to use "()" instead of "[]" >>> l = (i for i in range(1,20)) >>> l Cheers, -- Amit Khemka -- http://mail.python.org/mailman/listinfo/python-list

Re: What is python?????

2007-11-17 Thread Amit Khemka
On 11/17/07, Cope <[EMAIL PROTECTED]> wrote: > > In our place we eat pythons for curry. Its delicious. > And how about your python? > > Cope Not much of the difference here, it is just a bit more flexible. My python goes and brings me whatever I wish to eat. Cheers, -- --

Re: manually cutting a picture

2007-11-08 Thread Amit Khemka
On 11/7/07, Cameron Walsh <[EMAIL PROTECTED]> wrote: > Amit Khemka wrote: > > > Cut image by "m X m" grid (bigger the m, the more varied shapes you > > would be able to generate), this will give you m*m square pieces. With > > each piece store a vector whic

Re: manually cutting a picture

2007-11-06 Thread Amit Khemka
uot; operations can be optimized calculating a factor "m*m/N" and doing all merges together. 2. You can also maintain a 'size' attribute with each piece, so that all the pieces generated are of approximately same size. Please let me know if you have other ideas. Cheers, -- -- Amit Khemka -- http://mail.python.org/mailman/listinfo/python-list

Re: Trouble with for loop

2007-11-06 Thread Amit Khemka
at each of the variables namely a, b, > c, ## can take value from 1 to 9. > How do I go about this ? An ugly code for it would be ;-) : for (a, b, c, d, e, f) in zip(*[range(1, 10)]*6): print a, b, c, d, e, f Cheers, -- -- Amit Khemka -- http://mail.python.org/mailman/listinfo/python-list

Re: Which persistence is for me?

2007-11-01 Thread Amit Khemka
nction (c.insert?). > > Is there some other interface/database that I might like better? Why you can always look at some "pure" database solutions. If persistence is all you require, have a look at "anydbm" and or "shelve" modules . Cheers, -- -- Amit Khemka -- http://mail.python.org/mailman/listinfo/python-list

Re: Lists and Sublists

2007-10-24 Thread Amit Khemka
age'] = ['line noise', 'cryptic'] > keywords['python'].append('readable') > To add you may want to have a look at "shelve" module , in case you want to store this object to a file. It can be useful if the data set is large and does not change frequently and you would want to save on some startup time . cheers, -- -- Amit Khemka -- http://mail.python.org/mailman/listinfo/python-list

Re: How can i protect text format ?

2007-10-23 Thread Amit Khemka
ine 1 hi line 2 how r u".. > How can i protect \n characters ? I don't think the issue has anything to do with python. I guess while you are displaying the text into an HTML page the "\n" characters should be replaced by "" to appear as newlines. Cheers, -- Amit Khemka -- http://mail.python.org/mailman/listinfo/python-list

Re: Iteration for Factorials

2007-10-22 Thread Amit Khemka
7;t it surprise you if the code that you posted goes in infinite loop ?! 2. why do you use condition: n < 100 3. How do you think that your function will calculate the factorial ? 4. Instead of "input" use "raw_input", and then "cast" the input as integer . Cheers, amit. -- -- Amit Khemka -- http://mail.python.org/mailman/listinfo/python-list

Re: Hi to every one

2007-10-22 Thread Amit Khemka
ches in my existed cluster at my college. Just > look for python development held in this area. > Hey i was active member of this from last 2 year, i had just changed my > email address. Have a look at : http://cheeseshop.python.org/pypi?%3Aaction=browse Cheers, -- Amit Khemka -- http://mail.

Re: vote for Python - PLEASE

2007-10-20 Thread Amit Khemka
ven if the poll results do not accurately reflect the intended purpose, they may be, just may be, give an idea of size of community and just how much that 'one' lie they will live with to see 'their' language ahead ;-) ! cheers, -- -- Amit Khemka -- http://mail.python.org/mailman/listinfo/python-list

Re: Order by value in dictionary

2007-10-18 Thread Amit Khemka
> backitems=heapq.nlargest(1000, backitems, operator.itemgetter(1)) > a=[ backitems[i][0] for i in range(0,len(backitems))] > a.reverse() > return a > Btw, there are specialized algorithms called "Selection Algorithms" for finding k largest items in a collection. http://en.wikipedia.org/wiki/Selection_algorithm Cheers, -- -- Amit Khemka -- http://mail.python.org/mailman/listinfo/python-list

Re: Best way to generate alternate toggling values in a loop?

2007-10-18 Thread Amit Khemka
> Rather than spelling out the final result, I'll give you hints: Look at > itertools.cycle and itertools.izip. > Why not just use enumerate ? clvalues = ["Even", "Odd"] for i, (id, name) in enumerate(result): stringBuffer.write(''' %d %s ''' % (clvalues[i % 2], id, name)) Cheers, -- -- Amit Khemka -- http://mail.python.org/mailman/listinfo/python-list

Re: importing modules question

2007-10-18 Thread Amit Khemka
ike this: import loadee if __name__ == "__main__": l = loadee.loadee() Alternatively you can directly import the objects defined in a module by : from loadee import loadee if __name__ == "__main__": l = loadee() cheers, -- -- Amit Khemka -- http://mail.python.org/mailman/listinfo/python-list

Re: easy but difficult

2007-10-16 Thread Amit Khemka
bc_file'): data = line.strip().split('#') # add the numbers to the 'alphabet' key as a list d[data[0]] = d.get(data[0], []) + [data[1]] Now you can just iterate over the dictionary and write it into a file Cheers, -- -- Amit Khemka -- http://mail.python.org/mailman/listinfo/python-list

Re: use lines as argument to a command

2007-10-15 Thread Amit Khemka
uting a linux command "dmesg>>stat.txt")? Since subprocess module allow you to call programs through (linux) shell , you can use the same syntax in your command. example: >>> from subprocess import call >>> call("echo foo >> bar.txt", shell=True) Cheers, -- -- Amit Khemka -- http://mail.python.org/mailman/listinfo/python-list

Re: use lines as argument to a command

2007-10-15 Thread Amit Khemka
gument. Have a look at subprocess module http://docs.python.org/lib/module-subprocess.html If there is some else that you meant, please specify . Cheers, -- -- Amit Khemka -- http://mail.python.org/mailman/listinfo/python-list

Re: Last value of yield statement

2007-10-10 Thread Amit Khemka
doing this please? > Well the basic trouble is that the yield statement you see there > causes it to print the list over and over again when a string > containing "msgid" is found and the subsequent conditions are > satisfied. I just want the last list the yield sta

Re: HELP me Am very new one To python

2007-10-04 Thread Amit Khemka
e that you like and suits your needs. If you still get struck , please post specific issues. I wish and hope learning python would be a pleasing experience ! Cheers, amit. -- Amit Khemka website: www.onyomo.com wap-site: www.owap.in -- http://mail.python.org/mailman/listinfo/python-list

Re: generating range of numbers

2007-10-03 Thread Amit Khemka
comprehension, for more have a look at http://docs.python.org/tut/node7.html#SECTION007140000 Cheers, -- Amit Khemka website: www.onyomo.com wap-site: www.owap.in -- http://mail.python.org/mailman/listinfo/python-list

Re: sorting a list numbers stored as strings

2007-09-24 Thread Amit Khemka
On 9/24/07, Carsten Haese <[EMAIL PROTECTED]> wrote: > On Mon, 2007-09-24 at 16:53 +0530, Amit Khemka wrote: > > On 9/24/07, [EMAIL PROTECTED] <[EMAIL PROTECTED]> wrote: > > > > >>> l = ["1", "11", "2", "22"]

Re: sorting a list numbers stored as strings

2007-09-24 Thread Amit Khemka
> Hi, >>> l = ["1", "11", "2", "22"] >>> sorted(l, cmp = lambda x, y: cmp(int(x), int(y))) # provide your own compare function ! >>> l ['1', '2', '11', '22'] Cheers, -- Amit Khemka website: www.onyomo.com wap-site: www.owap.in -- http://mail.python.org/mailman/listinfo/python-list

Re: global name is not defined - but this is actually a function's name

2007-09-20 Thread Amit Khemka
NavBut2.grid (row=10, column=25, padx=6, pady=6, columnspan=3) > #widget bindings > NavBut2.bind('', lambda e:GoPrev(ctr)) > > > > my problem is at the 6th line: showbuttons() > the error says "global name "showbuttons" is not de

Re: mass editing for keys in a dictionary

2007-09-14 Thread Amit Khemka
ne liner would be : >>> dict_2 = dict([(k.split('_')[0], v) for (k,v) in dict_1.iteritems()]) It would split the keys by '_' and use first part of split as the new key ! You must be aware be careful in cases where there are keys like 'customer_1' , 'cust

Re: Python and Cron

2007-09-08 Thread Amit Khemka
ut 2&>1 "2&>1", Is that a typo ? It should be "2>&1" . Are you *sure* that the cron job is running ? cheers, -- Amit Khemka website: www.onyomo.com wap-site: www.owap.in -- http://mail.python.org/mailman/listinfo/python-list

Re: Using wild character

2007-09-05 Thread Amit Khemka
x27;artica'] To know more about list comprehensions, have a look at: http://docs.python.org/tut/node7.html#SECTION00714 Methods on strings: http://docs.python.org/lib/string-methods.html#string-methods Btw, not all of names in your list are countries ! Cheers, -- Amit Khemka website: www.onyomo.com wap-site: www.owap.in -- http://mail.python.org/mailman/listinfo/python-list

Re: Looping through File Question

2007-09-05 Thread Amit Khemka
ow away) f.readline() a single time before > looping. > If the lenght of the first line is fixed, you can also use f.seek to start > reading from the second row. > > francesco Btw, if you are trying to read a csv file and parse it, you can save some work .. have a look at "c

Re: Printing lists in columns

2007-09-05 Thread Amit Khemka
This is an example of "generator" functions, to understand what they are and how they work you can: 1. web-search for "python generators" 2. have a look at "itertools" module, for more generators -- Amit Khemka website: www.onyomo.com wap-site: www.owap.in -- http://mail.python.org/mailman/listinfo/python-list

Re: TypeError: 'module object is not callable'

2007-09-04 Thread Amit Khemka
On 9/4/07, [EMAIL PROTECTED] <[EMAIL PROTECTED]> wrote: > On Sep 4, 11:24 am, "Amit Khemka" <[EMAIL PROTECTED]> wrote: > > On 9/4/07, [EMAIL PROTECTED] <[EMAIL PROTECTED]> wrote: > > > > > Thanks guys. Changing to how Python does things has a l

Re: TypeError: 'module object is not callable'

2007-09-04 Thread Amit Khemka
t is: >>> l = ['1', '2', '3', '4'] you can do: >>> print "\t".join(l) # lookup join method in string module, assuming "\t" as the delimiter or, >>> for i in l: print i, '\t' , # note the

Re: TypeError: 'module object is not callable'

2007-09-03 Thread Amit Khemka
On 9/3/07, Bruno Desthuilliers <[EMAIL PROTECTED]> wrote: > Amit Khemka a écrit : > (snip) > > The exception is being raised as you are being confused about the > > names ie: you have a class named "Step" in a module named "Step.py" . > > &g

Re: TypeError: 'module object is not callable'

2007-09-03 Thread Amit Khemka
;Step" defined IN the module "Step" example 2: from Step import Step # You directly import the class ( and make the name visible in your name space) a = Step("magn") Also have a look at: http://effbot.org/zone/import-confusion.htm http://docs.python.org/ref/import.html Cheers, -- Amit Khemka website: www.onyomo.com wap-site: www.owap.in -- http://mail.python.org/mailman/listinfo/python-list

Re: for statement on empty iterable

2007-08-21 Thread Amit Khemka
lly I was thinking how do I > access the index inside a for statement? Can you help Have a look at "enumerate", You can iterate over a list like: for i,x in enumerate(['a', 'b', 'c']): print i, x It prints: 0 a 1 b 2 c cheers, amit Amit Khemka

Re: Logging module gives duplicate log entries

2007-08-21 Thread Amit Khemka
remove the handler once you are done applog.removeHandler(hdl) Cheers, amit. Amit Khemka website: www.onyomo.com wap-site: www.owap.in Home Page: www.cse.iitd.ernet.in/~csd00377 Endless the world's turn, endless the sun's Spinning, Endless the quest; I turn again, back to my own b

Re: Filtering content of a text file

2007-07-27 Thread Amit Khemka
27;) for line in file("myrecords.txt"): # iterate over the records if line.startswith("//-+"+alnum): # check your condition # write the matches to a file outfile.write(line) outfile.close() However rather than looping over the file for each alnum you

Re: Fetching a clean copy of a changing web page

2007-07-16 Thread Amit Khemka
ags" in the XML May be you can use the above to check the xml and catch the "bogus" ones ! cheers, -- Amit Khemka website: www.onyomo.com wap-site: www.owap.in Home Page: www.cse.iitd.ernet.in/~csd00377 Endless the world's turn, endless the sun's Spinning, Endle

Re: import

2007-07-06 Thread Amit Khemka
ogging up my python directory Yes. You can tell python where all to look for importing modules. import sys sys.path.append("/this/is/my/modules/path") > Thanks Welcome ! cheers, -- Amit Khemka website: www.onyomo.com wap-site: www.owap.in Home Page: www.cse.iitd.ernet.

Re: Split file into several and reformat

2007-06-21 Thread Amit Khemka
... >1299} > End sels > > And turn it into an output file for each of the "sels" in the input file, i.e > sel1.txt: Once you have read Bruno's pointers ! Have a look at http://aspn.activestate.com/ASPN/Cookbook/Python/Recipe/521877 cheers, --

Re: Newbie help understanding...

2007-05-26 Thread Amit Khemka
cards = [] for card in file(filename): cards.append(cards.split()) # i assume that suit and rank is separated by white space return cards or better still cards = [card.split() for card in file(filename)] Cheers, Amit Khemka -- onyomo.com Home Page: www.cse.iitd.ernet.in/~csd00377 Endless the world's turn, endless the sun's Spinning, Endless the quest; I turn again, back to my own beginning, And here, find rest. -- http://mail.python.org/mailman/listinfo/python-list

Re: Xml parser

2007-05-25 Thread Amit Khemka
On 5/24/07, ashish <[EMAIL PROTECTED]> wrote: > Hi All, > > I want to know weather is there any api available in python for parsing > xml(XML parser) Checkout cElementTree . Cheers, -- Amit Khemka -- onyomo.com Home Page: www.cse.iitd.ernet.in/~csd00377 Endless the wor

Re: Web Archtecture using tow layers in Phyton

2007-05-24 Thread Amit Khemka
t (example)... i don't know if this is > possible and how can this be implemented... any help is aprreciated... Read the documentation of the framework ( if any) you choose to work with you may find templating system useful. For standalone app you can look at wxPython, which can communicate to you

Re: Changing Unicode object to Tuple Type

2007-05-24 Thread Amit Khemka
n that tuple ?! Or do you want to store the unicode string as one of the member in a tuple ? In which case you can just do it the obvious way (though i guess thats not the question you asked)! Cheers, Amit Khemka -- onyomo.com Home Page: www.cse.iitd.ernet.in/~csd00377 Endless the world's

Re: function nested

2007-05-24 Thread Amit Khemka
nd(path) > else: > f1(path) > f1(start) > return stack > > > i feel s stupid right now > forgot to call f1 > > any comments how to make this better? os.walk is just the way for you ! Cheers, Amit Khemka -- onyomo.com Home Page: www.cse.

Re: how to use imaageop.scale

2007-05-24 Thread Amit Khemka
On 23 May 2007 18:58:28 -0700, Bruce <[EMAIL PROTECTED]> wrote: > On May 23, 5:31 pm, "Amit Khemka" <[EMAIL PROTECTED]> wrote: > > On 23 May 2007 00:02:34 -0700, Bruce <[EMAIL PROTECTED]> wrote: > > > > > Hi, I want to compress a jpg file. e.g.

Re: how to use imaageop.scale

2007-05-23 Thread Amit Khemka
his? Thanks! Were there any exceptions/error-messasges ? Do you jpeg libraries installed for hadling jpeg format ? Cheers, -- Amit Khemka -- onyomo.com Home Page: www.cse.iitd.ernet.in/~csd00377 Endless the world's turn, endless the sun's Spinning, Endless the quest; I turn again, b

Re: How to generate a continuous string

2007-04-16 Thread Amit Khemka
str = mychar*n n: Integer (number of times you want to duplicate) Cheers, -- Amit Khemka -- onyomo.com Home Page: www.cse.iitd.ernet.in/~csd00377 Endless the world's turn, endless the sun's Spinning, Endless the quest; I turn again, back to my own beginning, And here, find rest.

Re: newbie question: how to read back the dictionary from a file?

2007-04-16 Thread Amit Khemka
", then > loop read a int, then read a ":", then a float etc etc... Since it is > written out with standard python builtin functions, I guess there may > be some more direct method than this, say a function in some modules? > Could someone give me a hint? &g

Re: Storing of folder structure in SQL DB

2007-04-05 Thread Amit Khemka
On 4/5/07, Amit Khemka <[EMAIL PROTECTED]> wrote: > On 5 Apr 2007 04:58:22 -0700, Sergei Minayev <[EMAIL PROTECTED]> wrote: > An Example: > > import os > root='/my/root/directory' > id =0 > tree={root:(-1, id)} > id+=1 > for path, dirs,

Re: Storing of folder structure in SQL DB

2007-04-05 Thread Amit Khemka
th+'/'+dir]=(tree[path][1], id) id+=1 It stores ids as a tuple (parent_id, id) in a dictionary(tree). Should be straight forward to modify to your requirements. Also you can make the following code more efficient by saving/caching some lookups ! Cheers, --

Re: how to remove multiple occurrences of a string within a list?

2007-04-04 Thread Amit Khemka
tance of '0024' is removed. To remove all items with multiple occurances in myList: list(set(myList) - set([x for x in myList if myList.count(x)>1])) cheers, -- Amit Khemka -- onyomo.com Home Page: www.cse.iitd.ernet.in/~csd00377 Endless the world's turn, endless the sun

Re: Question about text in Python

2007-04-02 Thread Amit Khemka
uot;__main__": userinp=raw_input("Query>") while userinp: callmyabbrvfunction(userinp) userinp=raw_input("Another Query>") print "Exit: You have entered empty string !" cheers, -- Amit Khemka -- onyomo.com Home Page: www.cse.iitd.ernet.in/~c

Re: os.system questions

2007-03-31 Thread Amit Khemka
test variable for "up", I don't get this script to > actually run. Everything else is tested and works. Why won't this script > run? os.system doesn't allow you to get the output of the program, use os.popen instead. example: import os up = os.popen('uptime'

Re: Weird behavior in search in a list

2007-03-29 Thread Amit Khemka
num' not the smallest greater value in the list. cheers, -- Amit Khemka -- onyomo.com Home Page: www.cse.iitd.ernet.in/~csd00377 Endless the world's turn, endless the sun's Spinning, Endless the quest; I turn again, back to my own beginning, And here, find rest. -- http://mail.python.org/mailman/listinfo/python-list

Re: Weird behavior in search in a list

2007-03-29 Thread Amit Khemka
> On 29 Mar 2007 04:51:00 -0700, Su Y <[EMAIL PROTECTED]> wrote: > > I want find the first number in extend[] which is larger than num, so > On 3/29/07, Amit Khemka <[EMAIL PROTECTED]> wrote: > Btw a concise way could be: > def getfirstbigger(num): >

Re: Weird behavior in search in a list

2007-03-29 Thread Amit Khemka
d to 'break' when once the condition is met. def find(num): count=0 for elem in extend: if elem>num: break else: count+=1 return count Btw a concise way could be: def getfirstbigger(num): for i,x in enumerate(extend): if x>num:

Re: XML Parsing

2007-03-28 Thread Amit Khemka
called filecreate.xml > > As you might have guessed, I want to create files from this XML file > contents, so how can I do this? > What modules should I use? What options do I have? Where can I find > tutorials? Will I be able to put > this on the internet (on a googlepages ser

Re: converting epoch time to string (and vice versa)

2007-03-12 Thread Amit Khemka
epochs = calendar.timegm((t[2], t[1], t[0], 0, 0, 0)) > Im also trying to convert that epoch time to the string format > previously. Can anyone help this one too? import time time.ctime(epochs) cheers, amit. -- Amit Khemka -- onyomo.com Home Page: www.cse.iitd.ernet.in/~csd0037

Re: Dictionary of Dictionaries

2007-03-05 Thread Amit Khemka
wo']['124'] = 4 > > This gives: > > {'two': {'121': 2, '123': 1, '124': 4}, 'one': {'121': > 2, '123': 1, '124': 4}} And hence the results ! HTH, --

Re: How to find out if another process is using a file

2007-01-19 Thread Amit Khemka
http://www.physiol.ox.ac.uk/Computing/Online_Documentation/lsof-quickstart.txt cheers, -- Amit Khemka -- onyomo.com Home Page: www.cse.iitd.ernet.in/~csd00377 Endless the world's turn, endless the sun's Spinning, Endless the quest; I turn again, back to my own beginning, And here,

Re: Explanation about for loop

2007-01-11 Thread Amit Khemka
On 11 Jan 2007 20:48:19 -0800, raghu <[EMAIL PROTECTED]> wrote: > can any one help me explaining for loop and its execution and its > syntax with a simple example. Well Guido did that: http://docs.python.org/tut/node6.html#SECTION00620 -- Amit Khemka -- ony

Re: trouble getting google through urllib

2006-12-19 Thread Amit Khemka
import urllib2 req = urllib2.Request('http://www.google.com') # add 'some' user agent header req.add_header('User-Agent', 'Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.7.8) Gecko/20050524 Fedora/1.5 Firefox/1.5') up = urllib2.urlopen(req) cheers, amit -- ---

Re: catching exceptions

2006-12-16 Thread Amit Khemka
return statement in functions with two arguments. for example: def foo(self, value): try: a.x = value return True, '' except ValueError: return False, 'Float conversion error: %s' %(value) and when ever u call the function, check the first return va

Re: convert from date string to epoch

2006-12-15 Thread Amit Khemka
tup = map(int,date.split('/')) l = (tup[2], tup[0], tup[1], 0, 0, 0) epochs = calendar.timegm(l) return (int(epochs)) HTH, amit. -- Amit Khemka -- onyomo.com Home Page: www.cse.iitd.ernet.in/~csd00377 Endless the world's turn, endless the sun's Spin

Re: how can i change the text delimiter

2006-08-31 Thread Amit Khemka
t csv # standard csv module distributed with python inputFile = "csv_file_with_pipe_as_quotchar.txt" reader = csv.reader(open(inputFile), quotechar='|') for row in reader: # do what ever you would like to do cheers, amit. Amit Khemka -- onyomo.com Home Page: www.

Re: all ip addresses of machines in the local network

2006-08-31 Thread Amit Khemka
python code. ( In my network "nmap -osscan_limit -p 22 -T5 Class_D_Network" completes in 1.5 seconds !) cheers, amit. -- Amit Khemka -- onyomo.com Home Page: www.cse.iitd.ernet.in/~csd00377 Endless the world's turn, endless the sun's Spinning, Endless the quest; I turn again, back to my own beginning, And here, find rest. -- http://mail.python.org/mailman/listinfo/python-list

Re: how can i change the text delimiter

2006-08-30 Thread Amit Khemka
On 8/30/06, Amit Khemka <[EMAIL PROTECTED]> wrote: > sonald <[EMAIL PROTECTED]> wrote: > > Hi, > > Can anybody tell me how to change the text delimiter in FastCSV Parser > > ? > > By default the text delimiter is double quotes(") > > I want to chan

Re: how can i change the text delimiter

2006-08-30 Thread Amit Khemka
go about it? You can use the parser constructor to specify the field seperator: Python >>> parser(ms_double_quote = 1, field_sep = ',', auto_clear = 1) cheers, amit. -- Amit Khemka -- onyomo.com Home Page: www.cse.iitd.ernet.in/~csd00377 Endless the world's turn, endles

Re: all ip addresses of machines in the local network

2006-08-24 Thread Amit Khemka
On 8/24/06, Amit Khemka <[EMAIL PROTECTED]> wrote: > On 23 Aug 2006 21:46:21 -0700, damacy <[EMAIL PROTECTED]> wrote: > > hi, sandra. > > > > no, it's not as complicated as that. all i want to do is to load a > > database onto different machines residin

Re: all ip addresses of machines in the local network

2006-08-24 Thread Amit Khemka
a particular network service, to allow you to "distribute the database". In such case you can use "nmap" with -p option, to find all the machines which are listening on the particular port. hth, amit. Amit Khemka -- onyomo.com Home Page: www.cse.iitd.ernet.in/~csd00377

Re: find, replace and save string in ascii file

2006-08-23 Thread Amit Khemka
er you want changes to the NAME and then write the 'block' to a temperory file. If you want the output to be written to same file just 'move' this temperory file to the input file once you are done. Note: if there is other stuff in the input file, apart from such 'blo

Re: Help with async xmlrpc design

2006-08-16 Thread Amit Khemka
n submitting a request, client-server agree upon a port on which client will listen for the results. 2. Registering a callback function. (Googling would point to more elaborate discussions on pros and cons ) cheers, amit. Amit Khemka -- onyomo.com Home Page: www.cse.iitd.ernet.in/~csd00377 E

Re: How to change the path for python binary?

2006-08-10 Thread Amit Khemka
uot;python" in the shell? There could be various ways of doing so, like: Option 1: open your shell preference file ( ex. for bash ~/.bashrc) and add an alias: alias python="/path/to/python/version/of/your/choise" Option 2: make /usr/local/bin/python a symlink to python2.3.5 cheers

Re: Running queries on large data structure

2006-08-04 Thread Amit Khemka
nsidered using some native XML database like BDB XML. 1. It allows you to retain hierarchical structure of data. 2. It also has support for precompiled queries. 3. You can open a persistent connection. cheers, amit. -- Amit Khemka -- onyomo.com Home Page: www.cse.iitd.ernet.in/~csd0037

Re: using globals

2006-08-03 Thread Amit Khemka
a python module "t1.py". And its very logical that all the (global) variables in "t1.py" have the value which one would expect after execution of the "t1.py" otherwise. And hence you see value of counter as 1. (or in other words you are accessing two different instan

Re: PIL issues

2006-07-31 Thread Amit Khemka
2.0: "clean" the PIL build 2.1 In setup.py that comes with PIL, set the JPEG_ROOT to the jpeg-lib path 3.0 run setup.py I hope that should help .. cheers, amit -- Amit Khemka -- onyomo.com Home Page: www.cse.iitd.ernet.in/~csd00377 Endless the world's turn, endless the

Re: how to safely extract dict values

2006-07-31 Thread Amit Khemka
oops ! my mistake :-D On 7/31/06, Bruno Desthuilliers <[EMAIL PROTECTED]> wrote: > Amit Khemka wrote: > > how about: > > > > vals = [] > > for val in mydict.values(): > > try: vals.extend(val) > > except: vals.append(val) > > >>> l

Re: how to safely extract dict values

2006-07-31 Thread Amit Khemka
vals = [] for val in mydict.values(): try: vals.extend(val) except: vals.append(val) cheers, amit. -- Amit Khemka -- onyomo.com Home Page: www.cse.iitd.ernet.in/~csd00377 Endless the world's turn, endless the sun's Spinning, Endless the quest; I turn again, back to my own beginning, And here, find rest. -- http://mail.python.org/mailman/listinfo/python-list

Re: import a user created python file as module

2006-07-30 Thread Amit Khemka
sys sys.path.append("/path/to/Base") import file1 cheers, amit. -- Amit Khemka -- onyomo.com Home Page: www.cse.iitd.ernet.in/~csd00377 Endless the world's turn, endless the sun's Spinning, Endless the quest; I turn again, back to my own beginning, And here, find rest. -- http://mail.python.org/mailman/listinfo/python-list

Re: Encode filenames to safe format

2006-07-20 Thread Amit Khemka
On 7/20/06, Dara Durum <[EMAIL PROTECTED]> wrote: > Hi ! > > I want to encode filenames to safe format, like in browser url (space -> > %20, etc.). > What the module and function name that helps me in this project ? > import urllib urllib.quote('file name'

Re: Activate a daemon several times a day

2006-07-06 Thread Amit Khemka
if now(hours) in runat: > act() > sleep(60) > sleep(10) > > > Please enlighten me! > > Best regards, > Yves > -- > http://mail.python.org/mailman/listinfo/python-list > -- Amit Khemka -- onyomo.com Home Page: www.cse.iitd.ernet.

Re: ElementTree : parse string input

2006-07-06 Thread Amit Khemka
t; method. Btw, did you looked at cElementTree module ? It claims to be much 'faster' and has very similar api as ElementTree Module. link: http://effbot.org/zone/celementtree.htm cheers, amit. -- Amit Khemka -- onyomo.com Home Page: www.cse.iitd.ernet.in/~csd00377 Endless t

Re: Generating multiple lists from one list

2006-07-06 Thread Amit Khemka
> objects and 1,3,4,2 are their instance ids and they are unique e.g. a.1 > and b.1 cannot exist together. From this list i want to generate > multiple lists such that each list must have one and only one instance of > every object. > Thus, for the above list, my output should be:

Re: starting and stopping a program from inside a python script

2006-07-04 Thread Amit Khemka
n script exits, the process 'bar' is > still running and I have to issue ps -ef | grep 'bar' and then kill > it. > > Is there any better way of doing this? > > -- > http://mail.python.org/mailman/listinfo/python-list > -- Amit Khemka -- onyomo.com Home

Import: Multiple modules with same name

2006-06-29 Thread Amit Khemka
) return module But It looked like an overkill, Is there a more elegant and better way of doing it ? Thanks in advance, cheers, amit. -- Amit Khemka -- onyomo.com Home Page: www.cse.iitd.ernet.in/~csd00377 Endless the world's turn, endless the sun's Spinning, Endless the quest; I

Re: Logging to a file and closing it again properly (logging module)

2006-06-14 Thread Amit Khemka
g.Logger.manager.loggerDict.values(): > .>>> l.handlers = [] You can "close" the logger by just removing the handler from the logging object # first creater a logger and file handler fooLogger = logging.getLogger('FOO') fooLogger.setLevel(logging.INFO)

Re: reading files in small chunks?

2006-04-14 Thread Amit Khemka
? > > Thank You. It has basically to do with disk seeks and cache+memory utilization. and you can look around for the same for details on any of your fav search engine. cheers, amit. > > -- > http://mail.python.org/mailman/listinfo/python-list > > -- Amit Khemka -- o

Re: Splitting a string with extra parameters

2006-04-06 Thread Amit Khemka
ectory. Why don't you try that > way? > Reading some help gives more details of its use. > > F > -- > http://mail.python.org/mailman/listinfo/python-list > -- Amit Khemka -- onyomo.com Home Page: www.cse.iitd.ernet.in/~csd00377 Endless the world's turn

Re: Does anyone know where is the Berkeley XML Database documentation for its Python API?

2006-04-04 Thread Amit Khemka
for project engineering. Are they added or fixed in > the lastest version of BSBXML? > > > Thank you for help. > > -- > http://mail.python.org/mailman/listinfo/python-list > -- Amit Khemka -- onyomo.com Home Page: www.cse.iitd.ernet.in/~csd00377 Endless the world's

ordered sets operations on lists..

2006-02-10 Thread Amit Khemka
. -- Amit Khemka -- onyomo.com Endless the world's turn, endless the sun's Spinning, Endless the quest; I turn again, back to my own beginning, And here, find rest. -- http://mail.python.org/mailman/listinfo/python-list

Re: Unable to get PIL to load jpeg images

2006-02-08 Thread Amit Khemka
gt; > -- > Andrew Gwozdziewycz <[EMAIL PROTECTED]> > http://ihadagreatview.org > http://plasticandroid.org > -- > http://mail.python.org/mailman/listinfo/python-list > -- Amit Khemka -- onyomo.com Endless the world's turn, endless the sun's Spinning, Endless the quest; I turn again, back to my own beginning, And here, find rest. -- http://mail.python.org/mailman/listinfo/python-list

Re: Timeout at command prompt

2006-01-12 Thread Amit Khemka
Another thing that can be tried is: import threading a="" def input(): global a a = raw_input() T = threading.Thread(target=input) T.start() T.join(2) ## does the trick ... I have not tested it but i guess should work. cheers, amit. On 1/12/06, Amit Khemka <[EM

Re: Timeout at command prompt

2006-01-12 Thread Amit Khemka
I tried it on "Python 2.4.1" on '2.6.11-1.1369_FC4smp with gcc version 4.0.0' .. which works fine .. may be it could be an issue with some other combinations .. cheers, amit On 12 Jan 2006 07:35:57 -0800, Paul Rubin <"http://phr.cx"@nospam.invalid> wrote: >

Re: Timeout at command prompt

2006-01-12 Thread Amit Khemka
its "Python 2.4.1" .. on linux On 12 Jan 2006 06:34:08 -0800, Thierry Lam <[EMAIL PROTECTED]> wrote: > Is there a windows equivalent for that solution? > > -- > http://mail.python.org/mailman/listinfo/python-list > -- Endless the world's turn, endless the sun's spinning Endless the quest; I

Re: How can I create a dict that sets a flag if it's been modified

2006-01-12 Thread Amit Khemka
Ideally, I would have made a wrapper to add/delete/modify/read from the dictionay. But other than this, one way i can think straight off is to "pickle" the dict, and to see if the picked object is same as current object. cheers, amit. On 12 Jan 2006 01:15:38 -0800, [EMAIL PROTECTED] <[EMAIL PROT

Re: Timeout at command prompt

2006-01-11 Thread Amit Khemka
One way would be to use 'signal' s ... something like this should work import signal TIMEOUT = 5 # number of seconds your want for timeout signal.signal(signal.SIGALRM, input) signal.alarm(TIMEOUT) def input(): try: foo = raw_input() return foo except: # timeout return cheers, amit.

Re: writing IM bots

2005-12-14 Thread Amit Khemka
t; lot back. > http://twistedmatrix.com/projects/words/ > > Good Luck! > Linsong > > > Amit Khemka wrote: > > >Hello, > >I am trying to write an IM Bot, which automatically replies to a > >message, in Python. > >I was wondering If there are python modul

writing IM bots

2005-12-13 Thread Amit Khemka
Hello, I am trying to write an IM Bot, which automatically replies to a message, in Python. I was wondering If there are python modules for connecting to Yahoo!, msn networks ... ideally I would like to have a multithreaded module. This is one I found for msn, if anyone has used it please comment,

Re: matching a string to extract substrings for which somefunctionreturns true

2005-11-22 Thread Amit Khemka
thanks for you suggestions :-) .. cheers, On 11/23/05, Fredrik Lundh <[EMAIL PROTECTED]> wrote: > I wrote: > > > if you cannot cache session data on the server side, I'd > > recommend inventing a custom record format, and doing your > > own parsing. turning your data into e.g. > > > >"foo:1:

Re: matching a string to extract substrings for which some functionreturns true

2005-11-22 Thread Amit Khemka
<[EMAIL PROTECTED]> wrote: > Amit Khemka wrote: > > > Well actually the problem is I have a list of tuples which i cast as > > string and then put in a html page as the value of a hidden variable. > > And when i get the string again, i want to cast it back as lis

Re: matching a string to extract substrings for which some function returns true

2005-11-22 Thread Amit Khemka
, 2, 'foobar1', (3, 1)), ('foo2', 2, 'foobar2', (3, 2))" output: [('foo', 1, 'foobar', (3, 0)), ('foo1', 2, 'foobar1', (3, 1)), ('foo2', 2, 'foobar2', (3, 2))] I hope that explains it better... cheers,

  1   2   >