Re: xml-filter with XMLFilterBase() and XMLGenerator() shuffles attributes

2007-12-20 Thread infidel
> def startElement(self, name, attrs): > self.__downstream.startElement(name, attrs) > return > I want prevent it from shuffling attributes, i.e. preserve original > file's attribute order. Is there any ContentHandler.features* > responsible for that? I sus

draggable Tkinter.Text widget

2007-08-03 Thread infidel
but I was wondering if there was a simple way to add some "friction" to the scrolling so a tiny mouse movement doesn't cause the text to go zipping by in a flash. Thanks, infidel -- http://mail.python.org/mailman/listinfo/python-list

Re: __call__ considered harmful or indispensable?

2007-08-02 Thread infidel
I find it useful in certain situations. In particular, I have used it along with cx_Oracle to provide a python module that dynamically mirrors a package of stored procedures in the database. Basically I had class StoredProcedure(object) and each instance of this class represented a particular sto

Re: list.append not working?

2007-07-05 Thread infidel
On Jul 5, 8:58 am, Hardy <[EMAIL PROTECTED]> wrote: > I experience a problem with append(). This is a part of my code: > > for entity in temp: > md['module']= entity.addr.get('module') > md['id']=entity.addr.get('id') > md['type']=entity.addr.get('type')

Re: Help building GUI with Tix - solution

