PyCon 2006 Call for Tutorials
PyCon 2006 Call for Tutorials -- Enjoy teaching classes or tutorials? PyCon 2006 is looking for proposals for a pre-conference tutorials day. PyCon 2006 will be held February 24-26 in Addison, Texas (near Dallas). Tutorials will be held on February 23, at the same location. Tutorial sessions will be a half day (3 hours, with a 15-minute break); presenters may request two sessions in order to make up a full day. Tutorials may be on any topic, but obviously should be instructional in nature. Providing take-home materials for attendees is encouraged, and tutorial presenters will receive $50 per student registered for theirsession (with a minimum payment of $500, and a maximum of $1500). Extra consideration will be given to presenters with prior experience teaching classes or giving conference tutorials. Please provide one reference or evidence of such prior experience (sessions taught at OSCON, EuroPython, local user groups, etc.). PyCon attendees will register for tutorials. We reserve the right to cancel tutorials with low attendance; presenters will not be paid for cancelled tutorials. Example tutorial topics can be found at: http://us.pycon.org/TX2006/Tutorials Important Dates === * Submission deadline: November 15, 2005 * Acceptance deadline: November 22, 2005 * Cancellation date: January 15, 2006 (for inadequate attendance) Submission Format Proposals should be 250 to 1000 words long (i.e., one to four pages in manuscript format), containing the following information: * Author name(s) * Contact Information * (Recommended) At least one previous presentation/teaching engagement reference * Summary of proposed presentation * Presentation outline * Intended audience (non-programmers, beginning programmers, advanced users, CPython developers, etc.) E-mail your proposal to [EMAIL PROTECTED]. ASCII format is preferred (plain or reST), with HTML as a secondary alternative. If you have any questions about submission, please send mail to the conference organizers at [EMAIL PROTECTED] -- http://mail.python.org/mailman/listinfo/python-announce-list Support the Python Software Foundation: http://www.python.org/psf/donations.html
ANN: sharep 0.2 - share price downloader module
sharep is a Public Domain python module for downloading share prices from the internet. Currently only UK shares are supported. Feel free to submit support for other countries. News 08-Nov-2005 Version 0.2 released - updates for changes to Yahoo site 21-Dec-2004 Version 0.1 released Example # download bid and ask price for Glaxo Pharmaceuticals; symbol name GSK import sharep.uk sharep.uk.bid('GSK') '1,184.00' sharep.uk.ask('gsk') '1,186.00' Webpage: http://www.markcarter.me.uk/computing/python/sharep/sharep.htm Download: http://www.markcarter.me.uk/computing/python/sharep/sharep-0.2.zip -- http://mail.python.org/mailman/listinfo/python-announce-list Support the Python Software Foundation: http://www.python.org/psf/donations.html
SoCal Piggies meeting: Nov.10 at USC (7 PM)
The next meeting of the SoCal Piggies will be this Thursday November 10 at USC, starting at 7 PM. We'll have 2 presentations: * Python and Unicode -- Daniel Arbuckle * What You Can Do with Python in 90 Minutes -- Mark Kohler If you're a Python enthusiast living in the L.A./O.C. area, please consider joining us for the meeting. The SoCal Piggies Wiki is at http://socal-piggies.org/scp. Directions to the USC location are available here: http://socal-piggies.org/scp/USC_Salvatori_Computer_Science_Center,_room_222 Grig -- http://mail.python.org/mailman/listinfo/python-announce-list Support the Python Software Foundation: http://www.python.org/psf/donations.html
Revised announcement for tonight's Fredericksburg ZPUG
This is a revised announcement for tonight's Fredericksburg ZPUG meeting. Andrew Sawyers is postponing his Squid and Zope presentation until the January ZPUG meeting (January 11, 2006). This is the new agenda: -- Please join us November 9, 7:30-9:00 PM, for the sixth meeting of the Fredericksburg, VA Zope and Python User Group (ZPUG). Using Zope for newspaper publishing! The dangers of object oriented inheritance! Free food! * Allen Schmidt, Sr. Programmer for Fredericksburg.com - the website for the Free Lance-Star - will present on Using Zope for Newspaper Publishing. * Jim Fulton, CTO of Zope Corporation, will present an abbreviated version of the argument given in Clemens Szyperski's Component Software for why both inheritance and delegation (e.g. acquisition) cause tight coupling and therefore should be avoided except in special circumstances. * We will serve delicious fruit, cheese, and soft drinks. -- http://mail.python.org/mailman/listinfo/python-announce-list Support the Python Software Foundation: http://www.python.org/psf/donations.html
Re: which feature of python do you like most?
which feature of python do you like most? i cannot chose one but here is my list: iterpreter (i can try out things at once) dir(obj) (using dir() i can learn a new library quickly) identation (code is readable, no need for {} and ;) dynamictyping (no type declaration - less code to write) lightweight oo (no public/protected/private - less code to write) widespread (it's easy to find a python module for any kind of task) built-in types (creating list, dict is easy, iterator protocol wins) generators (creating an iterator is easy: replace return with yield) listcomprehension (intuitive and clear way of creating lists) pyrex/swig/boostpython (easily extendible with c/c++) crossplatform (i can write code for my win/linux os) free (yes it's free and it has a reasonable license) comp.lang.python (good questions and even better answers, friendly folks:) -- http://mail.python.org/mailman/listinfo/python-list
Re: A Tcl/Tk programmer learns Python--any advice?
In article [EMAIL PROTECTED], [EMAIL PROTECTED] says... Ah, another one leaves the fold... : \ I think I saw somebody say about OO in Python: It's there, but you don't have to use it. Every time somebody wants OO in the core of tcl, he is asked: Why do you want it? If OO was as easy in Tcl as in Python, there would be no real reason to switch in my opinion. (And maybe simpler namespaces and passing of lists to functions, we all love the uplevel and upvar commands, don't we?) -- Svenn -- http://mail.python.org/mailman/listinfo/python-list
Re: How do I create a dir using Python?
Sumi wrote: How do i create a dir using python. #v+ os.makedirs = makedirs(name, mode=511) makedirs(path [, mode=0777]) Super-mkdir; create a leaf directory and all intermediate ones. Works like mkdir, except that any intermediate path segment (not just the rightmost) will be created if it does not exist. This is recursive #v- Cheers, -- Klaus Alexander Seistrup Copenhagen, Denmark http://seistrup.dk/ -- http://mail.python.org/mailman/listinfo/python-list
$$$$$make tons of cash EASY$$$$$
What is $5 and 15 minutes when it can make you earn $100,000 ? Not much, if you ask me... You've probably seen a lot of those kind of messages over forums and newsgroups, and the explanation for this can be given in two words: IT WORKS! But how on earth, will you ask me, does it actually works? How is such a thing possible? This is a simple pyramid scheme. To explain it to you with realistic numbers, lets take a simple example: Imagine you folow the instructions given below, and post your message to 500 newsgroups (wich is not much). 10 people read your message and also folow the instructions: that's $10 for you. These 10 people get 10 people each to join the process: that's $100 for you. These 100 people get 10 people each to join the process: that's $1,000 for you! These 1,000 people get 10 people each to join the process: that's $10,000 for you!! These 10,000 people get 10 people each to join the process: that's $100,000 for you!!! After the whole process, you have therefore made $111,110! And it took you only 15 minutes and $5! If you think this might work (and it does, I can tell you that), then folow these simple instructions: 1) Open a FREE PayPal account (!Business or Premier, not the simple one!), and place $5 on it. 2) Using PayPal, pay $1 to the folowing 5 e-mail adresses, with 'Mailing list subscription' as subject and no message. 1- [EMAIL PROTECTED] 2- [EMAIL PROTECTED] 3- [EMAIL PROTECTED] 4- [EMAIL PROTECTED] 5- [EMAIL PROTECTED] 3) Make the changes you want to this message, and remove e-mail adress number 1. Then, place e-mail adress number 2 in number 1, 3 in number 2, 4 in number 3, 5 in number 4, and add your own e-mail adress (the one you used on PayPal!) in number 5. 4) Download UltraNNTP from http://ultranntp.zapto.org, and install it (it's small and free). 5) Using UltraNNTP, download the list of newsgroups from you favorite news (nntp) server. 6) Send your new message to all the newsgroups on your server (or at least 500 of them)! (!) I suggest you run a IP-hiding software like Steganos Internet Anonym (free download on www.steganos.com) while posting with UltraNNTP. (!!) If UltraNNTP helped you making this scheme work for you, please consider donating if only a few dollars on ultranntp.zapto.org. That little team needs your help badly to keep UltraNNTP free and make UltraNNTP 1.2 That's it! It will take you 15 minutes and will cost you $5, but it will also make you earn more than $100,000! All you have to do now is wait, and check your inbox to see PayPal money flying to you! So, what is $5 and 15 minutes when it can make you earn $100,000 ? -- http://mail.python.org/mailman/listinfo/python-list
tkinter and visual ocx
I've managed to register succesfuly an oxc with makepy and my python programm reconises the ocx. But now i have a problem to place the ocx on a tkinter frame. Perhaps somebody could show me a code snippet how to do it ? tia Rony -- http://mail.python.org/mailman/listinfo/python-list
Re: Cursor Position.
Samantha wrote: I will be using Tkinter. All I need is a way to get the X,Y position from a mouse click. I am trying to have an image loaded to click on, but that seems to be a problem. So if I can just get the position from the screen of a graphics program, showing an image, it will work for me. S If you use TkInter, use also these: http://www.pythonware.com/library/tkinter/introduction/index.htm http://infohost.nmt.edu/tcc/help/pubs/tkinter/ For mouse click position, this might be helpful: http://www.pythonware.com/library/tkinter/introduction/events-and-bindings.htm -- http://mail.python.org/mailman/listinfo/python-list
Installing Tkinter on knoppix
Greetings, Does anybody have a website where I can download a copy of Tkinter to install onto knoppix? Is it a pretty straightforward install? Cheers -Jon -- http://mail.python.org/mailman/listinfo/python-list
Re: Cursor Position.
Samantha wrote: I will be using Tkinter. All I need is a way to get the X,Y position from a mouse click. I am trying to have an image loaded to click on, but that seems to be a problem. So if I can just get the position from the screen of a graphics program, showing an image, it will work for me. Won't be easy - a toolkit (like tkinter) will only cpature your mous events that are directed towards it's own windows. You might be able to convince your program to collect mouse-events outside for a short period of time - like snapshot programs do - but that will reqiure pretty complicated, OS-dependant coding. Certainly way more complicated than loading an image using tkinter. Better tell us what's giving you a hard time there. Diez -- http://mail.python.org/mailman/listinfo/python-list
page faults when spawning subprocesses
I am working on a network management program written in python that has multiple threads (typically 20+) spawning subprocesses which are used to communicate with other systems on the network. This runs fine for a while, but eventually slows down to a crawl. Running sar shows that when it is running slowly there is an exceptionally large number of minor page faults - there are continuously 14000 faults/sec, with a variation of about +/-100. There are no pages swapped to disk, these are purely in-memory faults. I have a hypothesis about what is happening, but have not been able to prove or disprove it: the theory is that when a subprocess is spawned, there is a small window between the call to fork and the call to exec where the parent's memory is shared between the two processes. Linux marks the memory as copy-on-write, so if the parent process then accesses memory during that window a minor page fault is generated and the page is copied. Normally this is not a problem, but with a large number of threads all spawning subprocesses there is a chance of a another process being spawned during that window and the whole of memory is copied. This slows everything else down so the probability of another collision increases, and the whole thing snowballs. This could also happen if something else tries to write to large areas of memory (maybe the python garbage collector?). This is running on a Sun V40 64 bit SMP with Fedora Core 3. The same code has been run on intel systems and the problem has not been seen - this could be because the problem is specific to that hardware or because the intel systems are not fast enough for a collision to occur. My questions are: 1) is the theory plausible/likely? 2) what could I do to prove/disprove it? 3) has anyone else seen this problem? 4) are there any other situations that could be causing a continuous stream of minor page faults? 5) WTF can I do about it? Dave Kirby (dave.x.kirby at gmail dot com) -- http://mail.python.org/mailman/listinfo/python-list
Looking Python script to compare two files
hi: I want to compare two PDF or WORD files. Any Help? thx -- http://mail.python.org/mailman/listinfo/python-list
Is it a bug?
Hi, there! Now I am working around with the logging module. Here is the code: import logging log1=logging.getLogger(a) log1.critical(msg) No handlers could be found for logger a logging.critical(msg) CRITICAL:root:msg Since every logger is under the root logger, and if no handler is found for the logger, the message will be passed to upper level loggers, until the root, then why do I get the msg: No handlers could be found for logger a Thanks in advance! BR Darren Cui Liang -- http://mail.python.org/mailman/listinfo/python-list
Re: cx_Oracle callproc output parameters
infidel wrote: I have a stored procedure that has a single output parameter. Why do I have to pass it a string big enough to hold the value it is to receive? Why can't I pass an empty string or None? import cx_Oracle as oracle connection = oracle.connect('usr/[EMAIL PROTECTED]') cursor = connection.cursor() network_name, = cursor.callproc('my_pkg.get_network_name_sp', ('',)) Traceback (most recent call last): File interactive input, line 1, in ? DatabaseError: ORA-06502: PL/SQL: numeric or value error: character string buffer too small ORA-06512: at USR.MY_PKG, line 35 ORA-06512: at line 1 The following works fine, but I don't like having to do it: network_name, = cursor.callproc('my_pkg.get_network_name_sp', (' ' * 32,)) Am I missing something obvious here? Yes - where should the oracle store the data if you pass None (null-pointer!) or a too short string? The C-Api of oracle requires an INOUT-Paramter to be properly dimensioned - its like other c-calls, that take a pointer and a size argument. Thus you don't have to deal with freeing malloc'ed memory in the caller. I'm not sure about it, but possibly a _return_-value might help here, possible by using a function inbstead of a procedure. Did you try that? Of course it would require to rewrite your procedure to be a function, or if that is not possible due to others using it too, wrap it in a p/sql function. I'm a bit rusty on p/sql, so I can't wirte it out of my head. Then you could e.g. do select my_pkg.wrapped_get_network_name() from dual and wouldn't have to care about sizes. regards, Diez -- http://mail.python.org/mailman/listinfo/python-list
Re: Installing Tkinter on knoppix
Jon Monteleone wrote: Greetings, Does anybody have a website where I can download a copy of Tkinter to install onto knoppix? Is it a pretty straightforward install? Knoppix is debian-based - you can use apt-get. But installing on a CD is impossible - do you want to alter the packages that come with a knoppix? Then you need to create your own distribution based on it (which should be doable, as the plethorea of *ix-distros shows). On a persisted knoppix, just use the above mentioned apt-get. Regards, Diez -- http://mail.python.org/mailman/listinfo/python-list
not able to HTTPS page from python
Hi all, Am trying to read a email ids which will be in the form of links ( on which if we click, they will redirect to outlook with their respective email ids). And these links are in the HTTPS page, a secured http page. The point is that am able to read some links with HTTP page, but am not able to read the same when I try with HTTPS. Using the following code from sgmllib am able to read the links, class MyParser(sgmllib.SGMLParser): def __init__(self): sgmllib.SGMLParser.__init__(self) self.inside_a = False self.address = '' def start_a(self,attrs): if DEBUG: print start_a print attrs for attr,value in attrs: if attr == 'href' and value.startswith('mailto:'): self.address = value[7:] self.inside_a = True def end_a(self): if DEBUG: print end_a if self.address: print '%s %s' % (self.nickname, self.address) mailIdList.append(self.address) self.inside_a = False self.address = self.nickname = '' def handle_data(self,data): if self.inside_a: self.nickname = data And for the proxy authentication and the https handler am using the following lines of code authinfo = urllib2.HTTPBasicAuthHandler() proxy_support = urllib2.ProxyHandler ({http : http://user:[EMAIL PROTECTED]:port}) opener = urllib2.build_opener(proxy_support, authinfo, urllib2.HTTPSHandler) urllib2.install_opener(opener) Then am trying to call the parser for the links in a particular https page which will be given as a command line argument. Which will read me all the links in that page. p = MyParser() for ln in urllib2.urlopen( sys.argv[1] ): p.feed(ln) p.close() NOTE : I have installed python with _ssl support also. So with this code am able to read the links with HTTP page but not for the HTTPS page. AM NOT GETTING ANY ERRORS EITHER BUT ITS NOT READING THE LINKS, THAT ARE PRESENT IN THE GIVEN HTTPS PAGE Could you please tell me am I doing some thing wrong in the above code for any of the handlers. I have got struck here from so many days, please give me the solution for this. Thanks and regards YOGI -- http://mail.python.org/mailman/listinfo/python-list
RE: Looking Python script to compare two files
[yys2000] I want to compare two PDF or WORD files. Could you be more precise, please? + Do you only want to compare PDF-PDF or Word-Word? Or do you want to be able to do PDF-Word? + In either case, are you only bothered about the text, or is the formatting significant? + If it's only text, then use whatever method you want to extract the text (antiword, ghostscript, COM automation, xpdf, etc.) and then use the difflib module, or some external diff tool. + If you want a structure/format comparison, you're into quite difficult territory, I believe. It's easy enough to convert a Word Doc to PDF if that were needed but PDFs are notoriously difficult to disentangle, altho' relatively straightforward to build. There's pdftools (http://www.boddie.org.uk/david/Projects/Python/pdftools/) which I can't say I've tried, but even once you've got the document object into Python, I don't imagine it'll be easy to compare. + To do Word-Word comparison, there's more hope on the horizon (if that's the metaphor I want). Word has built-in comparison functionality, and recent versions of TortoiseSVN, for example include a script which will automate Word to do the right thing. Which is, essentially, one doc, and call its .Compare method against the other. TJG This e-mail has been scanned for all viruses by Star. The service is powered by MessageLabs. For more information on a proactive anti-virus service working around the clock, around the globe, visit: http://www.star.net.uk -- http://mail.python.org/mailman/listinfo/python-list
Re: Is it a bug?
Darren Cui Liang wrote: Hi, there! Now I am working around with the logging module. Here is the code: import logging log1=logging.getLogger(a) log1.critical(msg) No handlers could be found for logger a logging.critical(msg) CRITICAL:root:msg Since every logger is under the root logger, and if no handler is found for the logger, the message will be passed to upper level loggers, until the root, then why do I get the msg: No handlers could be found for logger a The error-message is always for the used logger - but it will search the list of its parents for appropriate handlers. So setting a handler on a logger foo makes the logger foo.bar find it. Or, alternatively, obtain a reference tto the root-logger, and set your handler there. Then all loggers will find it. Diez -- http://mail.python.org/mailman/listinfo/python-list
Re: Using python for writing models: How to run models in restricted python mode?
vinjvinj wrote: 2. restrict the amount of memory a module uses as well. For instance how can I restrict a user from doing a = range(100) or similar tasks so that my whole compute farm does not come down. The safest way to do this in unix is to run the model in a separate process, and use ulimit (or the resource module) to limit the memory usage. -- Jeremy Sanders http://www.jeremysanders.net/ -- http://mail.python.org/mailman/listinfo/python-list
Re: Installing Tkinter on knoppix
sudo apt-get install python2.4-tk -- http://mail.python.org/mailman/listinfo/python-list
Re: not able to HTTPS page from python
[EMAIL PROTECTED] wrote: AM NOT GETTING ANY ERRORS EITHER BUT ITS NOT READING THE LINKS, THAT ARE PRESENT IN THE GIVEN HTTPS PAGE HAVE YOU TRIED ADDING A PRINT STATEMENT TO THE FEED LOOP SO YOU CAN SEE WHAT YOU'RE GETTING BACK FROM THE SERVER ? /f -- http://mail.python.org/mailman/listinfo/python-list
Re: how to modify code while debugging it without having to stop and then restart debugger
Hi Dave, Currently there is no python debugger (that I know of) that does it, altough tools are beggining to get to it (another example outside of the python world is that eclipse already does it for java). If you use the pdb (that is the command-line debugger that comes along with python), you can do it, but it would require a considerable effort because you would have to modify it manually (with reload, assignments, etc.) -- not really a good thing in my opinion -- and you wouldn't have the easiness that is provided by visual debuggers. Now, I'm the developer of pydev (http://pydev.sf.net), that is a plugin that aims at enabling python development within eclipse (and is already used a lot in the python community), and I believe that given some time pydev will reach the functionality you're describing -- as others will probably do too -- and that's one of the reasons why pydev is being developed (the current state of tools for editing python still has space for LOTS of opportunities). So, making it short... currently you can do it but it is not easy because tools are still catching up to what python provides (I personally believe this is because it is so easy to edit python and understand the code that some people don't look for other alternatives, and end up just 'accepting' what they have because it is already better than alternatives -- altough this is only true for some given scenarios). Cheers, Fabio python wrote: thanks for all that have replied so far. i still find it __very__ hard to believe that i cannot edit code inside a function while debugging it. as i mentioned even micro$soft can do this using statically type languages like visual basic and csharp. also, both visualbasic and csharp have goto statements, which i do to not use in final code but can be real handy when used with the ability to change debugged code on the fly while inside the function being debugged. for example, if i am inside a function and there is some an error on a line and that is where the debugger is currently pointing at, i simple copy and paste the bad code line just below the actual code line. i fix this copied code line. then i just turn the bad line into a comment line and the debugger will move the current focus to the next time, which is the fixed code. how can such a dynamic language like python not be able to do this. i have seen functions like exec that can even run dynamically generated text on the fly. very strange.. any other ideas, thanks so much, dave python [EMAIL PROTECTED] wrote in message news:[EMAIL PROTECTED] hello and thanks for reading this, i have been a dos/windows user using some form of the basic language for 30 years now. i own and run a small programming company and there is one feature that keeps me in the windows/basic world. while i will agree that it has not evolved well, it does have one awesome feature that i have yet to see replicated in any linux product that i know about so far. i am a long time windows user and have had a great way to learn new api. to write some code and then run it. if there is an error, the debugger will load. then i can figure out what the eror is, just touch up the ocde and continue to run the code. i do not have to stop the code, modify the code, rerun the code. often an error will only happen after a complex set of conditions and not have to completely stop the app is a fantastic way to debug. there are several applications that can do this. in fact, the free version of the visual studio 2005, which is free, have this ability. so how can i use python to debug code and change that code without having to restart the code. thanks so much, dave -- http://mail.python.org/mailman/listinfo/python-list
Re: Application monitor
dcrespo wrote: Hi to all, I'd like to have an app monitor that gets rid of another app, in the way that if it closes unspectedly, the app monitor just wake it up one more time, and viceversa. Twisted contains such a thing. I think it's called twisted.runner, and no, it's not just for keeping Twisted processes running. -- http://mail.python.org/mailman/listinfo/python-list
Re: How to convert a number to hex number?
Bengt Richter wrote: On Wed, 09 Nov 2005 00:42:45 GMT, Ron Adam [EMAIL PROTECTED] wrote: Bengt Richter wrote: On 08 Nov 2005 08:07:34 -0800, Paul Rubin http://[EMAIL PROTECTED] wrote: dcrespo [EMAIL PROTECTED] writes: hex(255)[2:] 'ff' '%x'%255 is preferable since the format of hex() output can vary. Try hex(33**33). Not to mention ([EMAIL PROTECTED] deleted ;-) hex(-255)[2:] 'xff' hex(-255) '-0xff' hex(-2550xff) '0x1' Regards, Bengt Richter I just happen to have been playing around with converting bases the last couple of days. (idonowhy) ;-) It seems to be one of those inevitable things, enjoy it ;-) I do, it's one of the things that keeps me interested here and help me find new ideas to explore. :-) But you still use '-' + yourconversion(abs(x)) to deal with a negative number. That's what I was [EMAIL PROTECTED] about. You can't see the 'bits' in the way one was used to with the old int values. My answer was a base-complement representation, of which base-16 is a particular case. See http://groups.google.com/group/comp.lang.python/msg/d8324946fcdff8f8 and the code in the second reference from there: http://groups.google.co.uk/group/comp.lang.python/msg/359927a23eb15b3e It seems I came in the back door concerning this discussion. I hadn't read those specific threads. I think I see what direction you are going in, but I'm not sure what the actual goal is. Originally two's compliment representations were used to efficiently store signed integers when memory and processors where both real expensive slow and small. It also allowed for getting a signed number into a register in one instruction when you only had 8 bit data lines. And it was/is useful when designing electronic gate logic. So what is the need to use a compliment form in other bases now? I suppose it can still save memory, using a byte to store a value that can be stored in a single bit does seem to be a bit wasteful. Then again the same could be said for any ascii representation of numbers. Probably the most efficient way is to keep the number as integers where it will be stored in binary and only convert it to the desired base if it needs to be viewed with a __repr__ or __str__ method. hmm... I'm not sure at what point in Pythons int handling they get converted from binary to decimal? In this case the bit/byte storage issue of negative numbers would be side stepped. But if you are working with hex or binary there still may be some situations you might still want to distinguish between the twos (or ones?) compliment hexadecimal or binary data. Is this the correct issue you are referring to? I only put in characters for up to base 36, but it's a function parameter you can pass, so your digits ought to work if passed. The idea of base-complement is that the first digit is the zero digit for positive numbers and the digit for base-1 for negative numbers. This can be arbitrarily repeated to the left as fill without changing the numeric value. so for base 10 one is 01 and -1 is 99, and for hex that is 01 and FF. For base 2, 01 and 11. Etc. To make a general literal you need a prefix to the data that tells you the base value to use in interpreting the data part. A la 0x01, I proposed 0bbase value in decimal.data part So +1 -1 is 0b2.01 and 0b2.11 or octal 0b8.01 and 0b8.77 or decimal 0b10.01 and 0b10.99 and hex 0b16.01 and 0b16.ff So you are using two's compliment. 1 - 0b2.01 -1 - 0b2.11 reverse bits, add 1 3 - 0b2.0011 -3 - 0b2.1101or.. 2**4 - 3 = 13 = 1101 Then higher bases would be (base**digits)-n 3 - 0b8.03 -3 - 0b8.75 8**2 - 3 1 - 0b10.01 -1 - 0b10.99 10**2 - 1 So I presume you mean for edge cases... 89 - 0b10.89 is 89 or must it be 0b10.089 ? -89 - 0b10.921 How about preceding two's compliment with a 1b instead of 0b. then all the value digits can use as values and no padding is needed, but can still be used if desired. 3 - 0b2.11 or 0b2.0011 -3 - 1b2.101 1b2.1101 Signs could still be used also. 3 - 0b2.11 -3 - -0b2.11 I'm still trying to decide if I like the period. I think supporting arbitrary bases would be good. I was surprised their wasn't support for it in the math module. And partial support in the string module which I find kind of odd. It seems to me all of these are integers so why not subclass them from ints and supply an appropriate __repr__ and __str__ method? class hexx(int): ... def __repr__(self): ... return hex(self) ... a = hexx(100) a 0x64 b = a+a b 200 type(b) type 'int' type(a) class '__main__.hexx' Well, it would need a bit of work. ;-) Algorithmically, minus 1 can be represented with a single data digit, but that's a style issue. I think the representation of it is a style issue and the actual storage of it is a implementation
Re: python server
linuxpld [EMAIL PROTECTED] wrote in message news:[EMAIL PROTECTED] Hello I`m writing a program (server in future) in python. I would like to write it in such a way that I will be able to write gui in any language and connect to my python program and use functionality included with it. are there any libraries that I could use? That depends on what you want and what other goodies you want. I liked Python Web Modules http://www.pythonweb.org/ a lot, mostly because I needed a decent Database interface and because you do not have to buy the entire framework like you do with f.ex. CORBA if you only want to use some of it. Everything runs a browser these dayz. Another possibility is to write a command-line interpreter that takes commands from a socket and returns results. All ASCII of course. ASCII is easy to debug. This is very generic, robust and easy to write test scripts for. The disadvantage is that you need a parser in the GUI and one in the Application. The huge advantage is that you completely separate the internals of the two programs from each other. Most client-server UNIX/Linux applications are written this way; i.e. this programming method survives in the wild because it is stable and it works. The RPC frameworks tend to run up on a wild hype-cycle before being generally left to maintenance programmers to sort out. Consider a Mailbox system, where packages of work is send to a server process and processed results are shipped back to the client process. The trick is to keep all state inside the work packages so the servers do not need to track anything. MAKE is a file-based implementation of this. OTOH: For Python - Python situations, the Python Remote Objects, PYRO is not bad at all. And it does have an Event mechanism, which can be used as a Mailbox service. For reliable shared memory tasks ZOPE is good or maybe SPREAD. CORBA is overkill for everything, IMO ;-) I dont know if i wrote it understandably but maybe picture will explain it: || | python | || - module in python - - connection (???) - -gui in any language (java, c++, python, etc). | server | |---| what could I use as http? mqseries? webservices? what are the possibilites? thx for answers linuxfan -- http://mail.python.org/mailman/listinfo/python-list
Hi, from my login i want to login as a other user ,
Hi, from my login i want to login as a other user , how can i do it using python. -- http://mail.python.org/mailman/listinfo/python-list
Re: page faults when spawning subprocesses
Dave Kirby wrote: 5) WTF can I do about it? Maybe using vfork rather than fork would help. But I'm not sure that will work as intended when there are multiple threads, in fact I'm not sure fork will work either. You could have fork racing against another thread being in a critical region thus duplicating the memory map at some point where some data structures are in an inconsistent state and apparently locked by some thread existing in the parent. A possible solution would be to use fork to create two processes before creating any threads. Have the communicate over pipes or sockets when new processes are to be created. Then one process can create all the threads you need, and the other can fork off children. Even in that case vfork may come in handy. If you dislike the semantics of vfork, but still want the parent to block until the child has called execve, then you can do so manually using a pipe. Create the pipe before calling fork, in parent process you close write end and try to read from the pipe, in child process you close read end and mark write end close on exec. When exec succeeds, the pipe is closed and parent gets EOF. (I have tried some of this in C, but I must admit, I don't know if it can be done in Python as well.) -- Kasper Dupont Note to self: Don't try to allocate 256000 pages with GFP_KERNEL on x86. -- http://mail.python.org/mailman/listinfo/python-list
How to use generators?
Spoiler Alert - Anyone at Level 24 in Python Challenge may not want to read this post! I have never used generators before but I might have now found a use for them. I have written a recursive function to solve a 640x640 maze but it crashes, due to exceeding the stack. The only way around this I can think of is to use Generator but I have no idea how to. The function is as below: def solve_maze(x,y): if y = 0: success = 1 elif x = 0 or x 640 or y = 640: success = 0 elif maze_array[x][y] == 1: success = 0 elif im.getpixel((x,y)) == (255, 255, 255, 255): success = 0 else: maze_array[x][y] = 1 if solve_maze(x,y-1) == 1: success = 1 elif solve_maze(x+1,y) == 1: success = 1 elif solve_maze(x-1,y) == 1: success = 1 else: success = solve_maze(x,y+1) if success == 1: print im.getpixel((x,y)) return success #Main wibble = solve_maze(x,y) -- http://mail.python.org/mailman/listinfo/python-list
Re: Hi, from my login i want to login as a other user ,
sumi wrote: Hi, from my login i want to login as a other user , how can i do it using python. http://www.catb.org/~esr/faqs/smart-questions.html -- 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: debugger
is there a way to only look at specific variable names in Winpdb? It takes forever to debug something when i constantly have to search for variables. [EMAIL PROTECTED] wrote in message news:[EMAIL PROTECTED] Benji York wrote: [EMAIL PROTECTED] wrote: Benji York wrote: You might like Winpdb: http://www.digitalpeers.com/pythondebugger/ Not Found The requested URL /pythondebugger/-- was not found on this server. Apache/2.0.52 (Red Hat) Server at www.digitalpeers.com Port 80 shrug Works for me. -- Benji York Yeah, for some reason my browser was appending /-- to the link. I figured that out (little slow today) and pulled my post. -- http://mail.python.org/mailman/listinfo/python-list
Re: Hi, from my login i want to login as a other user ,
Hi, i am very new to python , it is just 2 days i started reading abt it. I did not understand the above statement. what i want to do is , i want to login as a super user eg : $su xyz , and then i need to enter the passwd, i want to do these steps using python , how can i do it?? -- http://mail.python.org/mailman/listinfo/python-list
Re: Newb ??
## Here you always get 100... This is false , sorry for the wrong comment on this part, it should rather be: ## randrange is from start to end-1 the_number = random.randrange(1,101) JM (But the rest of my comment seems OK) -- http://mail.python.org/mailman/listinfo/python-list
Re: cx_Oracle callproc output parameters
infidel wrote: I have a stored procedure that has a single output parameter. Why do I have to pass it a string big enough to hold the value it is to receive? Why can't I pass an empty string or None? [...] Am I missing something obvious here? You have to use variable objects to the callproc() that will hold the output values. This is an example using three VARCHAR output parameters. HTH, -- Gerhard import cx_Oracle con = cx_Oracle.connect(user/[EMAIL PROTECTED]) cur = con.cursor() l_SchemaName = cur.var(cx_Oracle.STRING) l_DbName = cur.var(cx_Oracle.STRING) l_DomainName = cur.var(cx_Oracle.STRING) cur.callproc(TP_Lookup.GetSchema, (l_SchemaName, l_DbName, l_DomainName)) print You are connected to, print the schema, l_SchemaName.getvalue(), print at %s.%s % (l_DbName.getvalue(), l_DomainName.getvalue()) -- http://mail.python.org/mailman/listinfo/python-list
Re: Hi, from my login i want to login as a other user ,
sumi wrote: Hi, i am very new to python , it is just 2 days i started reading abt it. I did not understand the above statement. what i want to do is , i want to login as a super user eg : $su xyz , and then i need to enter the passwd, i want to do these steps using python , how can i do it?? You're probably looking for the setuid() and setgid() functions in the module `os`. -- Gerhard -- http://mail.python.org/mailman/listinfo/python-list
triangulation
is there any sample code to triangulation? many thanks! -- http://mail.python.org/mailman/listinfo/python-list
Re: PYTHON LOOSING FOR JAVA???????
Fcamattti [EMAIL PROTECTED] writes: Hello for everybody OH MY GOD!?!?!?!?!?!?! I BETTER FIND A NEW JOB!?!?!?!? S. -- http://mail.python.org/mailman/listinfo/python-list
Re: Goto XY
OK - I added the import WConio line. But when I run import WConio print going to x10,y10... WConio.gotoxy(10,10) print Done the above, I get the following error: WConio.gotoxy(10,10) error: GetConOut Failed I installed the WConio to the ../site-packages/ folder in Python24, and when it didn't work I also moved the files in there to the /Lib/ folder where other things are like random, but that didn't seem to work either. -- http://mail.python.org/mailman/listinfo/python-list
Any available SAML 2.0 tools in Python ?
Hi! The subject says it all. If there isn't anything already available, does anyone know about anyone working on something ? -- Roland -- http://mail.python.org/mailman/listinfo/python-list
Re: Goto XY
[ale.of.ginger] WConio.gotoxy(10,10) error: GetConOut Failed Are you running at a Windows Command Prompt, or in an IDE? As I understand it, WConio will only work in a Windows Command Prompt. -- Richie Hindle [EMAIL PROTECTED] -- http://mail.python.org/mailman/listinfo/python-list
Re: python server
Magnus Lycka [EMAIL PROTECTED] wrote in message news:[EMAIL PROTECTED] Thee are many solutions. An XML-RPC server springs to mind as a solution. There are several Python XML-RPC servers . Good Idea. Seems that those particular batteries are included with Python 2.2 and up: OP: See help on: SimpleXMLRPCServer and xmlrpclib -- http://mail.python.org/mailman/listinfo/python-list
append to non-existing list
Hello, if I do this: for row in sqlsth: pkcolumns.append(row[0].strip()) etc without a prior: pkcolumns = []; I get this error on first iteration: UnboundLocalError: local variable 'pkcolums' referenced before assignment I guess that's normal as it's the way python works...?!? My question is: Is there no way to append to a non existing list? I am lazy for declaring it first, IMHO it bloats the code, and (don't know if it's good to say that here) where I come from (php) I was used to not-needing it... regards, Yves -- http://mail.python.org/mailman/listinfo/python-list
Re: triangulation
Shi Mu wrote: is there any sample code to triangulation? many thanks! Triangulation of what? Scattered points in a plane? 2D manifolds embedded in a 3D space? Delaunay triangulations? Constrained triangulations? -- Robert Kern [EMAIL PROTECTED] In the fields of hell where the grass grows high Are the graves of dreams allowed to die. -- Richard Harter -- http://mail.python.org/mailman/listinfo/python-list
Re: append to non-existing list
Hi I think there's no way to append to a non existing list. Sorry about my question, but the English is my second language, and I don't know what is the meaning of IHMO (or IMHO). I googled and found that it means In My Humbled Opinion, is that true? Thanks and accept my appologies for not talking entirely about your problem. Daniel -- http://mail.python.org/mailman/listinfo/python-list
Re: Get the pid of a os.startfile(filename)
Hi! That works perfect! But how I do it in a Win98? Does the win32all library have a standard way to do it? Thank you Daniel -- http://mail.python.org/mailman/listinfo/python-list
Re: append to non-existing list
I am afraid you have to either go back to php or whatever programming language that fits your style or change your style to fit python. There is a lot I don't like about python but if you have to use it, you have to cope with it. Yves Glodt wrote: My question is: Is there no way to append to a non existing list? I am lazy for declaring it first, IMHO it bloats the code, and (don't know if it's good to say that here) where I come from (php) I was used to not-needing it... regards, Yves -- http://mail.python.org/mailman/listinfo/python-list
Re: append to non-existing list
Yves Glodt wrote: if I do this: for row in sqlsth: pkcolumns.append(row[0].strip()) etc without a prior: pkcolumns = []; I get this error on first iteration: UnboundLocalError: local variable 'pkcolums' referenced before assignment I guess that's normal as it's the way python works...?!? My question is: Is there no way to append to a non existing list? how do you expect Python to figure out what kind of empty object you want ? /F -- http://mail.python.org/mailman/listinfo/python-list
Re: Application monitor
Many thanks for your answers. Respect Init, I need a cross platform solution. Most of times my system will run in Win98 and XP (more on XP than 98) Respect Twisted... Mmm... I already started with another networking library (TCPServer and SimpleXMLRPCServer), and I wouldn't like to mix things because I don't know so much about those libraries. I know that Twisted can do what I already have. But replacing it can be a hard task. So I would like to have a function like FindPID(exename) -- PID, or something more generic that could tell me the PID of a running program, and kill him in a certain moment. Daniel -- http://mail.python.org/mailman/listinfo/python-list
Re: PYTHON LOOSING FOR JAVA???????
Steven D'Aprano wrote: Alex Martelli wrote: [...] Taking a leaf from the various publishers and author's guilds out there... Obviously Google is threatening the profitability of programmers and their ability to make a honest day's living. Why would people hire programmers to create new innovative solutions, when they can just use Google to search teh Interweb for source code which Google has stolen from the rightful owners??? *wink* The obvious answer is send your CV to Alex... *wink*, *wink* If-you-can't-lick-'em-join-'em-ly y'rs, Nicola Musatti -- http://mail.python.org/mailman/listinfo/python-list
Re: append to non-existing list
Yves My question is: Is there no way to append to a non existing list? My question in return is: How is Python supposed to know that pkcolumns is supposed to be a list instead of some other type of object that happens to define an append() method? For example, my code might contain this class definition before the suspect pkcolumns.append() call: class MaxLengthList: def __init__(self, maxsize=0): self.data = [] self.maxsize = maxsize def append(self, item): if self.maxsize and len(self.data) == self.maxsize: del self.data[0] self.data.append(item) def __getattr__(self, attr): return getattr(self.data, attr) I think it would be perfectly reasonable for Python to choose to instantiate my MaxLengthList instead of a plain old list. Yves I am lazy for declaring it first, IMHO it bloats the code, and Yves (don't know if it's good to say that here) where I come from (php) Yves I was used to not-needing it... I don't know php, but would also have to wonder how it knows to create a list instead of an integer (for example). Finally, from the Zen of Python (try import this at an interpreter prompt): In the face of ambiguity, refuse the temptation to guess. Skip -- http://mail.python.org/mailman/listinfo/python-list
Re: page faults when spawning subprocesses
Dave Kirby wrote: I am working on a network management program written in python that has multiple threads (typically 20+) spawning subprocesses which are used to communicate with other systems on the network. ... Let me check if I got you right: You are using fork() inside a thread in a multi-threaded environment. That sounds complicated. :-) Have a look at http://www.opengroup.org/onlinepubs/009695399/functions/fork.html It mentions your use of fork, i.e. to create a new process running a different program (in this case the call to fork() is soon followed by a call to exec()). If you fork in your multi-threaded environment, what happens with all your threads? The document resorts to the effects of calling functions that require certain resources between the call to fork() and the call to an exec function are undefined.. Maybe you are just experiencing this :-) The document above recommends: to avoid errors, the child process may only execute async-signal-safe operations until such time as one of the exec functions is called. Maybe this discussion is also of some help: http://groups.google.com/group/comp.programming.threads/browse_thread/thread/37fe7e050b44c329/217660515af867ea?tvc=2#217660515af867ea Cheers Daniel -- http://mail.python.org/mailman/listinfo/python-list
Re: append to non-existing list
Yves Glodt wrote: Hello, if I do this: for row in sqlsth: pkcolumns.append(row[0].strip()) etc without a prior: pkcolumns = []; I get this error on first iteration: UnboundLocalError: local variable 'pkcolums' referenced before assignment I guess that's normal as it's the way python works...?!? My question is: Is there no way to append to a non existing list? I am lazy for declaring it first, IMHO it bloats the code, and (don't know if it's good to say that here) where I come from (php) I was used to not-needing it... regards, Yves You mean you want to type pkcolumns only once to keep your code short? Would something like this be useful? pkcolumns = [row.strip() for row in sqlsth] -- http://mail.python.org/mailman/listinfo/python-list
Re: append to non-existing list
If PHP is heavily influenced by Perl(as I read some where), the variable name determine it I believe. @myvar is an array ? [EMAIL PROTECTED] wrote: I don't know php, but would also have to wonder how it knows to create a list instead of an integer (for example). Skip -- http://mail.python.org/mailman/listinfo/python-list
Re: append to non-existing list
[EMAIL PROTECTED] wrote: Yves My question is: Is there no way to append to a non existing list? My question in return is: How is Python supposed to know that pkcolumns is supposed to be a list instead of some other type of object that happens to define an append() method? I am fairly new to python (and I like it more and more), but I can not answer this question... As I said, where I come from it is possible, and how they do it is explained a little here: http://lu.php.net/manual/en/language.types.type-juggling.php As I want to learn, I will work with python the pythonic way, but sometimes I just fall back to what I know from php... :-) Thanks for your answer and the example code, Yves p.s. thanks for the import this hint For example, my code might contain this class definition before the suspect pkcolumns.append() call: class MaxLengthList: def __init__(self, maxsize=0): self.data = [] self.maxsize = maxsize def append(self, item): if self.maxsize and len(self.data) == self.maxsize: del self.data[0] self.data.append(item) def __getattr__(self, attr): return getattr(self.data, attr) I think it would be perfectly reasonable for Python to choose to instantiate my MaxLengthList instead of a plain old list. Yves I am lazy for declaring it first, IMHO it bloats the code, and Yves (don't know if it's good to say that here) where I come from (php) Yves I was used to not-needing it... I don't know php, but would also have to wonder how it knows to create a list instead of an integer (for example). Finally, from the Zen of Python (try import this at an interpreter prompt): In the face of ambiguity, refuse the temptation to guess. Skip . -- http://mail.python.org/mailman/listinfo/python-list
Re: append to non-existing list
[EMAIL PROTECTED] wrote: I am afraid you have to either go back to php or whatever programming language that fits your style or change your style to fit python. sorry for offending... I just asked a question, and now I know one more thing about python... And btw I really am surprised by the amount of answers that my question rose, in so little time! thanks all! There is a lot I don't like about python but if you have to use it, you have to cope with it. Yves Glodt wrote: My question is: Is there no way to append to a non existing list? I am lazy for declaring it first, IMHO it bloats the code, and (don't know if it's good to say that here) where I come from (php) I was used to not-needing it... regards, Yves -- http://mail.python.org/mailman/listinfo/python-list
Re: append to non-existing list
Juho Schultz wrote: Yves Glodt wrote: Hello, if I do this: for row in sqlsth: pkcolumns.append(row[0].strip()) etc without a prior: pkcolumns = []; I get this error on first iteration: UnboundLocalError: local variable 'pkcolums' referenced before assignment I guess that's normal as it's the way python works...?!? My question is: Is there no way to append to a non existing list? I am lazy for declaring it first, IMHO it bloats the code, and (don't know if it's good to say that here) where I come from (php) I was used to not-needing it... regards, Yves You mean you want to type pkcolumns only once to keep your code short? Would something like this be useful? pkcolumns = [row.strip() for row in sqlsth] I will look into this, maybe it's what I need, thanks! -- http://mail.python.org/mailman/listinfo/python-list
Re: append to non-existing list
Yves Glodt wrote: Hello, if I do this: for row in sqlsth: pkcolumns.append(row[0].strip()) etc without a prior: pkcolumns = []; I get this error on first iteration: UnboundLocalError: local variable 'pkcolums' referenced before assignment I guess that's normal as it's the way python works...?!? yes sir. My question is: Is there no way to append to a non existing list? No. Definitively. And that's a Good Thing(tm). How would you use something that doesn't exist ??? I am lazy for declaring it first, s/declaring/instantiating/ If you were to use your own class Toto, would you ever hope that the following code would work : for v in some_seq: toto.dothis(v) without instantiating Toto and binding it to the name 'toto' before ? Well, in Python, a list is an instance of class list. There are syntactic sugar to instanciate a list (or a tuple or a string or a dict etc), but this: my_list = [] is strictly equivalent to this: my_list = list() Now let's try something else: class Machin(object): def append(self, value): pass class Bidule(object): def append(self, value): pass for i in range(10): m.append(i) How should Python interpret this ? Should it create a list, or a Machin, or a Bidule, or an instance of whatever imported class having a append() method ? IMHO it bloats the code, run your python interpreter and type: import this Then read carefully. Now if being explicit still hurts your personal convictions, there's this other language with a name starting with p... !-) and (don't know if it's good to say that here) where I come from (php) I was used to not-needing it... Not creating an Array before using it is Bad Style in PHP (and generate a Warning BTW). There are warts in Python (as in any other languages), and there are things that sometimes bore me but are not really warts. But having to explicitely instanciate objects can't be seen as a wart in any language IMHO !-) -- 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: append to non-existing list
Juho Schultz wrote: Yves Glodt wrote: Hello, if I do this: for row in sqlsth: pkcolumns.append(row[0].strip()) etc You mean you want to type pkcolumns only once to keep your code short? Would something like this be useful? pkcolumns = [row.strip() for row in sqlsth] I don't think this is the same as his original code though. There is an etc there. Your version is cleaner and easier to understand but it can mean another extra pass to go through the result and if sqlsth is an iterable, it needs to be saved away before iterating it. -- http://mail.python.org/mailman/listinfo/python-list
Re: cx_Oracle callproc output parameters
Gerhard Häring wrote: You have to use variable objects to the callproc() that will hold the output values. This is an example using three VARCHAR output parameters. Oh boy, one never stops learning... I still thing a single in-out-value is crying for a function - but in case of several parameters, this of course is way more elegant as it requires no knowledge about the column-size beforehand. Regards, Diez -- http://mail.python.org/mailman/listinfo/python-list
Re: Diff. between Class types and classic classes
Bruno Desthuilliers wrote: Colin J. Williams a écrit : bruno at modulix wrote: venk wrote: Hi, can some one properly explain the differences between class types and classic classes? ... Still face problems in identifying what is what. I'm not sure I understand your question. Are you talking about the diff between old-style and new-style classes, or the diff between classes and metaclasses ? new classes inherit from object. Classic classes do not. (snip) I hope that this helps. Colin, I don't personaly need much help with this !-) In fact, your answer is almost the same as the one I was going to post - before I re-read the OP's question. And I'm still not sure that what the OP is looking for. Bruno, Sorry, my reponse should have been addressed to venk. Colin W -- http://mail.python.org/mailman/listinfo/python-list
Re: append to non-existing list
Yves Glodt [EMAIL PROTECTED] writes: I guess that's normal as it's the way python works...?!? Yes, that's the way Python works. My question is: Is there no way to append to a non existing list? The next time you go shopping at your local super-market, do *not* get a shopping-cart (or shopping-basket, or any similar container). As you pick up the things you want to buy, try to put them into the non-existing cart. Perhaps you will then become enlightened. I am lazy for declaring it first, IMHO it bloats the code, and (don't know if it's good to say that here) where I come from (php) I was used to not-needing it... Basically you want Python to automatically create a list out of nowhere and bind a variable to that list when you try to access a variable that doesn't exist in a certain way. How do you propose that Python should now that it is a *list* you want, and not some other kind of object? There actually is a way to do what you want: for row in sqlsth: try: pkcolumns.append(row[0].strip()) except NameError: pkcolumns = [ row[0].strip() ] However, as you see it is much more work than to do it the right way. It's also much more fragile; think for example about what happens if your SQL statement (I assume that's what sqlsth is) yields zero rows, and you then try to look at pkcolumns after that loop. -- Thomas Bellman, Lysator Computer Club, Linköping University, Sweden God is real, but Jesus is an integer. ! bellman @ lysator.liu.se ! Make Love -- Nicht Wahr! -- http://mail.python.org/mailman/listinfo/python-list
PyCon 2006 Call for Tutorials
PyCon 2006 Call for Tutorials -- Enjoy teaching classes or tutorials? PyCon 2006 is looking for proposals for a pre-conference tutorials day. PyCon 2006 will be held February 24-26 in Addison, Texas (near Dallas). Tutorials will be held on February 23, at the same location. Tutorial sessions will be a half day (3 hours, with a 15-minute break); presenters may request two sessions in order to make up a full day. Tutorials may be on any topic, but obviously should be instructional in nature. Providing take-home materials for attendees is encouraged, and tutorial presenters will receive $50 per student registered for theirsession (with a minimum payment of $500, and a maximum of $1500). Extra consideration will be given to presenters with prior experience teaching classes or giving conference tutorials. Please provide one reference or evidence of such prior experience (sessions taught at OSCON, EuroPython, local user groups, etc.). PyCon attendees will register for tutorials. We reserve the right to cancel tutorials with low attendance; presenters will not be paid for cancelled tutorials. Example tutorial topics can be found at: http://us.pycon.org/TX2006/Tutorials Important Dates === * Submission deadline: November 15, 2005 * Acceptance deadline: November 22, 2005 * Cancellation date: January 15, 2006 (for inadequate attendance) Submission Format Proposals should be 250 to 1000 words long (i.e., one to four pages in manuscript format), containing the following information: * Author name(s) * Contact Information * (Recommended) At least one previous presentation/teaching engagement reference * Summary of proposed presentation * Presentation outline * Intended audience (non-programmers, beginning programmers, advanced users, CPython developers, etc.) E-mail your proposal to [EMAIL PROTECTED]. ASCII format is preferred (plain or reST), with HTML as a secondary alternative. If you have any questions about submission, please send mail to the conference organizers at [EMAIL PROTECTED] -- http://mail.python.org/mailman/listinfo/python-list
Re: Python doc problem example: gzip module (reprise)
Mike Meyer wrote: Xah Lee [EMAIL PROTECTED] writes: Newsgroups: comp.lang.perl.misc PS: I won't cross-post as I'm not subscribed to the Python group. Very wisely done. Then from Xah Lee, we get; I have cross posted it for you. Proving once again that he's stupider than spam. Please help google find him that way by adding this link to your pages: a href=http://xahlee.org/;stupider than spam/a thank you, mike Ah, but is he stupider spam, spam, spam, spam, bacon, eggs, and spam? -- http://mail.python.org/mailman/listinfo/python-list
Re: how to modify code while debugging it without having to stop and then restart debugger
python wrote: so how can i use python to debug code and change that code without having to restart the code. I don't know how well the commercial GUIs, such as Wing IDE manage to handle debugging. Perhaps that's worth looking into. It's my impression that debugger support in Python is weaker than e.g. VB, because Python programmers don't need and use debuggers so much. I think there are several reasons for this: - It's easy to experiment with code in the interactive interpreter. - Python programs don't dump. There is rarely a need to put a breakpoint at some known safe place and single-step from there until it crashes, and then redo everything, trying to find at what place before the crash you really had your bug. You'll almost always get a controlled exception in Python. - The tracebacks you get when exceptions appear are very informative, and typically enough to spot the bugs more or less at once. I debugged python programs I've never seen before last night and today. There were maybe half a dozen bugs, and in all cases, the tracebacks showed me exactly what I needed to do to fix the problems at once. - Due to Python's expressiveness, typical Python programs are shorter and simpler than comparable programs written in other languages. If you have spaghetti code, you really need to single-step to understand what is going on. Python code is typically well structured. - With Python, it's common that people write unit tests using e.g. the unittest or doctest libraries. With a test driven approach as described in Extreme Programming, you run your tests very often, with small changes in the code between each test run. - With object-oriented programming, it's easier to structure your code so that each chunk of code (e.g. method) is easy to understand. In other words, the divide and conquer approach to problem solving works better. I guess another reason is that Microsoft has put a lot of money into making VB and friends user friendly. These products are very much geared into accomodating beginners, and a nice looking GUI has been a very high priority. For an open source tool such as Python, where the people who drive development are the people who need to use the tool, being beginner friendly isn't the top priority (even though Python has succeeded well in that regard anyway). Aspects such as stability and consistency in semantics is considered much more important. (VB has a prettier GUI, but Python is a much prettier language...) -- http://mail.python.org/mailman/listinfo/python-list
Re: Any available SAML 2.0 tools in Python ?
On 11/9/05, Roland Hedberg [EMAIL PROTECTED] wrote: Hi!The subject says it all.If there isn't anything already available, does anyone know aboutanyone working on something ? Have you talked to any developers of Lasso? (http://lasso.entrouvert.org) It has Python bindings, and the project also produced Souk, a Python framework that implements the Liberty Alliance ID-FF 1.2 protocols. They might be working on future versions for SAML 2. -- http://mail.python.org/mailman/listinfo/python-list
Re: append to non-existing list
bruno at modulix wrote: Yves Glodt wrote: Hello, if I do this: for row in sqlsth: pkcolumns.append(row[0].strip()) etc without a prior: pkcolumns = []; I get this error on first iteration: UnboundLocalError: local variable 'pkcolums' referenced before assignment I guess that's normal as it's the way python works...?!? yes sir. My question is: Is there no way to append to a non existing list? No. Definitively. And that's a Good Thing(tm). How would you use something that doesn't exist ??? I am lazy for declaring it first, s/declaring/instantiating/ If you were to use your own class Toto, would you ever hope that the following code would work : for v in some_seq: toto.dothis(v) without instantiating Toto and binding it to the name 'toto' before ? Well, in Python, a list is an instance of class list. There are syntactic sugar to instanciate a list (or a tuple or a string or a dict etc), but this: my_list = [] is strictly equivalent to this: my_list = list() Now let's try something else: class Machin(object): def append(self, value): pass class Bidule(object): def append(self, value): pass for i in range(10): m.append(i) How should Python interpret this ? Should it create a list, or a Machin, or a Bidule, or an instance of whatever imported class having a append() method ? ok I see your point, and python's... (just FYI, and not to start a flamewar ;-): In php, the [] means append to an array object. If the array does not exist yet, it's created. [] *is* explicit for arrays, thus for php it's clear what you want.) IMHO it bloats the code, run your python interpreter and type: import this Then read carefully. Now if being explicit still hurts your personal convictions, there's this other language with a name starting with p... !-) no thanks, this is the 21st century ;-) and (don't know if it's good to say that here) where I come from (php) I was used to not-needing it... Not creating an Array before using it is Bad Style in PHP (and generate a Warning BTW). an undefined notice, yes, not a warning... ;-) There are warts in Python (as in any other languages), and there are things that sometimes bore me but are not really warts. But having to explicitely instanciate objects can't be seen as a wart in any language IMHO !-) Ok... I thank you for all the explanations. It helps me to see more far. I (and will continue to) use php for web, and wanna standardize on python for all non-web stuff we are doing, so I might be a frequent guest on this list... have a nice day, Yves -- http://mail.python.org/mailman/listinfo/python-list
Wrapping C functions in Pyrex and distutils problem
I'm trying to get a wrapper for my C code in order to be able to use it as a module in Python. I'm doing it as follows: C code (file_c.c): --- #include stdio.h void hello( int size ) { printf(Hello! %d\n, size); } --- Pyrex code (file.pyx): --- cdef extern void hello( int size ) --- Python code (setup.py): --- from distutils.core import setup from distutils.extension import Extension from Pyrex.Distutils import build_ext setup( name = File, ext_modules=[ Extension( file, [file.pyx, file_c.c] ) ], cmdclass = { 'build_ext': build_ext } ) --- After $ python setup.py build_ext --inplace all is compiled ok, but the shared library (file.so) is built only from one file (file_c.o) - and the second object file (file.o) is ignored. Of course it's imposible to import such a module in Python. What am I doing wrong? -- http://mail.python.org/mailman/listinfo/python-list
need an example of Python numarray to C++ and back again, Boost / SWIG?
I want to pass a 2D array from Python to C++, manipulate it in C++ (for example, add 1 to each element) and pass it back to Python. With these building blocks I will be able to figure out all the rest of what I need to do for my project. I am very familiar with Python, but less so with C++ and Boost or SWIG. Does anyone have an example with all steps that I can follow? More specifically I am looking for the C++ code, .i file for SWIG and/or the analagous setup files that Boost would need to do this. Thanks in advance for any help you can provide, -- http://mail.python.org/mailman/listinfo/python-list
Re: cx_Oracle callproc output parameters
Thanks! On 11/9/05, Gerhard Häring [EMAIL PROTECTED] wrote: infidel wrote: I have a stored procedure that has a single output parameter. Why do I have to pass it a string big enough to hold the value it is to receive? Why can't I pass an empty string or None? [...] Am I missing something obvious here? You have to use variable objects to the callproc() that will hold the output values. This is an example using three VARCHAR output parameters. HTH, -- Gerhard import cx_Oracle con = cx_Oracle.connect(user/[EMAIL PROTECTED]) cur = con.cursor() l_SchemaName = cur.var(cx_Oracle.STRING) l_DbName = cur.var(cx_Oracle.STRING) l_DomainName = cur.var(cx_Oracle.STRING) cur.callproc(TP_Lookup.GetSchema, (l_SchemaName, l_DbName, l_DomainName)) print You are connected to, print the schema, l_SchemaName.getvalue(), print at %s.%s % (l_DbName.getvalue(), l_DomainName.getvalue()) -- http://mail.python.org/mailman/listinfo/python-list
Re: struct.calcsize problem
Thanks for the helpful feedback. I guessed it was the alignment issue, but could not find the exact format for changing the default. It is not mystery any more! Bengt Richter wrote: On 7 Nov 2005 15:27:06 -0800, Chandu [EMAIL PROTECTED] wrote: In using the following struct format I get the size as 593. The same C struct is 590 if packed on byte boundary and 596 when using pragma pack(4). I am using pack(4) and added 3 spares at the end to get by. hdrFormat = '16s 32s 32s B 8s H 8s H 4s H H 20s 64s 64s 64s 32s 32s 64s L L B B B B B 64s 64s' Any ideas on what I am doing wrong? Looks to me like you are getting default native byte order and _alignment_ and some pad bytes are getting added in. For native order with no padding, try prefixing the format string with '=' hdrFormat '16s 32s 32s B 8s H 8s H 4s H H 20s 64s 64s 64s 32s 32s 64s L L B B B B B 64s 64s' If you add up the individual sizes, padding doesn't happen, apparently: map(struct.calcsize, hdrFormat.split()) [16, 32, 32, 1, 8, 2, 8, 2, 4, 2, 2, 20, 64, 64, 64, 32, 32, 64, 4, 4, 1, 1, 1, 1, 1, 64, 64] sum(map(struct.calcsize, hdrFormat.split())) 590 But default: struct.calcsize(hdrFormat) 593 Apparently is native, with native alignment I get the same as you: struct.calcsize('@'+hdrFormat) 593 Whereas native order standard (no pad) alignment is: struct.calcsize('='+hdrFormat) 590 Little endian, standard alignment: struct.calcsize(''+hdrFormat) 590 Big endian, standard alignment struct.calcsize(''+hdrFormat) 590 Network (big endian), standard alignment: struct.calcsize('!'+hdrFormat) 590 I guess if you want alignment for anything non-native, you have to specify pad bytes where you need them (with x format character). Regards, Bengt Richter -- http://mail.python.org/mailman/listinfo/python-list
Re: append to non-existing list
[EMAIL PROTECTED] wrote: Thomas Bellman wrote: The next time you go shopping at your local super-market, do *not* get a shopping-cart (or shopping-basket, or any similar container). As you pick up the things you want to buy, try to put them into the non-existing cart. Perhaps you will then become enlightened. But in PHP(and I believe Perl), it is more like : oops, I need a cart. shoutHello, I need a cart here, please and magically, someone wheel you a cart which you can put your stuff in. The @ is the magic calls for service. So as a customer, this sounds like better service but that will create problems to the super market as it need extra staff for this service and the environment is noiser, that is another story. :-) I will never mention any p-language except python in this list anymore... -- http://mail.python.org/mailman/listinfo/python-list
Re: How to use generators?
Ian Vincent enlightened us with: I have never used generators before but I might have now found a use for them. I have written a recursive function to solve a 640x640 maze but it crashes, due to exceeding the stack. The only way around this I can think of is to use Generator but I have no idea how to. A better way is to use a queue. I had the same problem with a similar piece of code. The only thing why you're using a stack is to move to the next point, without going back to a visited point. The non-recursive solution is to mark all visited points as such, only consider non-visited points, and then append the coordinates to a list of points yet to visit. Then keep looping over your code until either you found the solution to the maze or there are no points left to visit. 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: append to non-existing list
Yves Glodt wrote: I am fairly new to python (and I like it more and more), but I can not answer this question... As I said, where I come from it is possible, and how they do it is explained a little here: http://lu.php.net/manual/en/language.types.type-juggling.php but that page doesn't discuss the same thing; it says is that you don't have to specify the type when you create a variable, which applies to Python too: x = 10 # x is now an integer x = string # x is now a string It also says that PHP converts things on the fly when you to operations that involve different types. Python does that for some types... x = 10 + 5.5 # 15.5 x = hello + uworld # uhelloworld but requires you to spell things out in cases where the types don't have a natural relation: x = 10 + 20 # should this be 30 or 1020 or 1020 or ...? x = int(10) + 20 # 30 x = 10 + str(20) # 1020 In your case, you're using x.somemethod(somevalue) which only provides two clues: you want x to be something that has a method with a given name, and you're passing in some value. That's not enough information to figure out that you want a list and not some other object that happens to have a method with the same name. /F -- http://mail.python.org/mailman/listinfo/python-list
Re: append to non-existing list
Max M wrote: Yves Glodt wrote: bruno at modulix wrote: Yves Glodt wrote: Hello, if I do this: for row in sqlsth: pkcolumns.append(row[0].strip()) etc without a prior: pkcolumns = []; I get this error on first iteration: UnboundLocalError: local variable 'pkcolums' referenced before assignment I guess that's normal as it's the way python works...?!? Well you could do something like this. (Untested and unrecommended) self.__dict__.setdefault('pkcolumns', []).append(row[0].strip()) Personally I find pkcolumns = [] pkcolumns .append(row[0].strip()) to be nicer ;-) Yes me too, I'm gonna stick to that... :-) -- http://mail.python.org/mailman/listinfo/python-list
Pythonising the vim (e.g. syntax popups)
Evening, I'm an addicted vim user and don't really use the IDLE for anything more than calculations where I'm too lazy to start KCalc. But one feature is very pretty: the built-in help for function calls while you type. Like you enter... var1,var2=mystring.split( ...and the IDLE shows me a popup saying... S.split([sep [,maxsplit]]) - list of strings Is there a decent way to get that help into vim? Or like showing docstrings or help that I get through pydoc on request? I've been working myself through a pile of vim macros/plugins but couldn't find even one which simplifies programming in Python. Further issues would be handling the indentation - maybe a plugin which syntax colors different levels of indentation so I don't have to use my plastic ruler on the screen. ;) Perhaps some more experienced Python/Vim users have a tip which macro sets help most here. Thanks, Christoph -- ~ ~ .signature [Modified] 1 line --100%--1,48 All -- http://mail.python.org/mailman/listinfo/python-list
Re: append to non-existing list
Yves Glodt wrote: bruno at modulix wrote: Yves Glodt wrote: Hello, if I do this: for row in sqlsth: pkcolumns.append(row[0].strip()) etc without a prior: pkcolumns = []; I get this error on first iteration: UnboundLocalError: local variable 'pkcolums' referenced before assignment I guess that's normal as it's the way python works...?!? Well you could do something like this. (Untested and unrecommended) self.__dict__.setdefault('pkcolumns', []).append(row[0].strip()) Personally I find pkcolumns = [] pkcolumns .append(row[0].strip()) to be nicer ;-) -- hilsen/regards Max M, Denmark http://www.mxm.dk/ IT's Mad Science -- http://mail.python.org/mailman/listinfo/python-list
Re: append to non-existing list
Fredrik Lundh wrote: x = 10 + 20 # should this be 30 or 1020 or 1020 or ...? I think Perl handles this case pretty well and sane. In fact, this strict but dynamic type checking is quite painful to work with, especially the new decimal class. I can do a : decimal + int but not decimal + float But then when I use some built-in math functions, it can convert decimal to float and return a float which then cannot be operate with another decimal. -- http://mail.python.org/mailman/listinfo/python-list
parse data
I have some data (in a string) such as person number 1 Name: bob Age: 50 person number 2 Name: jim Age: 39 ...all that is stored in a string. I need to pull out the names of the different people and put them in a list or something. Any suggestions...besides doing data.index(name)...over and over? thanks! -- http://mail.python.org/mailman/listinfo/python-list
Winpdb question
Is there any way to either restrict the number of variables displayed in the Globals or Locals section. It is a pain having to search through this list all of the time just to look at the values of variables in my program. Bryan -- http://mail.python.org/mailman/listinfo/python-list
Re: Lie Hetland book: Beginning Python..
Magnus Lycka [EMAIL PROTECTED] wrote in news:[EMAIL PROTECTED]: Thank you for your message I found really illuminating. Using the same symbol for both string substitutions and SQL placeholder such as pysqlite 1 and the MySQL interface does, is not really a bright idea in my opinion. Who thinks this is pretty? sql = SELECT %s FROM %s WHERE %s = %%s cur.execute(sql % (col,table,search_col), (param,)) I think it's less confusing with: sql = SELECT %s FROM %s WHERE %s = ? cur.execute(sql % (col,table,search_col), (param,)) I had never thought about it, I really agree. Of course, the proper way, with %s-substitution for e.g. table names and ? for parameters is also open for SQL injection attacks if the values in the strings col, table and search_col above are user input, but since they are plain SQL identifiers, they are much easier to check than arbitrary search values. You'd probably have a set of allowed values, and check that the input was in that set. They are also less likely to come from an untrusted source. undoubtedly. As you can see in http://initd.org/tracker/pysqlite/wiki/PysqliteVersions you can use pysqlite 1.1 if you want to use the old pysqlite 1 API. Pysqlite2 is documented here: http://initd.org/pub/software/pysqlite/doc/usage-guide.html yes I had already found the docs and noticed there was no explanation about such a remarkable difference from pysqlite1 and pysqlite2. After your message, I find even more strange that Magnus' book reported pysqlite1 examples as Sqlite 3 was a great step forward in my opinion. But this can not prevent me from saying that it is the best Python book around in the beginner to intermediate range. -- http://mail.python.org/mailman/listinfo/python-list
Re: append to non-existing list
Yves Glodt [EMAIL PROTECTED] wrote: My question is: Is there no way to append to a non existing list? Nope. The problem (well, part of the problem, anyway) is that when you do: foo.append (bar) what's happening is you're calling foo's append method. If foo doesn't already exist, it has no way of knowing what to call. I am lazy for declaring it first, IMHO it bloats the code, and (don't know if it's good to say that here) where I come from (php) I was used to not-needing it... Python is not php. Nor is it Perl. Nor it is a whole bunch of other things. -- http://mail.python.org/mailman/listinfo/python-list
Re: append to non-existing list
In article [EMAIL PROTECTED], Yves Glodt [EMAIL PROTECTED] wrote: You mean you want to type pkcolumns only once to keep your code short? Would something like this be useful? pkcolumns = [row.strip() for row in sqlsth] I will look into this, maybe it's what I need, thanks! The list comprehension format described above is handy and compact, and there's no reason you shouldn't use it when appropriate. That being said, compactness should not itself be a goal. Writing clear and easy to understand code is much more important than reducing the number of lines. Sometimes you get both at the same time, but not always. -- http://mail.python.org/mailman/listinfo/python-list
Re: Web automation
[EMAIL PROTECTED] wrote: The contribution of Paul Boddie is valuable. I too examined DCOP and even chose as browser Konqueror, being a KDE application. But DCOP doesn't go to such a low level. It is not possible to send a simulated keystroke from one KDE application to another. I imagine that you can send keystrokes using the xlib package described earlier. Nevertheless, a proper automation interface doesn't work at that level. Instead, you work with more high-level concepts than sending keypresses and scanning around the window list to see what happened. One example of automation is the OutlookExplorer program I wrote [1] which connects to Microsoft Outlook and exports messages, calendar events, and so on. Instead of pretending that to be a user clicking on different things, reading things off the screen, and then navigating around - something which would be very easy to get wrong - the program instead connects to Outlook's automation interface via COM, selects each folder in turn using the high-level interface provided, and invokes various methods on the interface to export messages. With a browser, one may use a similarly high-level interface: instead of firing keypresses into the location bar and then firing a Return keypress to tell the browser to load a page, you invoke a method in the browser's automation interface - openURL in the mainwindow interface for Konqueror, I believe. After that, things can be more difficult, but even so, you should still have moderately high-level access to the document being displayed, for example, even if it is via a DOM. Not being an expert I can't understand nor comment on the more technical parts of your reply (out-of-process automation, PyXML-style DOM etc.). All I meant by out-of-process was whether you can just start a Python program outside the browser (eg. in a normal console) which connects to the browser in order to do its work. The PyXML-style DOM was a reference to the way the HTML document is represented - if you're used to XML processing in Java, JavaScript, Qt or even Python, you'll have seen such a thing before. Paul [1] http://www.boddie.org.uk/python/COM.html -- http://mail.python.org/mailman/listinfo/python-list
Re: Winpdb question
mclaugb wrote: Is there any way to either restrict the number of variables displayed in the Globals or Locals section. It is a pain having to search through this list all of the time just to look at the values of variables in my program. IMO, if you have too many locals or globals then that's a sign that you should structure your application better with more functions and classes ... -- Gerhard -- http://mail.python.org/mailman/listinfo/python-list
Re: Lie Hetland book: Beginning Python..
Vittorio wrote: [...] Nonetheless, I was unable to find any documentation about such a different behaviour between Pysqlite and Pysqlite2; from my beginner point of view the Pysqlite (Magnus' version) paramstyle looks a better and more pythonic choice and I don't grasp the Pysqlite2 developers' intentions deviating from that way. The reason why pysqlite 0.x/1.x used paramstyle pyformat, based on Python string substitution for SQL parameters is that at the time pysqlite was started, SQLite 2.x did not have any support for parameter binding. So we had to fake it in Python, just like the MySQL interface does (for the same reasons). Later SQLite 2.x versions and of course SQLite 3.x supported real bound parameters and pysqlite2 was developed from scratch to benefit from them. SQLite 3.x supports both qmark and named paramstyles, so you can use question marks *or* named parameters: from pysqlite2 import dbapi2 as sqlite con = sqlite.connect(:memory:) cur = con.cursor() cur.execute(select 2*?, (14,)) cur.fetchone() (28,) cur.execute(select 2 * :x, {x: 14}) cur.fetchone() (28,) x = 14 cur.execute(select 2 * :x, locals()) cur.fetchone() (28,) I've also once written a wrapper using pysqlite 2.x's hooks that allows you to use the format paramstyle with pysqlite 2.x, so you can reuse more code that was originally written against pysqlite 0.x/1.x: from pysqlite2 import dbapi2 as sqlite class PyFormatConnection(sqlite.Connection): def cursor(self): return sqlite.Connection.cursor(self, PyFormatCursor) class PyFormatCursor(sqlite.Cursor): def execute(self, sql, args=None): if args: qmarks = [?] * len(args) sql = sql % tuple(qmarks) sqlite.Cursor.execute(self, sql, args) else: sqlite.Cursor.execute(self, sql) con = sqlite.connect(:memory:, factory=PyFormatConnection) cur = con.cursor() cur.execute(create table test(a, b, c)) cur.execute(insert into test(a, b, c) values (%s, %s, %s), ('asdf', 4, 5.2)) cur.execute(select a, b, c from test where c %s, (4.27,)) print cur.fetchone() cur.close() con.close() I would be very grateful if someone would cast a light over Pysqlite/Pysqlite2 discrepancies. I think about the only place I wrote a bit about the differences was in the pysqlite 2.0 final announcement: http://lists.initd.org/pipermail/pysqlite/2005-May/43.html -- Gerhard -- http://mail.python.org/mailman/listinfo/python-list
Re: A Tcl/Tk programmer learns Python--any advice?
Svenn Are Bjerkem wrote: In article [EMAIL PROTECTED], [EMAIL PROTECTED] says... Ah, another one leaves the fold... : \ I think I saw somebody say about OO in Python: It's there, but you don't have to use it. Every time somebody wants OO in the core of tcl, he is asked: Why do you want it? If OO was as easy in Tcl as in Python, there would be no real reason to switch in my opinion. (And maybe simpler namespaces and passing of lists to functions, we all love the uplevel and upvar commands, don't we?) -- Svenn That is a misconception. There are several really good packages for OO in Tcl. XOTcl, [incr] Tcl, and my favorite Snit. On top of that there is currently being added OO to the core of Tcl as well. That should all be integrated in when 8.5 comes out in the spring. Tk is getting a native LF uplift as well. However, I think it is more perception than function now. Robert -- http://mail.python.org/mailman/listinfo/python-list
seeking ncpfs library bindings for Python
After hacking up a first cut that works through the existing ncpfs CLI tools, I was looking to move to a more integrated solution (if only to avoid so many spawns of external tasks just to, eg., update a queue's pending print job list). I couldn't find any hint of such a thing - the long-gone ndslib (active back c. 2001) seems to have targeted the server side, with perhaps a side interest in specifically Windows clients. Hasn't anyone ever put a wrapper around the ncpfs client library? All leads gratefully accepted! -- In software as well as in modern art, the distinction between intentional and accidental omissions is often difficult to make. -- Andrew Hunt David Thomas -- http://mail.python.org/mailman/listinfo/python-list
Re: append to non-existing list
On Wed, 09 Nov 2005 13:46:52 +0100, Yves Glodt wrote: My question is: Is there no way to append to a non existing list? I am lazy for declaring it first, IMHO it bloats the code, and (don't know if it's good to say that here) where I come from (php) I was used to not-needing it... But what happens if the non-existent list you try to append to is actually a non-existent dict, or worse, a non-existent float? You'll get errors and maybe even crash your computer and wipe the hard disk clear. *wink* How is appending to a non-existent object supposed to work? something.append(0) What object does the name something refer to? Does it even have an append method? How can you tell what methods it has if it doesn't exist yet? No, you can't append to a non-existent list, just as you can't add two non-existent numbers together. If PHP allows you to append to non-existent lists, then it is a poor design decision, and it obviously only works because PHP is much more limited than Python. Consider the following code: class PList(list): def append(self, obj): print Appending object to PList self.__class__.append(self, obj) # call the superclass class QList(list): def append(self, obj): print QList append is being called self.__class__.append(self, obj) class RList(QList): def append(self, obj): self.__class__.append(self, obj) print Now calling RList append something.append(hello world) # call append on a non-existent object What should Python do? Should something be a RList, QList, PList or ordinary list? -- Steven. -- http://mail.python.org/mailman/listinfo/python-list
Re: Invoking Python from Python
In article [EMAIL PROTECTED], Mike Meyer [EMAIL PROTECTED] wrote: . . . Since Cameron didn't provide examples, let me grab a simple one. The cheetah templating system works by creating Python programs from the template. The programs, when run, output the filled in template. The templates are generally more maintainable than the raw python - even if you cleaned up all the things Cheetah does to make writing templates easier. This model makes it possible for Cheetah templates use inheritance - they can inherit from each other, from python classes, and python classes can inherit from them. . . . Good example. Excellent one, even, for emphasizing the place of inheritance in the design. Functionalism, space-time, security, persistence, duality, ... I have trouble talking in this area without starting to froth. An unsatisfying treatment of some of these issues appears in URL: http://www.unixreview.com/documents/s=9884/ur0509m/ . I'll rein myself in and suggest an even easier introduction to this subject: configuration files. RARELY is the correct answer to create a new syntax, although many development organizations give the impression that's their first choice. .ini-speak is a safe-enough choice. Most interesting, though, is to interpret Python or some subset as a configu- ration specification, so that one has immediately not just HOME = /some/folder STEP_LIMIT = 16 but pool_size = cpu_count * 30 and even if today == Sunday: total_process_maximum = 8 available in the configuration language. Neat, eh? But if configuration is *that* powerful, then it can also do great damage. How does one make Python interpretation safe? That's a subject for another day. -- http://mail.python.org/mailman/listinfo/python-list
Re: parse data
If you know the indices of where the data should be in your string, you can use substrings... ie: stringy = Happy Happy Cow, 50, 1234 Your Mom's House AllTheTime,USA stringy[0:16] ' Happy Happy Cow' If the data isn't set all the time (for example, and address doesn't have a mandatory length), then you're probably stuck using the index function...unless you have everything separated by a delimiter, such as a ,...then this would work: listy = stringy.split(,) print listy [' Happy Happy Cow', ' 50', 1234 Your Mom's House AllTheTime, 'USA '] Hope this helps! -- http://mail.python.org/mailman/listinfo/python-list
Re: Hi, from my login i want to login as a other user ,
On Wed, 09 Nov 2005 04:01:00 -0800, sumi wrote: Hi, i am very new to python , it is just 2 days i started reading abt it. I did not understand the above statement. what i want to do is , i want to login as a super user eg : $su xyz , and then i need to enter the passwd, i want to do these steps using python , how can i do it?? Type ctrl-d to exit Python, then at the command prompt, type su enter, then type your root password. Then, as root, type python enter at the command prompt. -- Steven. -- http://mail.python.org/mailman/listinfo/python-list
Re: parse data
If you know the indices of where the data should be in your string, you can use substrings... ie: stringy = Happy Happy Cow, 50, 1234 Your Mom's House AllTheTime,USA stringy[0:16] ' Happy Happy Cow' If the data isn't set all the time (for example, and address doesn't have a mandatory length), then you're probably stuck using the index function...unless you have everything separated by a delimiter, such as a ,...then this would work: listy = stringy.split(,) print listy [' Happy Happy Cow', ' 50', 1234 Your Mom's House AllTheTime, 'USA '] Hope this helps! -- http://mail.python.org/mailman/listinfo/python-list
Make an exe file as a Windows Service
Hi to all, How can I install an exe file as a service through Python? Thanks -- http://mail.python.org/mailman/listinfo/python-list
Re: parse data
py schrieb: I have some data (in a string) such as person number 1 Name: bob Age: 50 person number 2 Name: jim Age: 39 ...all that is stored in a string. I need to pull out the names of the different people and put them in a list or something. Any suggestions...besides doing data.index(name)...over and over? thanks! Use the re module: import re your_data = person number 1 Name: bob Age: 50 person number 2 Name: jim Age: 39 names = [] for match in re.finditer(Name:(.*), your_data): names.append(match.group(1)) print names Bye, Dennis -- http://mail.python.org/mailman/listinfo/python-list
Re: PIL- Tkinter
Tuvas [EMAIL PROTECTED] wrote Is there a way to put an image loaded from PIL into a TKinter GUI? Without converting the image to a .bmp, and using a canvas? If that's the only way it'll work, I'll take it, but... It would be nice otherwise... hmm. is google down today? here's a random cookbook sample: http://aspn.activestate.com/ASPN/Cookbook/Python/Recipe/227575 also see: http://effbot.org/imagingbook/imagetk.htm http://effbot.org/tkinterbook/photoimage.htm (if the image doesn't appear when it should, see the note at the bottom of the photoimage page) /F -- http://mail.python.org/mailman/listinfo/python-list
Re: Wrapping C functions in Pyrex and distutils problem
Use additional_objects: LINKBASE = link-4.1b setup( name = LinkWrapper, ext_modules = [ Extension(link, [link.pyx], include_dirs = [%s/include % LINKBASE], extra_objects = glob.glob(%s/obj/* % LINKBASE), ) ], cmdclass = {'build_ext': build_ext} ) - -- Regards, Diez -- http://mail.python.org/mailman/listinfo/python-list
Re: PIL- Tkinter
Tuvas wrote: Is there a way to put an image loaded from PIL into a TKinter GUI? Without converting the image to a .bmp, and using a canvas? If that's the only way it'll work, I'll take it, but... It would be nice otherwise... Can you use PIL to convert it to a GIF? Tk can display GIF's natively. -- Cheers, Kevin Walzer, PhD WordTech Software - Tame the Terminal http://www.wordtech-software.com sw at wordtech-software.com -- http://mail.python.org/mailman/listinfo/python-list
PIL- Tkinter
Is there a way to put an image loaded from PIL into a TKinter GUI? Without converting the image to a .bmp, and using a canvas? If that's the only way it'll work, I'll take it, but... It would be nice otherwise... -- http://mail.python.org/mailman/listinfo/python-list
Re: how to modify code while debugging it without having to stop and then restart debugger
On Tue, 08 Nov 2005 13:38:28 -0500, python wrote: thanks for all that have replied so far. i still find it __very__ hard to believe that i cannot edit code inside a function while debugging it. You write a function: def myfunct(s): # input arg s is a string foo = s*3 bar = s.upper() + foo # LINE 2 blob = foo.lower() + bar return blob You enter the debugger and single-step to the marked line LINE 2. Then you edit the code to this: def myfunct(n): # input arg n is an int foo = n + 1 bar = foo*2 # LINE 2 blob = foo**bar return blob What should Python do when you step the debugger, and why is it useful? as i mentioned even micro$soft can do this using statically type languages like visual basic and csharp. also, both visualbasic and csharp have goto statements, which i do to not use in final code but can be real handy when used with the ability to change debugged code on the fly while inside the function being debugged. Better and better. Yes, I can see how the ability to jump around a function on the fly would really help you understand how the function is supposed to work when you take the gotos out. for example, if i am inside a function and there is some an error on a line and that is where the debugger is currently pointing at, i simple copy and paste the bad code line just below the actual code line. i fix this copied code line. then i just turn the bad line into a comment line and the debugger will move the current focus to the next time, which is the fixed code. how can such a dynamic language like python not be able to do this. Do you try to ignore the syntax and grammar of the programming language you are coding in too, or only English? [snip] there are several applications that can do this. in fact, the free version of the visual studio 2005, which is free, have this ability. Just out of curiosity, how much is the free version of Visual Studio 2005? -- Steven. -- http://mail.python.org/mailman/listinfo/python-list