Re: How to add few pictures into one
All that I want is this: I download ( via Python) some pictures from internet and I want to add all these pictures into one =one file/ So far, I managed to download pictures but I do not know how to add i them nto one file. How can I do that? Thank you for reply and help L. Zip file? Image file? Add all these pictures into one file isn't (fro me) a sufficient specification. I want to to do that as easy as possible. I think the easest way could be add( append) an image to another into an image file so that I can use an image browser and see all pictures in one file. Is that possible? Thank you for reply L. -- http://mail.python.org/mailman/listinfo/python-list
Re: Reading from a file and converting it into a list of lines
Really sorry for that indentation thing :) I tried out the code you have given, and also the one sreeram had written. In all of these,i get the same error of this type: Error i get in Sreeram's code is: n1,_,n2,_ = line.split(',') ValueError: need more than 1 value to unpack And error i get in your code is: for n1, a1, n2, a2 in reader: ValueError: need more than 0 values to unpack Any ideas why this is happening? Thanks a lot, girish -- http://mail.python.org/mailman/listinfo/python-list
Re: C# equivalent to range()
Fuzzyman wrote: Well, this is true. Doesn't make it a *good* thing of course... :-) on the other hand, the rules for what works and doesn't on public forums have been finely tuned for many years. that's why the rules don't apply to me people like Lee, Neuruss, and others get the kind of pushback they're getting. and frankly, their approach doesn't work in real life, so what makes you think it would work on the internet? /F -- http://mail.python.org/mailman/listinfo/python-list
Re: Again, Downloading and Displaying an Image from the Internet in Tkinter
Le Mardi 06 Juin 2006 03:08, Dustan a écrit : I should probably also mention, the only reason I downloaded the image to a file was because I don't know of any other way to do it. I feel no need to save the image to my hard drive. using PIL, there is something like this (untested) : (assuming you have put your image data in a file-like object, ie. a StringIO, named self._dled_img) Label(self.frame, image=TkImage(Image.open(self._dled_img))) -- _ Maric Michaud _ Aristote - www.aristote.info 3 place des tapis 69004 Lyon Tel: +33 426 880 097 -- http://mail.python.org/mailman/listinfo/python-list
Python.h
Hi, I am running python to c converter application. It throws an error saying python.h file not found. Can somebody plz suggest how to resolve this problem. Regards, Praveen Kumar -- http://mail.python.org/mailman/listinfo/python-list
Re: OT: unix newbie questions
Carlos Lopez wrote: Please help i am losing my mind ... UNIX Newbee *23. How do you add a line to the end of an existing file myfile with date stamp. (1) * f = open(myfile, a+) f.write(datestamp) f.close() *24. Display recent 10 java files, (with *.java extension) , in descending order by time, latest to oldest time. (1) * files = sorted(glob.glob(*.py), key=os.path.getmtime)[-10:] files.reverse() *25. How do you set only read permissions to user, group and others in octal mode for a file myfile.txt ? (2) os.chmod(myfile.txt, 0444) # note the leading zero *26. You observed that some of your group members are fiddling with your file myfile and you wanted to remove the read permission to your group. How do you do? (1) os.chmod(myfile.txt, 0404) *28. Here is another long listing of a file. (1)* -rw-r- 1 Y435678 odms 20 Sep 02 17:03 file.txt. *** *What are the owner permissions? * s = os.stat(urllib.py).st_mode if s stat.S_IREAD: print READ if s stat.S_IWRITE: print WRITE if s stat.S_IEXEC: print EXEC *29. The file “users_data” has the following contents : (1) Tom Smith 7.00 15 105.00 Rob Sheryl 8.00 20 160.00 Ken Bradman 7.00 13 91.00 Peter Smith 6.00 15 90.00 Dennis Smith 8.00 13 104.00 Tom Dave9.00 12 108.00 * *How do you sort the above file and redirect the output to another file called “sortedusers” * out = open(sortedusers, w) out.writelines(sorted(open(users_data))) *20. What is the command to list files in a directory : (2) os.listdir(directory) or, if you want full path names and glob-style filtering: glob.glob(os.path.join(directory, *)) /F -- http://mail.python.org/mailman/listinfo/python-list
Writing to a certain line?
I was wondering if there was a way to take a txt file and, while keeping most of it, replace only one line. See, I'd have a file like: Tommy 555 Bob 62 Joe 529 And I'd want to set it to be: Tommy 555 Bob 66 Joe 529 Is there any easy way to do this? -- http://mail.python.org/mailman/listinfo/python-list
Re: OT: unix newbie questions
Fredrik Lundh wrote: *24. Display recent 10 java files, (with *.java extension) , in descending order by time, latest to oldest time. (1) * files = sorted(glob.glob(*.py), key=os.path.getmtime)[-10:] files.reverse() (to display the files, use print) /F -- http://mail.python.org/mailman/listinfo/python-list
Re: Python.h
[EMAIL PROTECTED] wrote: I am running python to c converter application. It throws an error saying python.h file not found. Can somebody plz suggest how to resolve this problem. you need the python build files. if you're using Linux, look for something named python-dev or python-devel in your favourite package repository. /F -- http://mail.python.org/mailman/listinfo/python-list
Re: OT: unix newbie questions
Le Mardi 06 Juin 2006 08:36, Fredrik Lundh a écrit : *26. You observed that some of your group members are fiddling with your file myfile and you wanted to remove the read permission to your group. How do you do? (1) os.chmod(myfile.txt, 0404) rather, os.chmod(myfile.txt, 0400) I guess. or maybe you want something like this : import os, stat os.chmod(myfile.txt, os.stat(myfile.txt).st_mode - stat.S_IRGRP) -- _ Maric Michaud _ Aristote - www.aristote.info 3 place des tapis 69004 Lyon Tel: +33 426 880 097 -- http://mail.python.org/mailman/listinfo/python-list
python socket proxy
Hi all I am trying to create a lighweight tcp proxy server. I got this code from ActivePython documentation. What I am trying to accomplish, is I need to connect to local instance of the proxyserver (127.0.0.1). This server must then connect to a remote jabber server, send data, and listen to incoming data. When data arrives, it must relay it back thru 127.0.0.1. The reason why I need I am trying to get this to work, is I eventually want to make this server connect over ssl/tls (which macromedia flash doesnt support natively). The existing code only echoes back what it gets in, and note what it gets back from the remote server. Help would be appreciated [code] # Echo server program import socket HOST = '127.0.0.1' # Symbolic name meaning the local host PORT = 50007 # Arbitrary non-privileged port s = socket.socket(socket.AF_INET, socket.SOCK_STREAM) s.bind((HOST, PORT)) s.listen(1) conn, addr = s.accept() print 'Connected by', addr while 1: data = conn.recv(1024) print (data) if not data: break conn.send(data) conn.close() # Echo client program import socket HOST = 'remoteserver.com'# The remote host PORT = 5222 # The same port as used by the server s = socket.socket(socket.AF_INET, socket.SOCK_STREAM) s.connect((HOST, PORT)) s.send('Hello, world') data = s.recv(1024) print data s.close() print 'Received', repr(data) [/code] thanks -- http://mail.python.org/mailman/listinfo/python-list
Re: Reading from a file and converting it into a list of lines
On 6/06/2006 4:15 PM, Girish Sahani wrote: Really sorry for that indentation thing :) I tried out the code you have given, and also the one sreeram had written. In all of these,i get the same error of this type: Error i get in Sreeram's code is: n1,_,n2,_ = line.split(',') ValueError: need more than 1 value to unpack And error i get in your code is: for n1, a1, n2, a2 in reader: ValueError: need more than 0 values to unpack Any ideas why this is happening? In the case of my code, this is consistent with the line being empty, probably the last line. As my mentor Bruno D. would say, your test data does not match your spec :-) Which do you want to change, the spec or the data? You can change my csv-reading code to detect dodgy data like this (for example): for row in reader: if not row: continue # ignore empty lines, wherever they appear if len(row) != 4: raise ValueError(Malformed row %r % row) n1, a1, n2, a2 = row In the case of Sreeram's code, perhaps you could try inserting print line = , repr(line) before the statement that is causing the error. Thanks a lot, girish -- http://mail.python.org/mailman/listinfo/python-list
Re: How to add few pictures into one
Lad wrote: I want to to do that as easy as possible. But not even more easy. I think the easest way could be add( append) an image to another into an image file so that I can use an image browser and see all pictures in one file. Is that possible? Well, you can do it with PIL, creating a very big white image and putting on it all the images, as tiles. But probably you want to do something different. Maybe you can use PyUNO to create a PowerPoint-like (Presentation) file with an image on each page. If you are on Win another easy way is to create an Html page that shows all the pics, open it with Explorer and save it as a single HMT file. Probably there are other solutions. Bye, bearophile -- http://mail.python.org/mailman/listinfo/python-list
RE: embedding Python in COM server loaded with win32com
Hi, when you are running in Python the PyInitialize() is not called and therefore you don't have a valid threadstate since the call in win32com uses the standard idiom Py_BEGIN_ALLOW_THREADS() CallComServer Py_END_ALLOW_THREADS() You could use PyNewInterpreter to get a valid state, but this won't work in Python greater version 2.2, since with the new GILState API does not allow more than one interpreter per thread. You could work around the problem if you would use a localserver instead of an inproc server. With that you would always have a clean process for your server. Stefan -Original Message- From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] On Behalf Of Fozzie Sent: Monday, June 05, 2006 3:57 PM To: python-list@python.org Subject: embedding Python in COM server loaded with win32com Hi, I have a problem which is quite circular, and hopefully either someone has encountered something similar or has a reason why this will not work. We have a COM library providing mathematics to various systems, most functions are hard-coded but we want to embed a scripting language to allow arbitrary functions to be used in the numeric engines within the library, and am using Python for this. This seems to work fine called from standalone apps, and from VB, however, Python scripts, which access the scripts via win32com.client fail in the embedding code in C++ whenever I attempt to call PyImport_AddModule. As a concrete example, consider the following minimal interface, (created using an ATL project in VC7), which has a single property, the user supplied script, and a single function 'findRoot', which in this case is nothing more than an indicator that the embedding worked, - STDMETHODIMP CMinEmbed::get_script(BSTR* pVal) { USES_CONVERSION; *pVal = SysAllocString(A2OLE(__script.c_str())); return S_OK; } STDMETHODIMP CMinEmbed::put_script(BSTR newVal) { USES_CONVERSION; __script = std::string( OLE2A( newVal)); return S_OK; } STDMETHODIMP CMinEmbed::findRoot(DOUBLE* root) { std::string progress; PyObject * main, * globals, * res, * func; try { progress = calling PyInitialize; if(!Py_IsInitialized()) Py_Initialize(); progress = get __main__ module; main = PyImport_AddModule(__main__); progress = get __main__module dictionary; globals = PyModule_GetDict(main); progress = Run the script.; res = PyRun_String(__script.c_str(), Py_file_input, globals, globals); progress = Get the function from main dictionary.; func = PyDict_GetItemString(globals, func); progress = test function, and return indicator; if(NULL != func PyCallable_Check(func)) { *root = 1.0; } else { *root = -1.0; } progress = clean up; Py_XDECREF(res); Py_Finalize(); return S_OK; } catch(...) { // SetFailString just sets the ISupportErrorInfo interface SetFailString(IID_IMinEmbed, progress.c_str()); return E_FAIL; } } - When I build my server with the above method and run it at the Python interpretor I get, from win32com.client import Dispatch s = Dispatch('minServer.MinEmbed') s.script = 'def func(x) : return x*x' s.findRoot() Traceback (most recent call last): File stdin, line 1, in ? File COMObject minServer.MinEmbed, line 2, in findRoot File i:\\Python24\lib\site-packages\win32com\client\dynamic.py, line 251, in _ApplyTypes_ result = self._oleobj_.InvokeTypes(*(dispid, LCID, wFlags, retType, argTypes) + args) pywintypes.com_error: (-2147352567, 'Exception occurred.', (0, None, 'Failure to get main module', None, 0, -2147467259), None) However, works fine from VB and standalone apps. Is this approach even doable? Thanks in advance Dave Foster -- http://mail.python.org/mailman/listinfo/python-list -- http://mail.python.org/mailman/listinfo/python-list
Re: C# equivalent to range()
That's because many of them have killfiled you. I actually wonder whether anyone does use killfiles. I just can''t imagine the sort of person who writes plonk or welcome to my killfile etc could bear to miss out on a reply to such a post in case there's more to get angry about! And people who are not riled enough by a post to comment on it probably would'nt be fired up enough to bother killfiling either... -- http://mail.python.org/mailman/listinfo/python-list
Re: C# equivalent to range()
Erik Max Francis enlightened us with: The other zilion persons who were not interested (other than the four I mentioned above) silently and peacefully ignored the question on went on with their happy lifes. That's because many of them have killfiled you. I can say that I didn't killfile him. I just peacefully ignored the question and went on with my happy life - I simply don't know anything about C#. Sybren -- The problem with the world is stupidity. Not saying there should be a capital punishment for stupidity, but why don't we just take the safety labels off of everything and let the problem solve itself? Frank Zappa -- http://mail.python.org/mailman/listinfo/python-list
Re: Writing to a certain line?
Tommy B: I was wondering if there was a way to take a txt file and, while keeping most of it, replace only one line. You'd need to read the file and parse it, to find the start position of the line you want to change. Then seek output to that position and write and flush the changes. You must keep the file locked during this operation, to prevent other processes from changing the file in between these steps. You can only replace a string with a string of the same length. http://docs.python.org/lib/bltin-file-objects.html -- René Pijlman -- http://mail.python.org/mailman/listinfo/python-list
Checking var is a number?
Hi, I am very new to all this and need to know how to check a variable to see if it is a number or not. Also can anyone recommend a reference book apart from dive into python preferably a reference with good examples of how to impliment code. The project i have been given to work in is all CGI written in Python. Many Thanks David Phillips -- http://mail.python.org/mailman/listinfo/python-list
Re: Writing to a certain line?
Tommy B wrote: I was wondering if there was a way to take a txt file and, while keeping most of it, replace only one line. meta This is a FAQ (while I don't know if it's in the FAQ !-), and is in no way a Python problem. FWIW, this is also CS101... /meta You can't do this in place with a text file (would be possible with a fixed-length binary format). The canonical way to do so - whatever the language, is to write the modified version in a new file, then replace the old one. import os old = open(/path/to/file.txt, r) new = open(/path/to/new.txt, w) for line in old: if line.strip() == Bob 62 line = line.replace(62, 66) new.write(line) old.close() new.close() os.rename(/path/to/new.txt, /path/to/file.txt) If you have to do this kind of operation frequently and don't care about files being human-readable, you may be better using some lightweight database system (berkeley, sqlite,...) or any other existing lib that'll take care of gory details. Else - if you want/need to stick to human readable flat text files - at least write a solid librairy handling this, so you can keep client code free of technical cruft. HTH -- bruno desthuilliers python -c print '@'.join(['.'.join([w[::-1] for w in p.split('.')]) for p in '[EMAIL PROTECTED]'.split('@')]) -- http://mail.python.org/mailman/listinfo/python-list
Re: the most efficient method of adding elements to the list
alf wrote: Hi, Would it be .append()? Does it reallocate te list with each apend? l=[] for i in xrange(n): l.append(i) dumb FWIW, you'd have the same result with: l = range(n) /dumb More seriously (and in addition to other anwsers): you can also construct a list in one path: l = [i for i in xrange(n)] or if you want operations and conditionals : l = [trasform(i) for i in xrange(n) if match_some_cond(i)] HTH -- bruno desthuilliers python -c print '@'.join(['.'.join([w[::-1] for w in p.split('.')]) for p in '[EMAIL PROTECTED]'.split('@')]) -- http://mail.python.org/mailman/listinfo/python-list
Re: Checking var is a number?
[EMAIL PROTECTED] írta: Hi, I am very new to all this and need to know how to check a variable to see if it is a number or not. Also can anyone recommend a reference book apart from dive into python preferably a reference with good examples of how to impliment code. There are different types of number in Python. Integers and Long integers (type: 'int', 'long') Decimal numbers (class 'decimal.Decimal') Floating point numbers (type 'float') You can check this way: import decimal def print_type(var): if isinstance(var,int): print this is an integer elif isinstance(var,long): print this is a long integer elif isinstance(var,decimal.Decimal): print this is a decimal elif isinstance(var,float): print this is a float else: print this is something else... Test this: ... print_type(12) this is an integer print_type(12L) this is a long integer print_type(3.5) this is a float print_type('hello world') this is something else... print_type('44') this is something else... d = Decimal('123') print_type(d) this is a decimal The project i have been given to work in is all CGI written in Python. Probaby you wanted to convert a string into a number? For example: int(s) 1234 s = 'Foo' int(s) Traceback (most recent call last): File stdin, line 1, in ? ValueError: invalid literal for int(): Foo Or you can catch the exception: s = 'Foo2' try: ... intval = int(s) ... except ValueError: ... print This cannot be converted to an int. ... This cannot be converted to an int. Good luck! Laszlo -- http://mail.python.org/mailman/listinfo/python-list
Re: Checking var is a number?
[EMAIL PROTECTED] wrote: I am very new to all this and need to know how to check a variable to see if it is a number or not. assuming that variable means string object and number means integer, you can use the isdigit predicate: if var.isdigit(): print all characters in, var, are digits if you want to check for anything that can be converted to a float, the best way is to do the conversion and trap any ValueError that may occur: try: value = float(var) except ValueError: print not a valid float if you want an integer instead, replace float with int. if you had something else in mind, let us know. Also can anyone recommend a reference book apart from dive into python preferably a reference with good examples of how to impliment code. you can find an extensive list of available books here: http://wiki.python.org/moin/PythonBooks some on-line code collections: http://aspn.activestate.com/ASPN/Python/Cookbook/ http://effbot.org/zone/librarybook-index.htm and don't forget the core references: http://docs.python.org/lib/ http://docs.python.org/ref/ /F -- http://mail.python.org/mailman/listinfo/python-list
Re: python socket proxy
[EMAIL PROTECTED] wrote: Hi all I am trying to create a lighweight tcp proxy server. [...] There is a bunch of nice recipies in the Python Cookbook on port forwarding. In the [1] and [2] case it should be fairly simple to add an extra authentication step with pyOpenSSL. [1] http://aspn.activestate.com/ASPN/Cookbook/Python/Recipe/483730 [2] http://aspn.activestate.com/ASPN/Cookbook/Python/Recipe/114642 [3] http://aspn.activestate.com/ASPN/Cookbook/Python/Recipe/483732 best, fw -- http://mail.python.org/mailman/listinfo/python-list
Re: Checking var is a number?
Good luck! Laszlo I actually managed to get it sorted but i like that way of doing it much better actually :) Cheers David P -- http://mail.python.org/mailman/listinfo/python-list
Re: How to add few pictures into one
[EMAIL PROTECTED] wrote: Lad wrote: I want to to do that as easy as possible. But not even more easy. I think the easest way could be add( append) an image to another into an image file so that I can use an image browser and see all pictures in one file. Is that possible? Well, you can do it with PIL, creating a very big white image and putting on it all the images, as tiles. But probably you want to do something different. Maybe you can use PyUNO to create a PowerPoint-like (Presentation) file with an image on each page. If you are on Win another easy way is to create an Html page that shows all the pics, open it with Explorer and save it as a single HMT file. Probably there are other solutions. I was thinking about much less complicated task. I thought about this: Open a picture file( download it from internet) and write it in a result file( being open in binary mode). Then download another file and append to the result file. And so on... But is it possible? Will be the pictures in the result file seen well?? regards, L. -- http://mail.python.org/mailman/listinfo/python-list
Re: Checking var is a number?
I took a variable to mean a container for diffirent kinds of information either strings or integers etc, as i am mainly a asp, php, asp.net developer. Thanks for the list of references, that will come in very handy Cheers Guys David P -- http://mail.python.org/mailman/listinfo/python-list
Re: Writing to a certain line?
bruno at modulix wrote: meta This is a FAQ (while I don't know if it's in the FAQ !-), and is in no way a Python problem. FWIW, this is also CS101... /meta feel free to repost your response here: http://pyfaq.infogami.com/suggest /F -- http://mail.python.org/mailman/listinfo/python-list
Re: Writing to a certain line?
bruno at modulix: You can't do this in place with a text file (would be possible with a fixed-length binary format). More precise: it's possible with any fixed-length change, in both binary and text files, with both fixed and variable formats. -- René Pijlman -- http://mail.python.org/mailman/listinfo/python-list
Re: Checking var is a number?
[EMAIL PROTECTED] wrote: I took a variable to mean a container for diffirent kinds of information either strings or integers etc, as i am mainly a asp, php, asp.net developer. in python, a variable is a name that refers to a specific object. it's the object that has a type and a value, not the variable. this article might be somewhat helpful: http://effbot.org/zone/python-objects.htm /F -- http://mail.python.org/mailman/listinfo/python-list
Re: How to add few pictures into one
Lad wrote: Open a picture file( download it from internet) and write it in a result file( being open in binary mode). Then download another file and append to the result file. And so on... But is it possible? Will be the pictures in the result file seen well?? the internal structure of an image file is quite a bit more complicated than the internal structure of a text file, so it's not very likely that you would get very far with that approach. why not just put all the files in a directory, and use an image viewer with collage or slideshow support ? /F -- http://mail.python.org/mailman/listinfo/python-list
Re: check for dictionary keys
John Machin wrote: On 5/06/2006 10:46 PM, Bruno Desthuilliers wrote: [EMAIL PROTECTED] a écrit : hi in my code, i use dict(a) to make to a into a dictionary , a comes from user input, so my program does not know in the first place. Then say , it becomes a = { '-A' : 'value1' , '-B' : value2 , -C : value3 , '-D' : 'value4' } somewhere next in my code, i will check for these..: 1) -A and -B cannot exist together 2) -A and -C cannot exist together 3) -A and -B and -D cannot exist together 4) and lots of other combinations to check for Looks like an option parser... If so, there's all you need in the standard lib (look for the optparse module). how can i efficiently check for the above? At first as i do simple checks , i use if and else. But as i began to check for more combinatoiuns, it gets messy First : use boolean logic (truth table, Kernaugh diagram, etc) to simplify things. As an example, rule #3 is useless - it's a subset of rule #1 (-A and -B and -D implies -A and -B). This should greatly reduce the number of needed tests. Good idea, but doesn't scale well. Does it need to scale ? If there are lot of rules and frequently changing, yes, automating the process will be a good idea - but if it's about a program options, just using one's brain might be enough. At least it forces one to think about what's going on... Simple code can weed out redundant rules, Simple code can weed out redundant *simple* rules !-) (snip) Then, write a simple rule system describing either valid inputs or invalid inputs (preferably the smallest set !-). FWIW, it can be as simple as a list of lambdas/error messages pairs, with lambdas being predicate taking dict keys as params: _RULES = [ (lambda keys : '-A' in keys and '-B' in keys, can't have both options -A and -B), (lambda keys : '-A' in keys and '-C' in keys, can't have both options -A and -C), # etc... ] The evil HR director won't let the PHB pay me on a per LOC basis, so I've had to come up with a compact table-driven approach :-) otI'm my own evil HR director and PHB !-)/ot Don't like table-driven programming, John ? This solution takes very few lines, and while it's surely not a full-blown rule engine, it's at least reasonably flexible. (Not to say it's better than yours - it's of course a matter of effective use case). def validate(options, rules): keys = options.keys() for predicate, message in rules: if not predicate(keys): raise ValueError(message) C:\junktype option_combos.py bad_combos = ['ABD', 'AC', 'AB', 'CA'] def rule_compaction(bc_list, verbose=False): # The next few lines are admittedly oldfashioned :-) bc_sets = [set(x) for x in bc_list] deco = [(len(y), y) for y in bc_sets] deco.sort() bc_sets = [z[1] for z in deco] del deco if verbose: print bc_sets #1:, bc_sets for k in xrange(len(bc_sets)-1, 0, -1): candidate = bc_sets[k] for ko in bc_sets[:k]: if ko = candidate: if verbose: print candidate, knocked out by, ko del bc_sets[k] break if verbose: print bc_sets #2:, bc_sets return bc_sets Nice code - but how does it handle more complex predicates ? Seems you can only deal with 'and' rules here. nitpickDoesn't scale well, you said ?-)/nitpick (snip) -- bruno desthuilliers python -c print '@'.join(['.'.join([w[::-1] for w in p.split('.')]) for p in '[EMAIL PROTECTED]'.split('@')]) -- http://mail.python.org/mailman/listinfo/python-list
Re: Writing to a certain line?
Rene Pijlman wrote: bruno at modulix: You can't do this in place with a text file (would be possible with a fixed-length binary format). More precise: it's possible with any fixed-length change, in both binary and text files, with both fixed and variable formats. Granted. But this is somewhat limited in what you can do when working with text files... -- bruno desthuilliers python -c print '@'.join(['.'.join([w[::-1] for w in p.split('.')]) for p in '[EMAIL PROTECTED]'.split('@')]) -- http://mail.python.org/mailman/listinfo/python-list
Re: How to add few pictures into one
Fredrik Lundh wrote: Lad wrote: Open a picture file( download it from internet) and write it in a result file( being open in binary mode). Then download another file and append to the result file. And so on... But is it possible? Will be the pictures in the result file seen well?? the internal structure of an image file is quite a bit more complicated than the internal structure of a text file, so it's not very likely that you would get very far with that approach. why not just put all the files in a directory, and use an image viewer with collage or slideshow support ? Fredrik, Thank you for your reply. I really would like to have ALL pictures in one file. So, what would be the easiest/best way how to do that? Thank you for your reply regards, L. -- http://mail.python.org/mailman/listinfo/python-list
Re: is it possible to find which process dumped core
if your core is from a python program you can check what file/function was running use this gdb macro: define pbt set $i = 0 set $j = 0 while $i 1000 select $i if $eip = PyEval_EvalFrame if $eip PyEval_EvalCodeEx echo c frame # p $i echo py frame # p $j set $j = $j+1 x/s ((PyStringObject*)f-f_code-co_filename)-ob_sval x/s ((PyStringObject*)f-f_code-co_name)-ob_sval echo line # p f-f_lineno end end set $i = $i+1 end end document pbt show python backtrace macro by yairchu based on pyframe macro by jeremy hylton end works on python2.4 here but not 100% sure it will always work. it has some nasty hack. you can also see where each of the threads was by choosing the wanted thread in gdb I'll post my useful gdb macros to the web sometime soon -- http://mail.python.org/mailman/listinfo/python-list
Re: check for dictionary keys
On 6/06/2006 8:38 PM, bruno at modulix wrote: John Machin wrote: On 5/06/2006 10:46 PM, Bruno Desthuilliers wrote: [EMAIL PROTECTED] a écrit : hi in my code, i use dict(a) to make to a into a dictionary , a comes from user input, so my program does not know in the first place. Then say , it becomes a = { '-A' : 'value1' , '-B' : value2 , -C : value3 , '-D' : 'value4' } somewhere next in my code, i will check for these..: 1) -A and -B cannot exist together 2) -A and -C cannot exist together 3) -A and -B and -D cannot exist together 4) and lots of other combinations to check for Looks like an option parser... If so, there's all you need in the standard lib (look for the optparse module). how can i efficiently check for the above? At first as i do simple checks , i use if and else. But as i began to check for more combinatoiuns, it gets messy First : use boolean logic (truth table, Kernaugh diagram, etc) to simplify things. As an example, rule #3 is useless - it's a subset of rule #1 (-A and -B and -D implies -A and -B). This should greatly reduce the number of needed tests. Good idea, but doesn't scale well. Does it need to scale ? If there are lot of rules and frequently changing, yes, automating the process will be a good idea - but if it's about a program options, just using one's brain might be enough. At least it forces one to think about what's going on... Simple code can weed out redundant rules, Simple code can weed out redundant *simple* rules !-) (snip) Then, write a simple rule system describing either valid inputs or invalid inputs (preferably the smallest set !-). FWIW, it can be as simple as a list of lambdas/error messages pairs, with lambdas being predicate taking dict keys as params: _RULES = [ (lambda keys : '-A' in keys and '-B' in keys, can't have both options -A and -B), (lambda keys : '-A' in keys and '-C' in keys, can't have both options -A and -C), # etc... ] The evil HR director won't let the PHB pay me on a per LOC basis, so I've had to come up with a compact table-driven approach :-) otI'm my own evil HR director and PHB !-)/ot ot You must have some interesting conversations with yourself !-) /ot Don't like table-driven programming, John ? I love table-driven programming. You seem to misunderstand; In this case the bad combos list *is* the table. This solution takes very few lines, and while it's surely not a full-blown rule engine, it's at least reasonably flexible. (Not to say it's better than yours - it's of course a matter of effective use case). [snip] Nice code - but how does it handle more complex predicates ? Seems you can only deal with 'and' rules here. More complex predicates are not in the OP's spec ... this is a defence I learned from somebody in this newsgroup recently :-) nitpickDoesn't scale well, you said ?-)/nitpick I understand 'scale' to relate to size, not to complexity. Cheers, John -- http://mail.python.org/mailman/listinfo/python-list
Re: How to add few pictures into one
Lad wrote: I really would like to have ALL pictures in one file. So, what would be the easiest/best way how to do that? do you want to look at the images as a slideshow or as a collage? /F -- http://mail.python.org/mailman/listinfo/python-list
Re: How to add few pictures into one
Lad wrote: I really would like to have ALL pictures in one file. import Image def merge_images( input_files, output_file ) : img_list = [Image.open(f) for f in input_files] out_width = max( [img.size[0] for img in img_list] ) out_height = sum( [img.size[1] for img in img_list] ) out = Image.new( 'RGB', (out_width,out_height) ) y = 0 for img in img_list : w,h = img.size out.paste( img, (0,y,w,y+h) ) y += h out.save( output_file ) Use like this: merge_images( ['1.jpg','2.jpg','3.jpg'], 'output.jpg' ) Regards Sreeram signature.asc Description: OpenPGP digital signature -- http://mail.python.org/mailman/listinfo/python-list
10GB XML Blows out Memory, Suggestions?
I wrote a program that takes an XML file into memory using Minidom. I found out that the XML document is 10gb. I clearly need SAX or something else? Any suggestions on what that something else is? Is it hard to convert the code from DOM to SAX? -- http://mail.python.org/mailman/listinfo/python-list
Distutils: setup script for binary files
Hi. I want to create setup script, that will install compiled extension module plus few binaries the extension module depends on. For example: I have package X: X: __init__.py _x_.dll ( or so ) some other dll's ( so's ) _x_.dll depends on. I took a look on Python documentation, http://docs.python.org/dist/describing-extensions.html, but it only describes how to create setup script for extension module from source files. I think, I can treat _x_.dll as it was regular Python script. My problem is, that on Linux I should put some other so's in some directory, program loader can find. How can I do this? Any help is appreciated. Thanks -- Roman Yakovenko C++ Python language binding http://www.language-binding.net/ -- http://mail.python.org/mailman/listinfo/python-list
Re: 10GB XML Blows out Memory, Suggestions?
[EMAIL PROTECTED]: I wrote a program that takes an XML file into memory using Minidom. I found out that the XML document is 10gb. I clearly need SAX or something else? Any suggestions on what that something else is? PullDOM. http://www-128.ibm.com/developerworks/xml/library/x-tipulldom.html http://www.prescod.net/python/pulldom.html http://docs.python.org/lib/module-xml.dom.pulldom.html (not much) -- René Pijlman -- http://mail.python.org/mailman/listinfo/python-list
Re: 10GB XML Blows out Memory, Suggestions?
[EMAIL PROTECTED] wrote: I wrote a program that takes an XML file into memory using Minidom. I found out that the XML document is 10gb. I clearly need SAX or something else? More memory;) Maybe you should have a look at pulldom, a combination of sax and dom: it reads your document in a sax-like manner and expands only selected sub-trees. Any suggestions on what that something else is? Is it hard to convert the code from DOM to SAX? Assuming a good design of course not. Esp. if you only need some selected parts of the document SAX should be your choice. Mathias -- http://mail.python.org/mailman/listinfo/python-list
Re: 10GB XML Blows out Memory, Suggestions?
[EMAIL PROTECTED] schrieb: I wrote a program that takes an XML file into memory using Minidom. I found out that the XML document is 10gb. I clearly need SAX or something else? Any suggestions on what that something else is? Is it hard to convert the code from DOM to SAX? Yes. You could used elementtree iterparse - that should be the easiest solution. http://effbot.org/zone/element-iterparse.htm Diez -- http://mail.python.org/mailman/listinfo/python-list
Vectorization
Hi! Need to vectorize this, but do not have a clue. a = n*m matrix x and y are n and m vectors Suggestions? def fill(a, x, y): for i in range(1,a.shape[0]): xp = x[i] for j in range(a.shape[1]): yp = y[j] a[i,j] = sin(xp*yp)*exp(-xp*yp) + a[i-1,j] return a Thanks in advance, Ronny Mandal -- http://mail.python.org/mailman/listinfo/python-list
Re: Expanding Search to Subfolders
Thanks, that was a big help. It worked fine once I removed os.chdir(C:\\Python23\\programs\\Magazine\\SamplesE) and changed for file, st in DirectoryWalker(.): to for file in DirectoryWalker(.): (removing the st) -- http://mail.python.org/mailman/listinfo/python-list
Re: Expanding Search to Subfolders
Thanks everyone! -- http://mail.python.org/mailman/listinfo/python-list
Re: 10GB XML Blows out Memory, Suggestions?
[EMAIL PROTECTED] wrote: I wrote a program that takes an XML file into memory using Minidom. I found out that the XML document is 10gb. With a 10gb file, you're best bet might be to juse use Expat and C!! Regards Sreeram signature.asc Description: OpenPGP digital signature -- http://mail.python.org/mailman/listinfo/python-list
cxFreeze executable linked to /usr/lib/libpython2.3.so
Hi, I compiled a python script using cxFreeze because I need a standalone application, while the Windows version runs without any python installation the linux version of the executable is linked to libpython2.3.so.1.0 = /usr/lib/libpython2.3.so.1.0 thus the end user have to install python 2.3 in order to run the binary. I would like to know if it's possible, using cxFreeze to create a binary that is not linked to any python system library, for example by putting the library in the directory where the binary file is located. Thank Ale -- http://mail.python.org/mailman/listinfo/python-list
Re: How to add few pictures into one
Fredrik Lundh wrote: Lad wrote: I really would like to have ALL pictures in one file. So, what would be the easiest/best way how to do that? do you want to look at the images as a slideshow or as a collage? /F As a collage only -- http://mail.python.org/mailman/listinfo/python-list
Re: Writing to a certain line?
bruno at modulix wrote: Else - if you want/need to stick to human readable flat text files - at least write a solid librairy handling this, so you can keep client code free of technical cruft. HTH -- bruno desthuilliers for human readable, you might want to look at reading and writing dicts in YAML and SYCK libs, which is what this looks like -- http://mail.python.org/mailman/listinfo/python-list
Re: Reading from a file and converting it into a list of lines: code not working
Girish I have a text file in the following format: Girish 1,'a',2,'b' Girish 3,'a',5,'c' Girish 3,'a',6,'c' Girish 3,'a',7,'b' Girish 8,'a',7,'b' Girish . Girish . Girish . Girish Now i need to generate 2 things by reading the file: Girish 1) A dictionary with the numbers as keys and the letters as values. Girish e.g the above would give me a dictionary like Girish {1:'a', 2:'b', 3:'a', 5:'c', 6:'c' } Girish 2) A list containing pairs of numbers from each line. Girish The above formmat would give me the list as Girish [[1,2],[3,5],[3,6][3,7][8,7]..] Running this: open(some.text.file, w).write(\ 1,'a',2,'b' 3,'a',5,'c' 3,'a',6,'c' 3,'a',7,'b' 8,'a',7,'b' ) import csv class dialect(csv.excel): quotechar = ' reader = csv.reader(open(some.text.file, rb), dialect=dialect) mydict = {} mylist = [] for row in reader: numbers = [int(n) for n in row[::2]] letters = row[1::2] mydict.update(dict(zip(numbers, letters))) mylist.append(numbers) print mydict print mylist import os os.unlink(some.text.file) displays this: {1: 'a', 2: 'b', 3: 'a', 5: 'c', 6: 'c', 7: 'b', 8: 'a'} [[1, 2], [3, 5], [3, 6], [3, 7], [8, 7]] That seems to be approximately what you're looking for. Skip -- http://mail.python.org/mailman/listinfo/python-list
capture video from camera
i'm trying to capture video from camera/webcam using python. so far i haven't found any library that would allow me to do that. cross-platform solution related to SDL/pygame would be nice but a simple solution to capture video under windows is ok. Aljosa Mohorovic -- http://mail.python.org/mailman/listinfo/python-list
Re: 10GB XML Blows out Memory, Suggestions?
[EMAIL PROTECTED] wrote: I wrote a program that takes an XML file into memory using Minidom. I found out that the XML document is 10gb. I clearly need SAX or something else? What you clearly need is a better suited file format, but I suspect you're not in a position to change it, are you? Cheers, Nicola Musatti -- http://mail.python.org/mailman/listinfo/python-list
Interpretation of UnhandledException.rpt
Hi, in a windows server python application I receive once a week suddenly and not reproducible the following error. UnhandledException.rpt file: file //=== Exception code: C090 FLT_INVALID_OPERATION Program: C:\Python24\python.exe Date: 6/ 6/2006 14:36:13 (MM/DD/ HH:MM:SS) Fault address: 00E9ADF0 01:00019DF0 C:\in4\inforCOM\Prod\InforDbCOM_Server.dll Registers: EAX:012BDAA0 EBX:012ADF50 ECX:B0D6 EDX:012BDAA0 ESI:012ADF50 EDI:0096A8C0 CS:EIP:001B:00DC4DC7 SS:ESP:0023:0021EF4C EBP:02E91EF0 DS:0023 ES:0023 FS:003B GS: Flags:00010212 Call stack: Address Frame 00DC4DC7 02E91EF0 0001:3DC7 C:\Python24\DLLs\psycopg.pyd 2D36302D 36303032 *** Exception while writing report! *** /file Do I read this correct, that the problem is in the InforDbCOM_Server.dll? The call stack mentions the psycopg.pyd, can it be related to this problem? How can I track down this problem? -- Servus, Gregor -- http://mail.python.org/mailman/listinfo/python-list
Re: capture video from camera
aljosa wrote: i'm trying to capture video from camera/webcam using python. so far i haven't found any library that would allow me to do that. cross-platform solution related to SDL/pygame would be nice but a simple solution to capture video under windows is ok. first google hit for python video capture: http://videocapture.sourceforge.net/ for linux, see: http://www.antonym.org/libfg /F -- http://mail.python.org/mailman/listinfo/python-list
Re: 10GB XML Blows out Memory, Suggestions?
K.S.Sreeram schrieb: [EMAIL PROTECTED] wrote: I wrote a program that takes an XML file into memory using Minidom. I found out that the XML document is 10gb. With a 10gb file, you're best bet might be to juse use Expat and C!! No what exactly makes C grok a 10Gb file where python will fail to do so? What the OP needs is a different approach to XML-documents that won't parse the whole file into one giant tree - but I'm pretty sure that (c)ElementTree will do the job as well as expat. And I don't recall the OP musing about performances woes, btw. Diez -- http://mail.python.org/mailman/listinfo/python-list
Re: Vectorization
RonnyM [EMAIL PROTECTED] wrote in message news:[EMAIL PROTECTED] Hi! Need to vectorize this, but do not have a clue. a = n*m matrix x and y are n and m vectors Suggestions? def fill(a, x, y): for i in range(1,a.shape[0]): xp = x[i] for j in range(a.shape[1]): yp = y[j] a[i,j] = sin(xp*yp)*exp(-xp*yp) + a[i-1,j] return a Thanks in advance, Ronny Mandal Something like this, but the first row in a is never modified, is this correct? Note: this is a brute force Python attempt at a matrix, using a list of lists. Look also at the array and numarray modules. -- Paul from math import sin,exp def fill(a,x,y): aRowCount = len(x) aColCount = len(y) #a = [[0]*aColCount for i in range(aRowCount)] for ii,xp in enumerate(x[1:]): i = ii+1 for j,yp in enumerate(y): a[i][j] = sin(xp*yp)*exp(-xp*yp) + a[i-1][j] return a or more tersely (note - no side-effect of modifying a in place, makes a new copy): def fill2(a,x,y): fn = lambda t,u,v:sin(t*u)*exp(-t*u) + v return [a[0]] + [ [ fn(xp,yp,aa) for (yp,aa) in zip(y,arow) ] for (xp,arow) in zip(x[1:],a[:-1]) ] -- http://mail.python.org/mailman/listinfo/python-list
Re: Again, Downloading and Displaying an Image from the Internet in Tkinter
Justin Ezequiel wrote: cannot help you with Tkinter but... save=open(image.jpg,wb) save.write(web_download.read()) save.close() perhaps this would let you open the file in Paint Ok, that worked (was it plain w or the writelines/readlines that messed it up?). But Tkinter still can't find the image. I'm getting an error message: TclError: image C:\Documents and [pathname snipped] doesn't exist If it makes a difference, I'm on a Windows XP machine, and don't have to go cross-platform. -- http://mail.python.org/mailman/listinfo/python-list
Re: follow-up to FieldStorage
Bruno Desthuilliers wrote: John Salerno a écrit : If I want to get all the values that are entered into an HTML form and write them to a file, is there some way to handle them all at the same time, or must FieldStorage be indexed by each specific field name? AFAIK, FieldStorage is a somewhat dict-like object, but I'm not sure it supports the whole dict interface. At least, it does support keys(), so you should get by with: for k in fs.keys(): print myfile, k, :, fs[k] But reading the doc may help... Thanks. The cgi docs don't seem to get into too much detail, unless I wasn't thorough enough. But your method seems like it might work well if I can't find something after another read through. -- http://mail.python.org/mailman/listinfo/python-list
Re: 10GB XML Blows out Memory, Suggestions?
[EMAIL PROTECTED] wrote in message news:[EMAIL PROTECTED] I wrote a program that takes an XML file into memory using Minidom. I found out that the XML document is 10gb. I clearly need SAX or something else? You clearly need something instead of XML. This sounds like a case where a prototype, which worked for the developer's simple test data set, blows up in the face of real user/production data. XML adds lots of overhead for nested structures, when in fact, the actual meat of the data can be relatively small. Note also that this XML overhead is directly related to the verbosity of the XML designer's choice of tag names, and whether the designer was predisposed to using XML elements over attributes. Imagine a record structure for a 3D coordinate point (described here in no particular coding language): struct ThreeDimPoint: xValue : integer, yValue : integer, zValue : integer Directly translated to XML gives: ThreeDimPoint xValue4/xValue yValue5/yValue zValue6/zValue /ThreeDimPoint This expands 3 integers to a whopping 101 characters. Throw in namespaces for good measure, and you inflate the data even more. Many Java folks treat XML attributes as anathema, but look how this cuts down the data inflation: ThreeDimPoint xValue=4 yValue=5 zValue=6/ This is only 50 characters, or *only* 4 times the size of the contained data (assuming 4-byte integers). Try zipping your 10Gb file, and see what kind of compression you get - I'll bet it's close to 30:1. If so, convert the data to a real data storage medium. Even a SQLite database table should do better, and you can ship it around just like a file (just can't open it up like a text file). -- Paul -- http://mail.python.org/mailman/listinfo/python-list
Re: Again, Downloading and Displaying an Image from the Internet in Tkinter
Dustan wrote: Ok, that worked (was it plain w or the writelines/readlines that messed it up?). the plain w; very few image files are text files. But Tkinter still can't find the image. I'm getting an error message: TclError: image C:\Documents and [pathname snipped] doesn't exist If it makes a difference, I'm on a Windows XP machine, and don't have to go cross-platform. the image option takes a PhotoImage object, not a file name: http://effbot.org/tkinterbook/photoimage.htm note that the built-in PhotoImage type only supports a few image formats; to get support for e.g. PNG and JPEG, you can use PIL which ships with it's own PhotoImage replacement: http://effbot.org/imagingbook/imagetk.htm /F -- http://mail.python.org/mailman/listinfo/python-list
Re: Expanding Search to Subfolders
Here's the final working script. It opens all of the text files in a directory and its subdirectories and combines them into one Rich text file (index.rtf): #! /usr/bin/python import glob import fileinput import os import string import sys index = open(index.rtf, 'w') class DirectoryWalker: # a forward iterator that traverses a directory tree, and # returns the filename def __init__(self, directory): self.stack = [directory] self.files = [] self.index = 0 def __getitem__(self, index): while 1: try: file = self.files[self.index] self.index = self.index + 1 except IndexError: # pop next directory from stack self.directory = self.stack.pop() self.files = os.listdir(self.directory) self.index = 0 else: # get a filename, eliminate directories from list fullname = os.path.join(self.directory, file) if os.path.isdir(fullname) and not os.path.islink(fullname): self.stack.append(fullname) else: return fullname for file in DirectoryWalker(.): # divide files names into path and extention path, ext = os.path.splitext(file) # choose the extention you would like to see in the list if ext == .txt: print file # print the contents of each file into the index file = open(file) fileContent = file.readlines() for line in fileContent: if not line.startswith(\n): index.write(line) index.write(\n) index.close() -- http://mail.python.org/mailman/listinfo/python-list
Re: Expanding Search to Subfolders
Lou Losee wrote: How about something like: import os, stat class DirectoryWalker: # a forward iterator that traverses a directory tree, and # returns the filename ... not tested speak for yourself ;-) (the code is taken from http://effbot.org/librarybook/os-path.htm ) /F -- http://mail.python.org/mailman/listinfo/python-list
Re: capture video from camera
i searched on google and found http://videocapture.sourceforge.net/ before i posted here. videocapture has no docs and doesn't provide additional options like motion detection nor any info on possibility of motion detection or howto implement (use of minimal system resources). i posted here to find out if anybody knows a better way to capture video. Fredrik Lundh wrote: aljosa wrote: i'm trying to capture video from camera/webcam using python. so far i haven't found any library that would allow me to do that. cross-platform solution related to SDL/pygame would be nice but a simple solution to capture video under windows is ok. first google hit for python video capture: http://videocapture.sourceforge.net/ for linux, see: http://www.antonym.org/libfg /F -- http://mail.python.org/mailman/listinfo/python-list
Namespace problems
Hello All, I am kind of a beginner to python, but here is the deal. I am writing a wxpython Application, in which I have a GUI. This GUI imports some other modules that I have written, using the format import mymodule as _MyModule Now, this GUI in addition to having all it's bells and whistles has a console (from pyshell), so that the user can run their own scripts inside this GUI. What I am trying to do is to get these scripts that the user runs to be able to see all the other objects created and modules imported by the GUI. To make this clear, what I want to be able to do for example is in my script, do , dir(mymodule), already having imported mymodule in the GUI. Any ideas on how to make this happen? I don't want to import mymodule in this script, i want this script to see the mymodule that I imported in the main GUI. thanks a lot for your help, Kiran -- http://mail.python.org/mailman/listinfo/python-list
Re: 10GB XML Blows out Memory, Suggestions?
Paul You clearly need something instead of XML. Amen, brother... +1 QOTW. Skip -- http://mail.python.org/mailman/listinfo/python-list
Re: capture video from camera
aljosa wrote: i posted here to find out if anybody knows a better way to capture video. what other requirements did you forget to mention ? /F -- http://mail.python.org/mailman/listinfo/python-list
retaining newline characters when writing to file
If I read a string that contains a newline character(s) into a variable, then write that variable to a file, how can I retain those newline characters so that the string remains on one line rather than spans multiple lines? Example: In a CGI script, I'm reading the address field from an HTML form. Almost always the person will press ENTER so they can enter a second or third line. If I then want to write all the field values of this form to a CSV file, so that each person's entries takes one line, how can I ensure that the address string stays on one line despite the newline characters? (Or is it better to just use separate text fields for each line of the address?) Thanks. -- http://mail.python.org/mailman/listinfo/python-list
Re: retaining newline characters when writing to file
John Salerno wrote: If I read a string that contains a newline character(s) into a variable, then write that variable to a file, how can I retain those newline characters so that the string remains on one line rather than spans multiple lines? you cannot: the whole point of a newline character is to start a new line. however, some file formats let you escape the newline. for example, in Python source code, you can use end a line with a backslash. in CSV, you can put the string with newlines inside quotes, and Python's csv module knows how to do that: import csv, sys row = (One\nTwo\nThree, 1, 2, 3) writer = csv.writer(sys.stdout) writer.writerow(row) prints One Two Three,1,2,3 (not all CSV readers can handle multiline rows, though) /F -- http://mail.python.org/mailman/listinfo/python-list
Vancouver Python Workshop: New Keynoter
What's New? === The Vancouver Python Workshop is pleased to announce the addition of a third keynote speaker to this year's conference. Ian Cavén is the primary developer of the Lowry Digital Images motion picture restoration system. This Python and Zope-based system has been used to restore over 150 motion pictures. Highlights include Citizen Kane, Sunset Boulevard and both the Indiana Jones and Star Wars trilogies. While Ian was Chief Scientist at Lowry Digital, his rack of computers grew from a few Macintoshes on his desktop to over six hundred Macintosh and Linux servers - at one point earning Lowry the title as the second biggest installation of parallel processing Maintoshes in the world. In 2005, Lowry Digital Images was acquired by DTS (the famous movie audio company) and renamed DTS Digital Images. The motion picture restoration system has been discussed in publications as diverse as IEEE Spectrum, USA Today, the BBC NEWS, the New York Times and Apple.com. Ian has been a Python enthusiast since 1999. About the Vancouver Python Workshop === The conference will begin with keynote addresses on August 4st by Guido van Rossum [1], Jim Hugunin [2], and Ian Cavén. Further talks (and tutorials for beginners) will take place on August 5th and 6th. The Vancouver Python Workshop is a community organized conference designed for both the beginner and for the experienced Python programmer with: * tutorials for beginning programmers * advanced lectures for Python experts * case studies of Python in action * after-hours social events * informative keynote speakers * tracks on multimedia, Web development, education and more More information see: http://www.vanpyz.org/conference/ or contact Brian Quinlan at: [EMAIL PROTECTED] Vancouver = In addition to the opportunity to learn and socialize with fellow Pythonistas, the Vancouver Python Workshop also gives visitors the opportunity to visit one of the most extraordinary cities in the world [3]. For more information about traveling to Vancouver, see: http://www.vanpyz.org/conference/vancouver.html http://www.tourismvancouver.com http://en.wikipedia.org/wiki/Vancouver Important dates === Talk proposals accepted: May 15th to June 15th Early registration (discounted): May 22nd to June 30th Normal registration: from July 1st Keynotes: August 4th Conference and tutorial dates: August 5th and 6th [1] Guido van Rossum (Google) is the inventor of Python and has managed its growth and development for more than a decade. Guido was awarded the Free Software Foundation Award in 2002 and Dr.Dobb's 1999 Excellence in Programming Award. Guido works at Google and spends half of his time on Python. [2] Jim Hugunin (Microsoft) is the creator of numerous innovations that take Python into new application domains. Jim's most recent project, IronPython integrates Python into Microsoft's .NET runtime. Jim's previous project, Jython is Python for the Java runtime and was the second production-quality implementation of Python. Before that, Jim's Numeric Python adapted Python to the needs of number crunching applications. Jim works at Microsoft adapting the .NET runtime to the needs of dynamic languages like Python. [3] http://news.bbc.co.uk/2/hi/business/2299119.stm Cheers, Brian -- http://mail.python.org/mailman/listinfo/python-list
Re: retaining newline characters when writing to file
Fredrik Lundh wrote: John Salerno wrote: If I read a string that contains a newline character(s) into a variable, then write that variable to a file, how can I retain those newline characters so that the string remains on one line rather than spans multiple lines? you cannot: the whole point of a newline character is to start a new line. however, some file formats let you escape the newline. for example, in Python source code, you can use end a line with a backslash. in CSV, you can put the string with newlines inside quotes, and Python's csv module knows how to do that: import csv, sys row = (One\nTwo\nThree, 1, 2, 3) writer = csv.writer(sys.stdout) writer.writerow(row) prints One Two Three,1,2,3 (not all CSV readers can handle multiline rows, though) /F Thanks. I should give the csv module a look too, while I'm at it. -- http://mail.python.org/mailman/listinfo/python-list
calling functions style question
I just have a basic style question here. Suppose you have the program: def foo1(): do something def foo2() do something else Assume that you want to call these functions at execution. Is it more proper to call them directly like: foo1() foo2() or in an if __name__ == __main__: ? Both will execute when the script is called directly, I was just wondering if there is a preference, and what the pros and cons to each method were. Thanks, Brian -- http://mail.python.org/mailman/listinfo/python-list
Re: Namespace problems
Kiran wrote: Hello All, I am kind of a beginner to python, but here is the deal. I am writing a wxpython Application, in which I have a GUI. This GUI imports some other modules that I have written, using the format import mymodule as _MyModule Now, this GUI in addition to having all it's bells and whistles has a console (from pyshell), so that the user can run their own scripts inside this GUI. What I am trying to do is to get these scripts that the user runs to be able to see all the other objects created and modules imported by the GUI. To make this clear, what I want to be able to do for example is in my script, do , dir(mymodule), already having imported mymodule in the GUI. Any ideas on how to make this happen? I don't want to import mymodule in this script, i want this script to see the mymodule that I imported in the main GUI. thanks a lot for your help, Kiran Well, it depends on the context. If the __main__ context is that of PyShell it will likely contain no GUI object and you shall pass the GUI to PyShell before a PyShell window is created ( e.g. PyShell.__dict__[GUI] = GUI ). Descendent objects like mymodule that live in the GUI context will be accessible in the usual way i.e. by GUI.mymodule. You can experiment a little bit with contexts. Simply open a Python session and import PyShell: import PyShell PyShell.main() # causes creation of main window for PyShell Now you can inspect locals of PyShell using dir(). In this case the __main__ context is that of the top level session in which PyShell runs as an own session. You just have to import GUI to make it accessible to PyShell. If PyShell is the __main__ context you might assign GUI as described above. Regards, Kay -- http://mail.python.org/mailman/listinfo/python-list
Re: calling functions style question
The difference becomes clear when you import your program into another program (or the command line python editor). __name__!='__main__' when you import, so the functions will not be called if they're inside the block. This is why you see this block so often at the end of scripts; so that the script runs its main functions when called as a standalone program, but you can also import the code and do something with it without setting off those functions. THN Brian wrote: I just have a basic style question here. Suppose you have the program: def foo1(): do something def foo2() do something else Assume that you want to call these functions at execution. Is it more proper to call them directly like: foo1() foo2() or in an if __name__ == __main__: ? Both will execute when the script is called directly, I was just wondering if there is a preference, and what the pros and cons to each method were. Thanks, Brian -- http://mail.python.org/mailman/listinfo/python-list
what are you using python language for?
im just asking out of curiosity. -- http://mail.python.org/mailman/listinfo/python-list
Re: Vectorization
Paul McGuire wrote: RonnyM [EMAIL PROTECTED] wrote in message news:[EMAIL PROTECTED] Hi! Need to vectorize this, but do not have a clue. a = n*m matrix x and y are n and m vectors Suggestions? def fill(a, x, y): for i in range(1,a.shape[0]): xp = x[i] for j in range(a.shape[1]): yp = y[j] a[i,j] = sin(xp*yp)*exp(-xp*yp) + a[i-1,j] return a Thanks in advance, Ronny Mandal Something like this, but the first row in a is never modified, is this correct? Note: this is a brute force Python attempt at a matrix, using a list of lists. Look also at the array and numarray modules. The array module doesn't do matrices, and numarray is deprecated. Please point new users to numpy, instead. http://numeric.scipy.org/ Since the OP seems to already be using one of Numeric/numarray/numpy, (given a.shape), I would suggest that he ask the question on the appropriate mailing list: https://lists.sourceforge.net/lists/listinfo/numpy-discussion I won't attempt an answer until the OP answers about the first row. -- Robert Kern I have come to believe that the whole world is an enigma, a harmless enigma that is made terrible by our own mad attempt to interpret it as though it had an underlying truth. -- Umberto Eco -- http://mail.python.org/mailman/listinfo/python-list
Re: calling functions style question
Brian wrote: I just have a basic style question here. Suppose you have the program: def foo1(): do something def foo2() do something else Assume that you want to call these functions at execution. Is it more proper to call them directly like: foo1() foo2() or in an if __name__ == __main__: ? Both will execute when the script is called directly, I was just wondering if there is a preference, and what the pros and cons to each method were. Thanks, Brian If you want those functions to be called each time your module gets imported you have to apply calls out of the if __name__ ... statement. If your module is, for certain reasons, always the __main__ module and never gets imported there is no obvious preference because behaviour will be the same. -- http://mail.python.org/mailman/listinfo/python-list
Re: what are you using python language for?
At the moment, I'm using it for 1) Enginerring/scientific data analysis and visualization. 2) Serial communication test programs. 3) Small utilities for embedded software development (processing map and hex files). 4) Miscellaneous other stuff like grabbing all of the comic strips I like every day and putting them on a local web page so I can read them all in one place, deleting all of the virus-laden e-mails that Postini catches, etc. -- Grant Edwards grante Yow! Is this BOISE?? at visi.com -- http://mail.python.org/mailman/listinfo/python-list
Re: what are you using python language for?
hacker1017 wrote: im just asking out of curiosity. To get an impression you might have a look at the Europython 2006 schedule: http://indico.cern.ch/conferenceTimeTable.py?confId=44 Personally I'm playing with the language itself at the moment and extend it through it: http://www.fiber-space.de/EasyExtend/doc/EE.html Regards, Kay -- http://mail.python.org/mailman/listinfo/python-list
Request for trackers to evaluate as SF replacement for Python development
The Python Software Foundation's Infrastructure committee has been charged with finding a new tracker system to be used by the Python development team as a replacement for SourceForge. The development team is currently unhappy with SF for several reasons which include: * Bad interface Most obvious example is the Check to Upload button* Lack of reliability SF has been known to go down during the day unexpectedly and stay down for hours* Lack of workflow controls For instance, you cannot delete a category once createdFor these reasons and others, we are requesting the Python community help us find a new tracker to use. We are asking for test trackers to be set up to allow us to test them to see which tracker we want to move the Python development team to. This is in order to allow the Infrastructure committee to evaluate the various trackers to see which one meets our tracker needs the best. Because we are not sure exactly what are requirements for a tracker are we do not have a comprehensive requirements document. But we do have a short list of bare minimum needs:* Can import SF data http://effbot.org/zone/sandbox-sourceforge.htm contains instructions on how to access the data dump and work with the support tools (graciously developed by Fredrik Lundh) * Can export data To prevent the need to develop our own tools to get our data out of the next tracker, there must be a way to get a dump of the data (formatted or raw) that includes *all* information* Has an email interface To facilitate participation in tracker item discussions, an email interface is required to lower the barrier to add comments, files, etc.If there is a tracker you wish to propose for Python development team use, these are the steps you must follow: * Install a test tracker If you do not have the server resources needed, you may contact the Infrastructure committee at infrastructure at python.org, but our resources are limited by both machine and manpower, so *please* do what you can to use your own servers; we do not expect you to provide hosting for the final installation of the tracker for use by python-dev, though, if your tracker is chosen * Import the SF data dump http://effbot.org/zone/sandbox-sourceforge.htm* Make the Infrastructure committee members administrators of the tracker A list of the committee members can be found at http://wiki.python.org/moin/PythonSoftwareFoundationCommittees#infrastructure-committee-ic * Add your tracker to the wiki page at http://wiki.python.org/moin/CallForTrackers This includes specifying the contact information for a *single* lead person to contact for any questions about the tracker; this is to keep communication simple and prevent us from having competing installations of the same tracker software * Email the Infrastructure committee that your test tracker is up and ready to be viewedWe will accept new trackers for up to a maximum of two months starting 2006-06-05 (and thus ending 2006-08-07). If trackers cease to be suggested, we will close acceptance one month after the last tracker proposed (this means the maximum timeframe for all of this is three months, ending 2006-09-04). This allows us to not have this process carry on for three months if there is no need for it to thanks to people getting trackers up quickly. As the committee evaluates trackers we will add information about what we like and dislike to the http://wiki.python.org/moin/GoodTrackerFeatures wiki page so that various trackers and change their setttings and notify us of such changes. This prevents penalizing trackers that are set up quickly (which could be taken as a sign of ease of maintenance) compared to trackers that are set up later but possibly more tailored to what the Infrastructure committee discovers they want from a tracker. If you have any questions, feel free to email infrastructure at python.org .- Brett Cannon Chairman, Python Software Foundation Infrastructure committee -- http://mail.python.org/mailman/listinfo/python-list
Re: what are you using python language for?
4) Miscellaneous other stuff like grabbing all of the comic strips I like every day and putting them on a local web page so I can read them all in one place I wonder how many other folks have done this too. It was my first pet Python project, converting a Java rendition of the same app into Python. Shorter, clearer, faster, better... Mine uses my older Java config file (which, while tinkering with Java's XML libraries, ended up being XML), supports Referrer/Referer spoofing, searches pages for regexps so that I can find image URLs that have been munged with random numbers (like dilbert.com does). It then builds a local HTML file that points at all the locally-saved images. I wonder what other sorts of features folks have added in their comic-snatchers... I tried a multi-threaded version in Java, but had problems with it saturating my dialup connection, and returning some sort of errors (perhaps in violation of HTTP's suggestion that one only have, IIRC, 2 connections to a server at a given time). I might try it again with Python. I saw some function-call fly by recently that looked like it took a function reference and an array of parameter-arrays, and spawned a thread for each function. I foolishly deleted that message, but it shouldn't be too hard to scare up again. I think it involved importing something from the future. A nice little status-GUI would be a nice addition, but I'm too lazy to go that far, leaving it with just a TUI. Might be a good way to learn Python GUI programming... -tkc -- http://mail.python.org/mailman/listinfo/python-list
Re: what are you using python language for?
I'm using for processing genetic and biological data, anda for fun...On 6/4/06, hacker1017 [EMAIL PROTECTED] wrote:im just asking out of curiosity.-- http://mail.python.org/mailman/listinfo/python-list-- Miguel Galves - Engenheiro de ComputaçãoJá leu meus blogs hoje? Para geeks http://log4dev.blogspot.comPra pessoas normaishttp://miguelgalves.blogspot.comNão sabendo que era impossível, ele foi lá e fez... -- http://mail.python.org/mailman/listinfo/python-list
Re: what are you using python language for?
hacker1017 wrote: im just asking out of curiosity. We use python for somewhat complex build system which builds several versions of embedded Linux for multiple architectures (30+). Two particularly interested aspects of this build system involve simple cluster management utilities (utilities to help manage distribution of work across 70 machines) and we are currently developing a distributed execution framework. Some cool stuff if you ask me (I mean, i had better like it, its my job!) -carl -- Carl J. Van Arsdall [EMAIL PROTECTED] Build and Release MontaVista Software -- http://mail.python.org/mailman/listinfo/python-list
Re: 10GB XML Blows out Memory, Suggestions?
[EMAIL PROTECTED] wrote: I wrote a program that takes an XML file into memory using Minidom. I found out that the XML document is 10gb. I clearly need SAX or something else? Any suggestions on what that something else is? Is it hard to convert the code from DOM to SAX? If your XML files grow so large you might rethink the representation model. Maybe you give eXist a try? http://exist.sourceforge.net/ Regards, Kay -- http://mail.python.org/mailman/listinfo/python-list
Re: what are you using python language for?
On 2006-06-06, Tim Chase [EMAIL PROTECTED] wrote: 4) Miscellaneous other stuff like grabbing all of the comic strips I like every day and putting them on a local web page so I can read them all in one place I wonder how many other folks have done this too. It was my first pet Python project, converting a Java rendition of the same app into Python. Shorter, clearer, faster, better... Mine uses my older Java config file (which, while tinkering with Java's XML libraries, ended up being XML), Mine just has lists of strip/source pairs at the top of the source code. supports Referrer/Referer spoofing, Yup. Although I wouldn't actually call mine spoofing. Since I do grab the end URL from the referrer every time, it really is referring me to the server where the image is. searches pages for regexps so that I can find image URLs that have been munged with random numbers (like dilbert.com does). It then builds a local HTML file that points at all the locally-saved images. I wonder what other sorts of features folks have added in their comic-snatchers... Mine scales the images up by 50% -- the native image size provided by the distributors is just too small on my 19 1280x1024 screen. I tried a multi-threaded version in Java, but had problems with it saturating my dialup connection, and returning some sort of errors (perhaps in violation of HTTP's suggestion that one only have, IIRC, 2 connections to a server at a given time). I might try it again with Python. I saw some function-call fly by recently that looked like it took a function reference and an array of parameter-arrays, and spawned a thread for each function. I foolishly deleted that message, but it shouldn't be too hard to scare up again. I think it involved importing something from the future. A nice little status-GUI would be a nice addition, but I'm too lazy to go that far, leaving it with just a TUI. Might be a good way to learn Python GUI programming... Mine runs as a cron job every morning before I get to the office (which is where I read them -- don't tell anybody). -- Grant Edwards grante Yow! Why was I BORN? at visi.com -- http://mail.python.org/mailman/listinfo/python-list
Pydev 1.1.0 Released
Hi All, Pydev and Pydev Extensions 1.1.0 have been released Details on Pydev Extensions: http://www.fabioz.com/pydev Details on Pydev: http://pydev.sf.net Details on its development: http://pydev.blogspot.com Release Highlights in Pydev Extensions: - - Bug-fixes Release Highlights in Pydev: -- - Startup is now faster for the plugin: actions, scripts, etc. are now all initialized in a separate thread - Indentation engine does not degrade as document grows - Multiple-string does not mess up highlighting anymore - code completion issue with {} solved - Ctrl+W: now expands the selection to cover the whole word where the cursor is - Assign to attributes (provided by Joel Hedlund) was expanded so that Ctrl+1 on method line provides it as a valid proposal - A Typing preferences page was created so that the main page now fits in lower resolutions What is PyDev? --- PyDev is a plugin that enables users to use Eclipse for Python and Jython development -- making Eclipse a first class Python IDE -- It comes with many goodies such as code completion, syntax highlighting, syntax analysis, refactor, debug and many others. Cheers, -- Fabio Zadrozny -- Software Developer ESSS - Engineering Simulation and Scientific Software http://www.esss.com.br Pydev Extensions http://www.fabioz.com/pydev Pydev - Python Development Enviroment for Eclipse http://pydev.sf.net http://pydev.blogspot.com -- http://mail.python.org/mailman/listinfo/python-list
Using Komodo 3.5 - Setting breakpoints in multiple *.py files
I am using ActiveState Komodo 3.5 to work on a large python 2.4 application with an extensive UI... I am attempting to debug the application and am setting breakpoints in 4 different *.py files.. Breakpoints in the main file are working OK, but any breakpoints in imported files are not... The three imported files are open in Komodo and are in the same local directory as the main file (in the python24/Lib/site-packages tree)... The code sections I am trying to debug are invoked by some UI events... When I start the debugging section and navigate to the features I am trying to debug, the breakpoint are ignored... I can execute a Break now command and the IDE is smart enough to find and display imported *.py resources... but normal breakpoints are ignored... I am new to Komodo and Python, and the IDE debugging features are certainly not working as expected, based upon my experience with Visual Studio and JBuilder... I've searched the included Help system and so far haven't had any luck... Thanks! -- http://mail.python.org/mailman/listinfo/python-list
Need pixie dust for building Python 2.4 curses module on Solaris 8
I'm having no success building the curses module on Solaris 8 (yes, I know it's ancient - advancing the state-of-the-art is not yet an option) for Python 2.4. Sun provides an apparently ancient version of curses in /usr/lib, so I downloaded and installed ncurses 5.5, both using default settings and using --with-shared. When the curses module is linked against libcurses.so I get some strange error about acs32map being undefined (which appears to live in a couple termcap-ish files in /usr/lib). When the curses module is linked against libncurses.a I get bazillions of linker errors like this: Text relocation remains referenced against symbol offset in file table.0 0x41 /opt/app/nonc++/ncurses-5.5/lib/libncurses.a(lib_color.o) hls_palette 0x2dc /opt/app/nonc++/ncurses-5.5/lib/libncurses.a(lib_color.o) cga_palette 0x2e3 /opt/app/nonc++/ncurses-5.5/lib/libncurses.a(lib_color.o) hls_palette 0x5e0 /opt/app/nonc++/ncurses-5.5/lib/libncurses.a(lib_color.o) cga_palette 0x5e7 /opt/app/nonc++/ncurses-5.5/lib/libncurses.a(lib_color.o) unknown 0xc9e /opt/app/nonc++/ncurses-5.5/lib/libncurses.a(lib_color.o) unknown 0xcb7 /opt/app/nonc++/ncurses-5.5/lib/libncurses.a(lib_color.o) unknown 0x18 /opt/app/nonc++/ncurses-5.5/lib/libncurses.a(lib_mouse.o) The build step and output from distutils are: $ python ../setup.py build_ext --include-dirs=/opt/app/nonc++/ncurses-5.5/include --rpath=/opt/app/nonc++/ncurses-5.5/lib --library-dirs=/opt/app/nonc++/ncurses-5.5/lib running build_ext INFO: Can't locate readline library INFO: Can't locate Tcl/Tk libs and/or headers building '_curses' extension gcc -fno-strict-aliasing -DNDEBUG -g -O3 -Wall -Wstrict-prototypes -fPIC -I. -I/home/ink/skipm/src/python-svn/release24-maint/./Include -I/opt/app/g++lib6/python-2.4/include -I/usr/local/include -I/opt/app/nonc++/ncurses-5.5/include -I/opt/app/g++lib6/python-2.4/include/python2.4 -c /home/ink/skipm/src/python-svn/release24-maint/Modules/_cursesmodule.c -o build/temp.solaris-2.8-i86pc-2.4/home/ink/skipm/src/python-svn/release24-maint/Modules/_cursesmodule.o /home/ink/skipm/src/python-svn/release24-maint/Modules/_cursesmodule.c: In function `PyCursesWindow_GetStr': /home/ink/skipm/src/python-svn/release24-maint/Modules/_cursesmodule.c:822: warning: implicit declaration of function `mvwgetnstr' gcc -shared build/temp.solaris-2.8-i86pc-2.4/home/ink/skipm/src/python-svn/release24-maint/Modules/_cursesmodule.o -L/opt/app/g++lib6/python-2.4/lib -L/usr/local/lib -L/opt/app/nonc++/ncurses-5.5/lib -Wl,-R/opt/app/nonc++/ncurses-5.5/lib -lncurses -o build/lib.solaris-2.8-i86pc-2.4/_curses.so Any ideas what's wrong and what I need to do to correct the problem? Thx, Skip -- http://mail.python.org/mailman/listinfo/python-list
Newbie: returning dynamicly built lists (using win32com)
Very newb here, but my question will hopefully be obvious to someone. Code: import string from win32com.client import Dispatch docdir = 'E:\\scripts\\Python\\RSAutomation\\' def getOldData(testcases): excel = Dispatch(Excel.Application) excel.Workbooks.Open(docdir + 'FILE.xls') # load and create list from file (testcases.csv) for rsinput in testcases.xreadlines(): inputlist = string.split(rsinput, ',') # iterate through and update spreadsheet input cellx = range(3,51) values = range(0,48) for i,r in zip(cellx, values): excel.ActiveSheet.Cells(i,2).Value = inputlist[r] # TODO: read output from cell 32,6 into a tuple or list and then return list to __main__ [THIS IS WHERE I AM HAVING A PROBLEM] print excel.ActiveSheet.Cells(32,6) --This prints properly as loop executes excel.ActiveWorkbook.Close(SaveChanges=0) excel.Quit() if __name__ == __main__: csv_testcases = open('arse_testcases.csv','r') getOldData(csv_testcases) OK, so what is happening is that I am sending a list of data to an overly complicated spreadsheet that produces it's own output (in cell 32,6). As I loop through multiple test cases, the print statement calling into COM for the cell data seems to be printing out results just fine. But when I try and put the output from the spreadsheet into a dynamic list after the TODO section thusly: outputlist = [] outputlist.extend(excel.ActiveSheet.Cells(32,6) return outputlist I get an error like: [win32com.gen_py.Microsoft Excel 9.0 Object Library.Range instance at 0x15450880] I need to be able to return the dynamically generated built up by the responses from the spreadsheet lookup call (the exce.Activesheet thingy). Is there a better way to get this dynamically built list out of the funtion? Thanks!!! -- http://mail.python.org/mailman/listinfo/python-list
Re: Newbie: returning dynamicly built lists (using win32com)
I'm afraid I don't have a Windows machine to test on, but.. Ransom wrote: I get an error like: [win32com.gen_py.Microsoft Excel 9.0 Object Library.Range instance at 0x15450880] This isn't an error. This is a list with one element, where the element apparently represents a range of Excel cells. So by using that element you can do things like changing the formatting of the cell, as well as finding out what data is in there. It looks like you might need to use excel.ActiveSheet.Cells(32, 6).Value to get the contents of cell (32, 6). (It depends on what Excel calls it, of course, so if it's not that have a look at Excel's VBA documentation to see if it mentions anything.) Nick -- http://mail.python.org/mailman/listinfo/python-list
Re: Newbie: returning dynamicly built lists (using win32com)
Ransom wrote: Very newb here, but my question will hopefully be obvious to someone. Code: import string from win32com.client import Dispatch docdir = 'E:\\scripts\\Python\\RSAutomation\\' def getOldData(testcases): excel = Dispatch(Excel.Application) excel.Workbooks.Open(docdir + 'FILE.xls') # load and create list from file (testcases.csv) for rsinput in testcases.xreadlines(): inputlist = string.split(rsinput, ',') # iterate through and update spreadsheet input cellx = range(3,51) values = range(0,48) for i,r in zip(cellx, values): excel.ActiveSheet.Cells(i,2).Value = inputlist[r] # TODO: read output from cell 32,6 into a tuple or list and then return list to __main__ [THIS IS WHERE I AM HAVING A PROBLEM] print excel.ActiveSheet.Cells(32,6) --This prints properly as loop executes excel.ActiveWorkbook.Close(SaveChanges=0) excel.Quit() if __name__ == __main__: csv_testcases = open('arse_testcases.csv','r') getOldData(csv_testcases) OK, so what is happening is that I am sending a list of data to an overly complicated spreadsheet that produces it's own output (in cell 32,6). As I loop through multiple test cases, the print statement calling into COM for the cell data seems to be printing out results just fine. But when I try and put the output from the spreadsheet into a dynamic list after the TODO section thusly: outputlist = [] outputlist.extend(excel.ActiveSheet.Cells(32,6) return outputlist I get an error like: [win32com.gen_py.Microsoft Excel 9.0 Object Library.Range instance at 0x15450880] That's not an error, that's a list containing a single Python COM object. I need to be able to return the dynamically generated built up by the responses from the spreadsheet lookup call (the exce.Activesheet thingy). Is there a better way to get this dynamically built list out of the funtion? Thanks!!! I suspect that you need to apply judicious conversions to string or numeric to grab the values of the cells you are interested in, unencumbered by the COM wrappings. regards Steve -- Steve Holden +44 150 684 7255 +1 800 494 3119 Holden Web LLC/Ltd http://www.holdenweb.com Love me, love my blog http://holdenweb.blogspot.com Recent Ramblings http://del.icio.us/steve.holden -- http://mail.python.org/mailman/listinfo/python-list
Re: what are you using python language for?
On 6/4/06, hacker1017 [EMAIL PROTECTED] wrote: im just asking out of curiosity. My current gig is perl only, but I still use python for personal stuff 1) +Twisted for a couple of IRC Bots 2) an interface between TextMate and py.test 3) a soccer management game (wxPython + PyGame) -- Stand Fast, tjg. -- http://mail.python.org/mailman/listinfo/python-list
newbie: python application on a web page
Hi all, I am so new to everything, I don't even know where to post my question... do bear... I made this Python calculator that will take an equation as an input and will display the computed curves on a shiny Tkinter interface Now, I'd like to make this application available on a public web page... and all I could come up with was this post Hints?! I'd also appreciate a link to a beginner forum Thanks Puzzled Me -- http://mail.python.org/mailman/listinfo/python-list
Re: newbie: python application on a web page
puzz wrote: I made this Python calculator that will take an equation as an input and will display the computed curves on a shiny Tkinter interface well, it doesn't sound like you're quite as newbie-ish as many other newbies ;-) Now, I'd like to make this application available on a public web page... and all I could come up with was this post some potentially useful links: http://tkinter.unpythonic.net/wiki/ http://infogami.com/ http://pages.google.com I'd also appreciate a link to a beginner forum assuming beginner implies really wants to learn, this one's quite nice: http://mail.python.org/mailman/listinfo/tutor /F -- http://mail.python.org/mailman/listinfo/python-list
Re: 10GB XML Blows out Memory, Suggestions?
Em Ter, 2006-06-06 às 13:56 +, Paul McGuire escreveu: (just can't open it up like a text file) Who'll open a 10 GiB file anyway? -- Felipe. -- http://mail.python.org/mailman/listinfo/python-list
Re: capture video from camera
aljosa wrote: i searched on google and found http://videocapture.sourceforge.net/ before i posted here. yup. videocapture has no docs With the API docs in the .zip and the examples provided, you should be able to handle it.I did :) and doesn't provide additional options like motion detection nor any info on possibility of motion detection or howto implement (use of minimal system resources). Sure. You may try to use some external lib such as Camellia (http://camellia.sourceforge.net/). There are (swig-generated) bindings for Ruby, writing a bridge to python should be straightforward By the way, if you want to be cross-platform, you can use pyv4l as a replacement of videocapture for Linux. Combine this with a pygame integration and you're done. Cheers, SB -- http://mail.python.org/mailman/listinfo/python-list
Re: what are you using python language for?
I tend to do a significant amount of EDI related work:-statistical analysis-X12-HTML formattingI've do a ton of customer DB reporting. I find it easier to use Python that Crystal reports for a lot of the stuff I do so I extract data and spit out CSV files for Excel to make it look pretty. And I'm getting ready to do a fun/work project using TurboGears for a web-based migration tracking utility we need.ChrisOn 6/4/06, hacker1017 [EMAIL PROTECTED] wrote:im just asking out of curiosity. --http://mail.python.org/mailman/listinfo/python-list-- A little government and a little luck are necessary in life, but only a fool trusts either of them. -- P. J. O'Rourke -- http://mail.python.org/mailman/listinfo/python-list
Re: what are you using python language for?
hacker1017 wrote: im just asking out of curiosity. Math research on the Collatz Conjecture. -- http://mail.python.org/mailman/listinfo/python-list
Re: Newbie: returning dynamicly built lists (using win32com)
Ransom wrote: Very newb here, but my question will hopefully be obvious to someone. OK, so what is happening is that I am sending a list of data to an overly complicated spreadsheet that produces it's own output (in cell 32,6). As I loop through multiple test cases, the print statement calling into COM for the cell data seems to be printing out results just fine. But when I try and put the output from the spreadsheet into a dynamic list after the TODO section thusly: outputlist = [] outputlist.extend(excel.ActiveSheet.Cells(32,6) return outputlist I get an error like: [win32com.gen_py.Microsoft Excel 9.0 Object Library.Range instance at 0x15450880] the Cells call returns some kind of internal win32com object, not strings. Python has two different ways of converting an object to a string of characters; str() and repr(): http://pyref.infogami.com/str http://pyref.infogami.com/repr when you print an object, Python uses str() to do the conversion. however, when you print a container, the container object's str() implementation often uses repr() on the members. to apply str() to all list members, you can simply do: outputlist = map(str, outputlist) print outputlist or print map(str, outputlist) or some other variation thereof. /F -- http://mail.python.org/mailman/listinfo/python-list
Re: newbie: python application on a web page
I made this Python calculator that will take an equation as an input and will display the computed curves on a shiny Tkinter interface well, it doesn't sound like you're quite as newbie-ish as many other newbies ;-) Now, I'd like to make this application available on a public web page... and all I could come up with was this post some potentially useful links: http://tkinter.unpythonic.net/wiki/ http://infogami.com/ http://pages.google.com I'd also appreciate a link to a beginner forum assuming beginner implies really wants to learn, this one's quite nice: http://mail.python.org/mailman/listinfo/tutor And perhaps you'll find this also helpful: http://modpython.org/ an apache module that embeds the interpreter into the webserver. -- http://mail.python.org/mailman/listinfo/python-list
Re: 10GB XML Blows out Memory, Suggestions?
Diez B. Roggisch wrote: What the OP needs is a different approach to XML-documents that won't parse the whole file into one giant tree - but I'm pretty sure that (c)ElementTree will do the job as well as expat. And I don't recall the OP musing about performances woes, btw. There's just NO WAY that the 10gb xml file can be loaded into memory as a tree on any normal machine, irrespective of whether we use C or Python. So the *only* way is to perform some kind of 'stream' processing on the file. Perhaps using a SAX like API. So (c)ElementTree is ruled out for this. Diez B. Roggisch wrote: No what exactly makes C grok a 10Gb file where python will fail to do so? In most typical cases where there's any kind of significant python code, its possible to achieve a *minimum* of a 10x speedup by using C. In most cases, the speedup is not worth it and we just trade it for the increased flexiblity/power of the python language. But in this situation using a bit of tight C code could make the difference between the process taking just 15mins or taking a few hours! Ofcourse I'm not asking him to write the entire application in C. It makes sense to just write the performance critical sections in C, and wrap it in Python, and write the rest of the application in Python. signature.asc Description: OpenPGP digital signature -- http://mail.python.org/mailman/listinfo/python-list