2007-07-03 Thread infidel
I figured it out after finding an example somewhere: >>> import Tix >>> app = Tix.Tk("Demo") >>> panes = Tix.PanedWindow(app) >>> left = panes.add('left') >>> right = panes.add('right') >>> tree = Tix.Tree(left) >>> notebook = Tix.NoteBook(right) >>> tree.pack() >>> notebook.pack() >>> panes.pack(

Help building GUI with Tix

2007-07-03 Thread infidel
I am trying to build a GUI using the Tix module. What I want is a paned window with a tree in the left pane and a notebook in the right pane. I keep getting an error that I don't understand when adding these widgets to the panes: PythonWin 2.5.1 (r251:54863, May 1 2007, 17:47:05) [MSC v.1310 32

Re: SimplePrograms challenge

2007-06-13 Thread infidel
# writing/reading CSV files, tuple-unpacking, cmp() built-in import csv writer = csv.writer(open('stocks.csv', 'wb')) writer.writerows([ ('GOOG', 'Google, Inc.', 505.24, 0.47, 0.09), ('YHOO', 'Yahoo! Inc.', 27.38, 0.33, 1.22), ('CNET', 'CNET Networks, Inc.', 8.62, -0.13, -1.49) ]) sto

Re: SimplePrograms challenge

2007-06-11 Thread infidel
# reading CSV files, tuple-unpacking import csv #pacific.csv contains: #1,CA,California #2,AK,Alaska #3,OR,Oregon #4,WA,Washington #5,HI,Hawaii reader = csv.reader(open('pacific.csv')) for id, abbr, name in reader: print '%s is abbreviated: "%s"' % (name, abbr) -- http://mail.python.org/mai

Re: REALLY need help with iterating a list.

2007-06-11 Thread infidel
On Jun 11, 11:30 am, Radamand <[EMAIL PROTECTED]> wrote: > This has been driving me buggy for 2 days, i need to be able to > iterate a list of items until none are left, without regard to which > items are removed. I'll put the relevant portions of code below, > please forgive my attrocious nam

Re: A bug in cPickle?

2007-05-16 Thread infidel
ActivePython 2.5.1.1 as well: PythonWin 2.5.1 (r251:54863, May 1 2007, 17:47:05) [MSC v.1310 32 bit (Intel)] on win32. Portions Copyright 1994-2006 Mark Hammond - see 'Help/About PythonWin' for further copyright information. >>> from pickle import dumps >>> from cPickle import dumps as cdumps >>>

Re: Generate report containing pdf or ps figures?

2007-04-23 Thread infidel
On Apr 23, 9:30 am, Grant Edwards <[EMAIL PROTECTED]> wrote: > I need to be able to generate a PDF report which consists > mostly of vector images (which I can generate as encapsulated > Postscript, PDF, or SVG). What I need is a way to combine > these figures into a single PDF document. Right no

Re: The decentralized nature of the Python community is driving me crazy

2006-08-18 Thread infidel
> And then you have discussion and yet again, there is no perlmonks.org > for Python. We have this, IRC, and what else? There's also http://planet.python.org, which is an aggregator of python blogs that I check many times a day for new posts. -- http://mail.python.org/mailman/listinfo/python-lis

Re: inheritance?

2006-08-16 Thread infidel
> Yes I believe so but in fromfile I want to call the appropriate > method depending on the in a parameter in fromfile... > like: > class baseClass: >def fromfile(self, fileObj, byteOrder=None, explicit=False): > if explicit: > call fromfile of explicit class > else: >

Re: converting a nested try/except statement into try/except/else

2006-08-10 Thread infidel
> > try: > > if int(text) <= 0: raise ValueError > > Hmm, I'm actually not so sure about this line now. It doesn't seem right > to raise a ValueError when the result of the expression is negative, > because even though it's a problem for my program, it isn't really a > "ValueError," r

Re: newb question: file searching

2006-08-08 Thread infidel
> Also, I've noticed that files are being found within hidden > directories. I'd like to exclude hidden directories from the walk, or > at least not add anything within them. Any advice? The second item in the tuple yielded by os.walk() is a list of subdirectories inside the directory indicated

Re: do people really complain about significant whitespace?

2006-08-08 Thread infidel
> All societies demonise outsiders to some extent. It's an unfortunate > human (and animal) trait. Which is why I questioned it. > So just block your ears when the propaganda vans with the loud-speakers > on top drive past your dwelling :-) Funny how using python makes me feel like a member of s

Re: do people really complain about significant whitespace?

2006-08-08 Thread infidel
> One of the most stupid language-definition decisions that most people > have come across is the Makefile format. > Hope that goes some way to explaining one possible reason why rational > people can consistently react in horror to the issue. Ah, thanks for that. This peek into history makes

do people really complain about significant whitespace?

2006-08-07 Thread infidel
Where are they-who-hate-us-for-our-whitespace? Are "they" really that stupid/petty? Are "they" really out there at all? "They" almost sound like a mythical caste of tasteless heathens that "we" have invented. It just sounds like so much trivial nitpickery that it's hard to believe it's as common

Re: Programming newbie coming from Ruby: a few Python questions

2006-08-02 Thread infidel
> The time to crush our enemies has come. > This is the Jihad! Death to the infidels Whoa, dude, let's not get carried away now, 'k? Looking-over-his-shoulder-ly y'rs, infidel -- http://mail.python.org/mailman/listinfo/python-list

Re: cleaner way to write this try/except statement?

2006-08-01 Thread infidel
Here's how I would do it: def Validate(self, parent): try: text_ctrl = self.GetWindow() text = text_ctrl.GetValue() if not text: raise ValueError if int(text) <= 0: raise ValueError return True except ValueError, error

Re: Determining if an object is a class?

2006-07-12 Thread infidel
>>> import types >>> class OldStyle: pass ... >>> type(OldStyle) == types.ClassType True -- http://mail.python.org/mailman/listinfo/python-list

Re: Generator naming convention?

2006-06-28 Thread infidel
> Any idea? Do you have a naming convention for generators? Sometimes I use the prefix 'iter', like dictionaries have .items() and .iteritems(). sometimes I use 'x', like range() vs. xrange(). You could simply use 'i' like some of the functions in the iteritems module (imap(), izip(), etc). I g

Re: New to Python: Do we have the concept of Hash in Python?

2006-06-01 Thread infidel
> Is there any built-in Hash implementation in Python? I am looking for a > container that I can access to it's items by name. Something like this: > > Print container["memeberName"] You obviously haven't read the tutorial, they're called "dictionaries" in Python > I am asking this because I lear

Re: what is the difference between tuple and list?

2006-05-16 Thread infidel
> is there any typical usage that shows their difference? I think the general idea is to use lists for homogenous collections and tuples for heterogenous structures. I think the database API provides a good usage that shows their differences. When you do cursor.fetchall() after executing a query

Re: String Exceptions (PEP 352)

2006-04-27 Thread infidel
You could also use the "assert" statement: >>> if foo and bar: ... assert i <= 10, "if foo and bar then i must not be greater than 10" ... -- http://mail.python.org/mailman/listinfo/python-list

Re: send pdf or jpg to printer

2006-04-19 Thread infidel
Bell, Kevin wrote: > Does anyone have any suggestions on printing pdf's? These pdf's don't > change much, so if it be more straight forward to convert them to jpgs, > or another format, then that'd be fine too. I use GhostScript and GSPrint to send PDFs to our printer in a Windows environment. I

Re: function prototyping?

2006-04-13 Thread infidel
If you want the user to be able to (re)define them in config.py, why not just define them there in the first place? I may be wrong, but I think "global" means "module level" rather than "interpreter level". -- http://mail.python.org/mailman/listinfo/python-list

Re: how to create file with spaces

2006-04-06 Thread infidel
dirpath is just a string, so there's no sense in putting it in a list and then iterating over that list. If you're trying to do something with each file in the tree: for dir, subdirs, names in os.walk(rootdir): for name in names: filepath = os.path.join(dir, name) + "-dummy" i

Re: CGIHTTPServer threading problems

2006-03-31 Thread infidel
Alvin A. Delagon wrote: > I'm a simple python webserver based on CGIHTTPServer module: > > import CGIHTTPServer > import BaseHTTPServer > import SocketServer > import sys > import SQL,network > from config import * > > class > ThreadingServer(SocketServer.ThreadingMixIn,BaseHTTPServer.HTTPServer):

Re: SimpleXMLRPCServer

2006-03-30 Thread infidel
> I'm doing some experiments with the SimpleXMLRPCServer in Python, > and I've found it to be an excellent way to do high-level network > operations. > > However, is there a way to enable "two-way" communication using XML-RPC? > By that I mean, can the server contact all the clients? To do that yo

Re: Print a PDF transparently

2006-02-17 Thread infidel
Daniel Crespo wrote: > Hi to all, > > I want to print a PDF right from my python app transparently. With > "transparently" I mean that no matter what program handles the print > petition, the user shouldn't be noticed about it. > > For example, when I want to print a PDF, Adobe Acrobat fires and k

Re: indentation messing up my tuple?

2006-02-01 Thread infidel
> i am using a tuple because i am building lists. I don't understand > if i just use (food + > drink) then while drink is unique food remains the same do i get this: > > (burger, coke) > (burger, 7up) > (burger, sprite) I don't understand what you're saying here. food and drink are both string

Re: indentation messing up my tuple?

2006-01-31 Thread infidel
tuple is the name of the built-in type, so it's not a very good idea to reassign it to something else. (food + drink + '\n') is not a tuple, (food + drink + '\n',) is There's no reason to use tuples here, just do this: data.append(food + drink) f.write('\n'.join(data)) -- http://mail.python.or

Have a very Pythonic Christmasolstihanukwanzaa

2005-12-23 Thread infidel
Happy holidays to my fellow Pythonistas. Love, Saint Infidel the Skeptic -- http://mail.python.org/mailman/listinfo/python-list

Re: Why my modification of source file doesn't take effect when debugging?

2005-12-02 Thread infidel
> I'm using the Windows version of Python and IDLE. When I debug my .py > file, my modification to the .py file does not seem to take effect > unless I restart IDLE. Saving the file and re-importing it doesn't help > either. Where's the problem? "import" only reads the file the first time it's cal

Re: creating package question

2005-11-16 Thread infidel
the path to your 'root' folder. One of my projects is structured like this: C:\src\py infidel\ __init__.py models\ __init__.py basemodel.py views\ __init__.py baseview.py controllers\ __init

Re: CherryPy not playing nicely with win32com?

2005-11-14 Thread infidel
> Just an idea: because in CherryPy it is running in multithreading mode? > If you are using threads together with COM stuff, you will have to > add pythoncom.CoInitialize() and pythoncom.CoUninitialize() calls > in your code -- for each thread. That worked perfectly. Thanks a million! I used to

CherryPy not playing nicely with win32com?

2005-11-10 Thread infidel
I've been trying to get my CherryPy server to authenticate users against our network. I've managed to cobble together a simple function that uses our LDAP server to validate the username and password entered by the user: # ldap.py from win32com.client import GetObject ADS_SECURE_AUTHENTICATION =

cx_Oracle callproc output parameters

2005-11-08 Thread infidel
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

Re: Python and PL/SQL

2005-11-07 Thread infidel
> Thanks for your answers. > I would like to document with Python PL/SQL of programs, so similarly > as javadoc for Java. > I do not know whether it is possible. If yes, I would like to know how. All of the source code for procedures and packages in an oracle database can be retreived from the USE

Re: Python and PL/SQL

2005-11-07 Thread infidel
vb_bv wrote: > Does Pyton PL/SQL programming language of Oracle support? > > Thx PL/SQL is only supported *inside* Oracle databases. Python can be used to call PL/SQL procedures (I recommend the cx_Oracle module), but you can't run Python inside the database like PL/SQL. -- http://mail.python.

pythonic

2005-11-03 Thread infidel
http://dictionary.reference.com/search?q=pythonic http://thesaurus.reference.com/search?r=2&q=pythonic -- http://mail.python.org/mailman/listinfo/python-list

Re: Learning multiple languages (question for general discussion)

2005-11-03 Thread infidel
Python has spoiled me. I used to periodically try out new languages just for fun, but since learning Python, it's become a lot less interesting. I find myself preferring to just try new ideas or techniques in Python rather than searching for new languages to dabble in. The last few I've download

Re: Instantiating Classes in python (newbie)

2005-10-31 Thread infidel
> Hello, I am learning python for work from knowing java,c#,c. I had a > couple questions. > 1) IntegerClass - to instantiate this class how come I use i = > IntegerClass.IntegerClass() and then this works while i = > IntegerClass() i.method. I receive an error. It depends on what IntegerClass

Re: xml-rpc - adodb - None type - DateTime type

2005-10-28 Thread infidel
> I can replace all None values with the string 'Null', there's no > problem, but I can't detect the DateTime type object I retrieve from > the database. > > I have something like this: > def xmlrpc_function(): > conn = adodb.NewADOConnection('postgres') > conn.Connect(host,user,password,da

Re: possible bug in cherrypy.lib.autoreload

2005-10-20 Thread infidel
Ok, so it turns out that the problem the cherrypy.lib.autoreload module is having, is that kid imports elementtree and on my machine the elementtree modules are inside a zip file (.egg). So the "path" to the elementtree __init__.py file is not a valid OS path because everything after the .egg file

possible bug in cherrypy.lib.autoreloader

2005-10-19 Thread infidel
I may have found the source of my infinite loop when importing kid modules from my cherrypy server. Here is some code from the autoreloader module of cherrypy: def reloader_thread(): mtimes = {} def fileattr(m): return getattr(m, "__file__", None) while RUN_RELOADER:

Re: infinite cherrypy autoreloader loop

2005-10-19 Thread infidel
Ok, the problem seems to be with my cherrypy importing Kid. If I import the kid module or any of my compiled kid template modules, then I get the autoreloader infinite loop. Is anyone else experiencing this effect? -- http://mail.python.org/mailman/listinfo/python-list

infinite cherrypy autoreloader loop

2005-10-19 Thread infidel
I did an "svn update" of cherrypy this morning, and now when I try running a server, the log window just keeps reporting the autoreloader restarting over and over: 2005/10/19 12:42:33 HTTP INFO SystemExit raised: shutting down autoreloader 2005/10/19 12:42:33 HTTP INFO CherryPy shut down 2005/10/1

Python, alligator kill each other

2005-10-06 Thread infidel
By Denise Kalette Associated Press MIAMI - The alligator has some foreign competition at the top of the Everglades food chain, and the results of the struggle are horror-movie messy. A 13-foot Burmese python recently burst after it apparently tried to swallow a live 6-foot alligator whole, author

Re: Problem SQL ADO

2005-09-27 Thread infidel
> "SELECT > VA_MK_YEAR,VA_MK_DESCRIP,VO_VIN_NO,VO_MODEL,VO_BODY,VO_DESCRIPTION" + \ > "FROM D014800 LEFT OUTER JOIN D014900 ON (VA_MK_NUMBER_VER = > VO_MAKE_NO) AND (VA_MK_YEAR = VO_YEAR)" + \ > "WHERE (((VA_MK_YEAR)=?) AND ((VA_MK_DESCRIP)=?) AND > ((VO_MODEL)=?))" Doesn't look like you h

Re: error processing variables

2005-09-09 Thread infidel
> import shutil > > #variables > s = shutil > > toHPU = "/etc/sysconfig/network/toHPU.wifi" > wlan = "/etc/sysconfig/network/ifcfg-wlan-id-00:0e:38:88:ba:6d" > toAnyWifi = "/etc/sysconfig/network/toAny.wifi" > wired = "/etc/sysconfig/network/ifcfg-eth-id-00:0b:db:1b:e3:88" > > > def toHPU(): > > >

Re: Python CGI and Firefox vs IE

2005-09-07 Thread infidel
> I see what's happening, but I'm at a loss to figure out what to do > about it. Any help would be appreciated. Try giving the buttons different name attributes. -- http://mail.python.org/mailman/listinfo/python-list

Re: File parser

2005-08-30 Thread infidel
Angelic Devil wrote: > I'm building a file parser but I have a problem I'm not sure how to > solve. The files this will parse have the potential to be huge > (multiple GBs). There are distinct sections of the file that I > want to read into separate dictionaries to perform different > operations

Re: question on "import __main__"

2005-08-26 Thread infidel
> import __main__ > if __name__!='__main__': >print 1 > > print 2 > > when i run test.py, i got > 2 > on the screen. > > now, i have some question about the code, 1. since no __main__ module at > all, why it's legal to write "import __main__"? __main__ is the module that the interpreter starts

Re: a dummy python question

2005-08-26 Thread infidel
> > If that were so, Pythonistas could never write a recursive function! > > No, presumably at the writing of the edition of _Learning Python_ that > he is reading, Python did not have nested scopes in the language, yet. > One could always write a recursive function provided it was at the > top-lev

Re: a dummy python question

2005-08-25 Thread infidel
Learning Python wrote: > A example in learning Python by Mark Lutz and David Ascher > > about function scope > > example like this: > > >>def outer(x): > def inner(i): > print i, > if i: inner(i-1) > inner(x) > >>outer(3) > > Here supposely, it should report error, becaus

Re: pipes like perl

2005-08-24 Thread infidel
> but... i see it doesn't work for some commands, like "man python" (it > gets stuck on the "if" line)... .readlines() won't return until it hits end-of-file, but the "man" command waits for user input to scroll the content, like the "more" or "less" commands let you view "pages" of information on

Re: pipes like perl

2005-08-23 Thread infidel
Here's one technique I use to run an external command in a particular module: stdin, stdout, stderr = os.popen3(cmd) stdin.close() results = stdout.readlines() stdout.close() errors = stderr.readlines() stderr.close() if errors: r

threadsafety in cherrypy with kid

2005-08-18 Thread infidel
I have just recently discovered CherryPy and Kid (many kudos to the respective developers!) and am tinkering with them to see what I can come up with. The application I eventually want to write will eventually require the python code to call stored procedures in a database which means I'll need to

Re: len(sys.argv) in (3,4)

2005-08-12 Thread infidel
It might make more sense if you could find out exactly what that one argument contains. -- http://mail.python.org/mailman/listinfo/python-list

Re: len(sys.argv) in (3,4)

2005-08-12 Thread infidel
> Nope. But since you're running this on a very peculiar OS, I just can > guess that this very peculiar OS consider all args to be one same string... It depends on what you're coding with. If you're writing a Win32 program in C/C++ (and by extension, Visual Basic), the WinMain() function passes a

Re: breaking a loop

2005-08-11 Thread infidel
> Desired behavior: when I type 'exit' the program should quit. def search(): user_input = '' while True: user_input = raw_input('Search for: ') if user_input == 'exit': break print 'processing', user_input Note that putting user input directly into SQL statements

Re: Why does __init__ not get called?

2005-08-09 Thread infidel
This doesn't work. I'm out of my league here. -- http://mail.python.org/mailman/listinfo/python-list

Re: Why does __init__ not get called?

2005-08-09 Thread infidel
> Are you sure you can specify arbitrary arguments to the __new__ method? > I thought they had to be the class object, the tuple of bases, and the > dictionary of names. Nevermind, I think I was imagining metaclasses rather than just regular overriding of __new__ -- http://mail.python.org/mailma

Re: Why does __init__ not get called?

2005-08-09 Thread infidel
I think you have to call type.__new__ like this: def __new__(cls, year, month, day, *args, **kw): print "new called" try: return _datetime.__new__(cls, year, month, day, *args, **kw) except ValueError: return type.__new__(cls, ...) Are you sure

Re: Passing arguments to function - (The fundamentals are confusing me)

2005-08-09 Thread infidel
> in Python equality rebinds the name Assignment (=) rebinds the name. Equality (==) is something else entirely. -- http://mail.python.org/mailman/listinfo/python-list

Re: What are modules really for?

2005-08-09 Thread infidel
> I am very new to Python, but have done plenty of development in C++ and > Java. And therein lies the root of your question, I believe. > One thing I find weird about python is the idea of a module. Why is this > needed when there are already the ideas of class, file, and package? One reason is

Re: Conditionally implementing __iter__ in new style classes

2005-07-06 Thread infidel
Something like this: >>> class Base(object): ... def __getitem__(self, key): ... return key ... def __iter__(self): ... yield self[1] ... yield self['foo'] ... yield self[3.0] ... >>> class ConcreteIterable(Base): ... def __iter__(self):

Re: Conditionally implementing __iter__ in new style classes

2005-07-06 Thread infidel
Why not define an Iterator method in your Base class that does the iteration using __getitem__, and any subclass that wants to do something else just defines its own Iterator method? For that matter, you could just use the __iter__ methods of Base and Concrete instead of a separate method. -- ht

Re: Conditionally implementing __iter__ in new style classes

2005-07-06 Thread infidel
I'm not sure I understand why you would want to. Just don't define __iter__ on your newstyle class and you'll get the expected behavior. -- http://mail.python.org/mailman/listinfo/python-list

Re: pulling multiple instances of a module into memory

2005-06-27 Thread infidel
Do you have control over the eggs.so module? Seems to me the best answer is to make the start method return a connection object conn1 = eggs.start('Connection1') conn2 = eggs.start('Connection2') -- http://mail.python.org/mailman/listinfo/python-list

Re: a dictionary from a list

2005-06-24 Thread infidel
dict((x, None) for x in alist) -- http://mail.python.org/mailman/listinfo/python-list

Re: Favorite non-python language trick?

2005-06-24 Thread infidel
> def class Colour: > def __init__(self, blue=0, green=0, red=0): > # pseudo-Python code borrowing concept "with" from Pascal > with self: > blue = blue > green = green > red = red > > And now you can see why Python doesn't support this idiom.

Re: metaclass that inherits a class of that metaclass?

2005-06-01 Thread infidel
Ok, forget everything I've said. The more I think about this the less I understand it. I'm way out of my league here. sitting-down-and-shutting-up-ly y'rs, infi -- http://mail.python.org/mailman/listinfo/python-list

Re: metaclass that inherits a class of that metaclass?

2005-06-01 Thread infidel
Oh great, just when I thought I was starting to grok this mess. -- http://mail.python.org/mailman/listinfo/python-list

Re: metaclass that inherits a class of that metaclass?

2005-06-01 Thread infidel
> because i need the representations of the other systems types to > themselves be python classes, and so i need a metaclass to make sure > they follow certain rules. This metaclass is for that system what type > is for python I think that's exactly the same thing I just said. More or less. Altho

Re: metaclass that inherits a class of that metaclass?

2005-06-01 Thread infidel
"God made me an atheist, who are you to question His wisdom?" -- Saint Infidel the Skeptic -- http://mail.python.org/mailman/listinfo/python-list

Re: metaclass that inherits a class of that metaclass?

2005-06-01 Thread infidel
I don't think that makes any sense. How could you possibly create such a circular relationship between things in any language? Besides, if I understand metaclasses at all, only other metaclasses can be bases of a metaclass. Why not use python classes to represent the other system's types with a

Re: metaclass that inherits a class of that metaclass?

2005-06-01 Thread infidel
Why in the name of all that is holy and just would you need to do such a thing? -- http://mail.python.org/mailman/listinfo/python-list

Re: Python Polymorphism

2005-05-12 Thread infidel
carlos> Supose that I want to create two methos (inside a carlos> class) with exactly same name, but number of carlos> parameters different That isn't polymorphism, that's function overloading. carlos> Look, I don't want to use things like: carlos> carlos> def myMethod(self, myValue=None):

Re: lists in cx_Oracle

2005-05-02 Thread infidel
I think perhaps you are asking for something that the OCI doesn't provide. At least I'd be rather surprised if it did. I know that the SQL syntax doesn't provide for such a mechanism. And really, it all boils down to the list comprehension: in_clause = ', '.join([':id%d' % x for x in xrange(len

Re: lists in cx_Oracle

2005-05-02 Thread infidel
Something like this might work for you: >>> ids= ['D102', 'D103', 'D107', 'D108'] >>> in_clause = ', '.join([':id%d' % x for x in xrange(len(ids))]) >>> sql = "select * from tablename where id in (%s)" % in_clause >>> import cx_Oracle as ora >>> con = ora.connect('foo/[EMAIL PROTECTED]') >>> cur =

Re: Getting the sender widget's name in function (Tkinter)

2005-04-28 Thread infidel
Here's a slight variation of tiissa's solution that gives the callable a reference to the actual widget instead of just it's name: from Tkinter import Tk, Button class say_hello: def __init__(self, widget): self.widget = widget def __call__(self): print 'Hello,', self.widg

Re: Getting the sender widget's name in function (Tkinter)

2005-04-26 Thread infidel
from Tkinter import Tk, Button def say_hello(event): print 'hello!' print event.widget['text'] root = Tk() button1 = Button(root, text='Button 1') button1.bind('', say_hello) button1.pack() button2 = Button(root, text='Button 2') button2.bind('', say_hello) button2.pack() root.mainloop()

Re: EOF-file missing

2005-04-14 Thread infidel
You can use the Content-Length header to tell the server how long the string is. -- http://mail.python.org/mailman/listinfo/python-list

Re: oracle interface

2005-04-05 Thread infidel
cx_Oracle rocks -- http://mail.python.org/mailman/listinfo/python-list

Re: AttributeError: 'module' object has no attribute 'setdefaulttimeout'

2005-03-31 Thread infidel
That just means the urllib.socket module doesn't have any function named setdefaulttimeout in it. It appears there might be something wrong with your socket module as mine has it: py> import urllib py> f = urllib.socket.setdefaulttimeout py> f -- http://mail.python.org/mailman/listinfo/python-

Re: Finding attributes in a list

2005-03-29 Thread infidel
You can use the new 'sorted' built-in function and custom "compare" functions to return lists of players sorted according to any criteria: >>> players = [ ... {'name' : 'joe', 'defense' : 8, 'attacking' : 5, 'midfield' : 6, 'goalkeeping' : 9}, ... {'name' : 'bob', 'defense' : 5, 'attacking

Re: Pattern matching from a text document

2005-03-23 Thread infidel
First, if you're going to loop over each line, do it like this: for line in file('playerlist.txt'): #do stuff here Second, this statement is referencing the *second* item in the list, not the first: match = ph.match(list[1]) Third, a simple splitting of the lines by some delimiter character

Re: _conditionally_ returning to point where exception was raised?

2005-03-16 Thread infidel
There's no "Resume Next" in python. Once you catch an exception, the only way you can go is forward from that point. So if B.CallingMethod catches an exception that was raised in A.CalledMethod, all it could do is try calling A.CalledMethod again, it can't jump back to the point where the excepti

Re: pyparsing: parseString confusion

2005-03-11 Thread infidel
I've notice the same thing. It seems that it will return as much as it can that matches the grammar and just stop when it encounters something it doesn't recognize. -- http://mail.python.org/mailman/listinfo/python-list

Re: Win32api shellexecute Bshow

2005-02-16 Thread infidel
Acrobat is stupid like this. I haven't yet found a way to prevent it from launching a new window, so I gave up and went with GhostScript and GSPrint instead. Works fabulously. -- http://mail.python.org/mailman/listinfo/python-list

Re: delay and force in Python

2005-01-20 Thread infidel
Of course I meant to put a break out of the loop after the print statement. Duh on me. -- http://mail.python.org/mailman/listinfo/python-list

Re: delay and force in Python

2005-01-19 Thread infidel
It took me a while to figure out what the "translated" code was trying to do. Here's a quick example that I think accomplishes the same thing: >>> for i, n in enumerate(x for x in xrange(998) if x % 2 == 0): ... if i == 1: ... print n ... 2 -- http://mail.python.org

Re: Python mascot proposal

2004-12-13 Thread infidel
Not that my opinion is worth anything in these matters, but I like the upper-left example at http://exogen.cwru.edu/python.png the best (out of the samples I've seen thus far). I don't like the "gear" shape, and I think adding a coil or circle around the "head" detracts somewhat from the look. I