Re: other ways to check for ?

2006-11-02 Thread Sybren Stuvel
Christophe enlightened us with: > I don't think it's a good idea because when you place a try catch > block around a function call, you'll catch any exception thrown by > the function itself and not only the "cannot be called" exception. That depends on the exception you're catching, doesn't it?

Re: other ways to check for ?

2006-11-02 Thread Sybren Stuvel
elderic enlightened us with: > are there other ways than the ones below to check for 'function'> in a python script? First of all, why would you want to? If you want to call the object as a function, just do so. Handle the exception that is raised when it's raised. Sybren -- Sybren Stüvel Stü

Re: which one of these is better?

2006-10-26 Thread Sybren Stuvel
John Salerno enlightened us with: > Hmm, looks like this doesn't work anyway if open() doesn't work, > because then f.close() raises an UnboundLocalError for obvious > reasons. Neither work 100% correct, actually. If the file can be located and opened, but not read, the message Could not loca

Re: displaying \n-less prompts in a pythonic way

2006-10-26 Thread Sybren Stuvel
alf enlightened us with: > I have a command line program which also does some interaction with the > user using stdin and stdout. > > My requirement is to print prompt so the user can answer in the same > line. Unfortunately: > > print 'enter command:', > > > does not really work as the comma i

Re: A py2exe like tool for Linux

2006-10-24 Thread Sybren Stuvel
Paolo Pantaleo enlightened us with: > is thre something like py2exe for Linux? I don't need to build a > standalone executable (most Linuxes have python instaled), but at > least I need to provide all the needed libraries togheter with my > source code, so users just need to download one file, and

Re: Change on file

2006-10-24 Thread Sybren Stuvel
Fulvio enlightened us with: > I was thinking about use md5 check to se if a file had changes since > last check. Am I correct? You can do that, but a check on the mtime (os.stat) would be a lot easier. Sybren -- Sybren Stüvel Stüvel IT - http://www.stuvel.eu/ -- http://mail.python.org/mailman

Re: Python and CMS

2006-10-23 Thread Sybren Stuvel
Kjell Magne Fauske enlightened us with: > I recommend taking a look at Django [1]. It is not a CMS right out > of the box, but writing one using the Django framework is not that > difficult. Django is my favourite as well. It's very easy to start building a dynamic website. Sybren -- Sybren Stü

Re: Detect Unused Modules

2006-10-21 Thread Sybren Stuvel
Kamilche enlightened us with: > DetectUnusedModules.py - Detect modules that were imported but not > used in a file. When run directly, this class will check all files > in the current directory. Nice as it is, but why not use pylint to check this and many other coding style issues? Sybren -- S

Re: Python Source

2006-10-21 Thread Sybren Stuvel
ArdPy enlightened us with: > Is it possible to hack through the code written by Guido van Rossum > that makes the python interpreter. Yes it is. > If yes please let me know how to begin. If its not then pardon me. Download the source, start hacking. Sybren -- Sybren Stüvel Stüvel IT - http:/

Re: Classes and Functions - General Questions

2006-10-19 Thread Sybren Stuvel
Setash enlightened us with: >> class1.py: >> >> class Class1(object): >> pass >> >> class2.py: >> import class1 This line imports class1.py and places its contents under the name "class1". > classes.py: > > class Class1 > pass > > class Class2(Class1) > pass That's co

Re: Classes and Functions - General Questions

2006-10-18 Thread Sybren Stuvel
Setash enlightened us with: > 1) Classes. How do you extend classes? > > I know its as easy as: > > class classname(a) >do stuff > > > But where does the parent class need to lie? In the same file? Can > it lie in another .py file in the root directory? It doesn't matter at all, as long as 'a'

Re: HTML Encoded Translation

2006-10-17 Thread Sybren Stuvel
Dave enlightened us with: > How can I translate this: > > gi > > to this: > > "gi" > > I've tried urllib.unencode and it doesn't work. As you put so nicely in the subject: it is HTML encoding, not URL encoding. Those are two very different things! Try a HTML decoder, you'll have more luck with tha

Re: building extensions for Windows Python

2006-10-17 Thread Sybren Stuvel
JW enlightened us with: > Thanks to Michael and Nick, I can now cross-compile my Pyrex > extensions for bog-standard Python 2.5 [...] I can now use Linux to > cross-build my extension for Windows, and my preliminary testing > (under WINE -- See the original post. I must adhere to my > employment c

Re: Save/Store whole class (or another object) in a file

2006-10-17 Thread Sybren Stuvel
[EMAIL PROTECTED] enlightened us with: > is it possible in python (with/without matplotlib, numpy etc) to > store a whole class with its data into a file Check out the pickle module. Sybren -- Sybren Stüvel Stüvel IT - http://www.stuvel.eu/ -- http://mail.python.org/mailman/listinfo/python-li

Re: How to send E-mail without an external SMTP server ?

2006-10-16 Thread Sybren Stuvel
[EMAIL PROTECTED] enlightened us with: > Yes, I want to find a way to send email without an external smtp server. You can't. Use a DNS server to find the MX record of the destination domain, connect to that SMTP server, then deliver the mail. Sybren -- Sybren Stüvel Stüvel IT - http://www.stuv

Re: Need a Regular expression to remove a char for Unicode text

2006-10-13 Thread Sybren Stuvel
శ్రీనివాస enlightened us with: > Can any one tell me how can i remove a character from a unocode > text. కల్<200c>&హార is a Telugu word in Unicode. Here i want to > remove '&' but not replace with a zero width char. And one more > thing, if any whitespaces are there b

Re: Funky file contents when os.rename or os.remove are interrupted

2006-10-10 Thread Sybren Stuvel
Russell Warren enlightened us with: > On first pass I would think that both of those calls are single step > operations (removing/changing an entry in the FAT, or FAT-like > thing, on the HDD) and wouldn't result in an intermediate, > null-populated, step, but the evidence seems to indicate I'm > w

Re: Converting MSWord Docs to PDF

2006-10-10 Thread Sybren Stuvel
[EMAIL PROTECTED] enlightened us with: > is it possible to convert MSword docs into PDF format? Yes, it is. check out http://www.stuvel.eu/ooo-python#header3. It's about converting Excel to PDF, but it equally applies to MSWord. Sybren -- Sybren Stüvel Stüvel IT - http://www.stuvel.eu/ -- htt

Re: WSGI - How Does It Affect Me?

2006-10-08 Thread Sybren Stuvel
Theerasak Photha enlightened us with: >> > 3. Using IIS [...] >> >> Why would you want to use that monstrosity? > > Two words: "contractual obligation" That doesn't answer the question. It only makes me ask it to someone else, namely the parties involved in creating the contract. Sybren -- Sybre

Re: WSGI - How Does It Affect Me?

2006-10-08 Thread Sybren Stuvel
Gregory Piñero enlightened us with: > So I keep hearing more and more about this WSGI stuff, and honestly I > still don't understand what it is exactly AFAIK it's a standard for web frameworks. In such a framework, you receive a 'request' object, and return a 'response' object. If I'm correct, the

Re: operator overloading + - / * = etc...

2006-10-07 Thread Sybren Stuvel
Tim Chase enlightened us with: > With the caveat of the "=" mentioned in the subject-line (being > different from "==")...I haven't found any way to override > assignment in the general case. Why would you want to do that? Sybren -- Sybren Stüvel Stüvel IT - http://www.stuvel.eu/ -- http://ma

Re: operator overloading + - / * = etc...

2006-10-07 Thread Sybren Stuvel
SpreadTooThin enlightened us with: > Can these operators be overloaded? Yes. > If so. How? Implement __add__, __sub__ etc. in the class that you want to be able to add, subtract, etc. Sybren -- Sybren Stüvel Stüvel IT - http://www.stuvel.eu/ -- http://mail.python.org/mailman/listinfo/pytho

Re: ANN: SimpleJSONRPCServer

2006-10-07 Thread Sybren Stuvel
aum enlightened us with: > I've built a module called SimpleJSONRPCServer, which is essentially > the same as the familiar python library module SimpleXMLRPCServer, > except that it uses the JSON-RPC protocol. Thanks a lot! I've used XML-RPC on a low-speed device, and it was way too slow. Sybren

Re: How to get keyboard event in Linux console?

2006-10-03 Thread Sybren Stuvel
Jia,Lu enlightened us with: > I want to deal keyboard event in Linux console. > Example: I Create a deamon at background and when I press F1 key > then print Hello at Console. Type "who" and see which PTY you're connected to: sybren pts/02006-10-04 07:55 (klappie.stuvel.eu) So I'm conn

Re: Best way to handle large lists?

2006-10-03 Thread Sybren Stuvel
Bill Williams enlightened us with: > I don't know enough about Python internals, but the suggested > solutions all seem to involve scanning bigList. Can this presumably > linear operation be avoided by using dict or similar to find all > occurrences of smallist items in biglist and then deleting th

Re: Pythonic API design: detailed errors when you usually don't care

2006-10-02 Thread Sybren Stuvel
Simon Willison enlightened us with: > try: > do_something() > except HttpError: > # An HTTP error occurred > except ApplicationError: > # An application error occurred > else: > # It worked! > > This does the job fine, but has a couple of problems. > I anticipate that most people using my

Re: Python/UNO/OpenOffice?

2006-10-02 Thread Sybren Stuvel
John Machin enlightened us with: > Many thanks for all that, olive; I made the minimal hacks to make it > open an XLS ffile, and it worked! > I'll try to see why that worked and my previous experiment crashed > inside a DLL. Thanks, keep us posted! Sybren -- Sybren Stüvel Stüvel IT - http://ww

Re: Python/UNO/OpenOffice?

2006-10-01 Thread Sybren Stuvel
John Machin enlightened us with: > Hi, Sybren. I tried folloing your recipe on Windows with OOo 2.0 ... > > Minor problem: the executable is called soffice, not ooffice. > > Major problem: it crashed right at the start, somewhere in the maze > of dlls. That's not nice. > Has anyone managed to get

Re: Escapeism

2006-09-30 Thread Sybren Stuvel
Kay Schluehr enlightened us with: > Usually I struggle a short while with \ and either succeed or give up. > Today I'm in a different mood and don't give up. So here is my > question: > > You have an unknown character string c such as '\n' , '\a' , '\7' etc. > > How do you echo them using print? >

Re: builtin regular expressions?

2006-09-30 Thread Sybren Stuvel
Antoine De Groote enlightened us with: > Can anybody tell me the reason(s) why regular expressions are not built > into Python like it is the case with Ruby and I believe Perl? They _are_ built into Python. Python ships with the 're' module. > Python Culture says: 'Explicit is better than implic

Re: for: else: - any practical uses for the else clause?

2006-09-30 Thread Sybren Stuvel
Paul Rubin enlightened us with: >> height = 0 >> for block in stack: >> if block.is_marked(): >> print "Lowest marked block is at height", height >> break >> height += block.height >> else: >> raise SomeError("No marked block") > > all_heights = [block.height for blo

Re: Python/UNO/OpenOffice?

2006-09-30 Thread Sybren Stuvel
[EMAIL PROTECTED] enlightened us with: > Are then any currently active and reasonably mature Python plugins/ > apis/whatever for programming/scripting OpenOffice? The page I've > found is http://udk.openoffice.org/python/python-bridge.html, but it > was last updated more than a year ago. Aside fro

Re: Making sure script only runs once instance at a time.

2006-09-29 Thread Sybren Stuvel
Tim Williams enlightened us with: > def check_lock(): > import os, sys > try: > os.remove({filename}) > except: > if "Permission denied" in sys.exc_info()[1]: > print 'This program is already running' > sys.exit() > f_lock = open({filename},'w

Re: retry in exception

2006-09-29 Thread Sybren Stuvel
Antoine De Groote enlightened us with: > I hope I don't upset anybody by comparing Python to Ruby (again). Is > there something like Ruby's retry keyword in Python? Please don't assume that everybody knows Ruby through and through... Sybren -- Sybren Stüvel Stüvel IT - http://www.stuvel.eu/ -

Re: using the email module

2006-09-28 Thread Sybren Stuvel
Erik Johnson enlightened us with: > # Ah! Yes, that works! Thank you! ;) You're welcome! Sybren -- Sybren Stüvel Stüvel IT - http://www.stuvel.eu/ -- http://mail.python.org/mailman/listinfo/python-list

Re: using the email module

2006-09-28 Thread Sybren Stuvel
Erik Johnson enlightened us with: > When I run this and view the email I receive in MS Outlook Express, > what I see is the HTML rendered in the body of the message, my body > is not seen anywhere and there is no attachment. If the HTML document should really be attached, give it a Content-Dis

Re: License / Registration key enabled software

2006-09-28 Thread Sybren Stuvel
Steve Holden enlightened us with: > And you guarantee that the contents of the smartcard is only used by > one user at a time by building a licensing system for the > smartcards? We can never, ever make a 100% guarantee that people won't copy what you supply them. The only way to do that is to tho

Re: License / Registration key enabled software

2006-09-28 Thread Sybren Stuvel
Mike Playle enlightened us with: > Imagine you're an IT manager for a medium-to-large company who wants > to use some expensive piece of software. You talk to the vendor and > buy a licence to use the software on up to 5 machines at once, but > you don't know who in the company will want to use it,

Re: License / Registration key enabled software

2006-09-28 Thread Sybren Stuvel
Steve Holden enlightened us with: > Otherwise you might as well say that any costs associated with using > a piece of software (including purchase pricing) are "hostile to the > wants of the user". It's true. People pay because they have to, but they'd rather not. Sybren -- Sybren Stüvel Stüve

Re: QuoteSQL

2006-09-26 Thread Sybren Stuvel
Fredrik Lundh enlightened us with: > and now we're waiting for the "['%s']*len(t)" vs. "'%s' for i in t" > benchmarks (and the "consistency is more important than efficiency" > and "creating extra objects is conceptually wrong" followups, and > the "it depends on what you mean by" followups to the

Re: QuoteSQL

2006-09-26 Thread Sybren Stuvel
Tim Chase enlightened us with: > >>> cur.execute("select * from people where last_name in (%s)" % > ','.join('%s' for i in xrange(len(t))), > t) But since the value of 'i' isn't used at all, it can be abbreviated to: >>> cur.execute("select * from people where last_name in (%s)" %

Re: does anybody earn a living programming in python?

2006-09-26 Thread Sybren Stuvel
walterbyrd enlightened us with: > If so, I doubt there are many. > > I wonder why that is? www.uwklantprofiel.nl and www.uwpensioenanalyse.nl, both systems are written in Python, although the website of the former is still in PHP. It'll be Python soon, too. I've created both systems. Sybren --

Re: QuoteSQL

2006-09-26 Thread Sybren Stuvel
Lawrence D'Oliveiro enlightened us with: > Because quoting the wildcards introduces backslash specials before > each wildcard. Quoting non-wildcards then causes those backslashes > to be doubled, which means they escape themselves instead of the > wildcards. I don't know about other DBMSes, but in

Re: QuoteSQL

2006-09-26 Thread Sybren Stuvel
Lawrence D'Oliveiro enlightened us with: > You're proposing two separate functions: > > 1) quoting of non-wildcard specials > 2) quoting of wildcard specials I'm suggesting functions based on the role of the string they need to escape, not the characters in that string. 1) Quoting of

Re: where are isinstance types documented?

2006-09-26 Thread Sybren Stuvel
codefire enlightened us with: > I'm using the isinstance built-in function. I've found the docs for > it, but there are no docs on the supported types. All types/classes are supported. > For example isinstance(a, int) works fine but isinstance(s, string) > doesn't - because 'string is not known'.

Re: concat next line with previous

2006-09-26 Thread Sybren Stuvel
[EMAIL PROTECTED] enlightened us with: > hi > what is the python way to concat 2 lines eg concated = line1 + line2 Sybren -- Sybren Stüvel Stüvel IT - http://www.stuvel.eu/ -- http://mail.python.org/mailman/listinfo/python-list

Re: QuoteSQL

2006-09-26 Thread Sybren Stuvel
Lawrence D'Oliveiro enlightened us with: > The trouble with this is that, instead of offering extra functionality, it > leaves the door open to making two stupid mistakes: > > 2) quoting of wildcards BEFORE quoting of non-wildcards Why is this a "stupid" mistake in your view? Please explain th

Re: Extend file type

2006-09-26 Thread Sybren Stuvel
abcd enlightened us with: > Any suggestions on how to find out? I did try adding to MyFile > > def __call__(self, *args): > print "calling:", args > return file.__call__(self, *args) > > but I never see that either. I don't know the answer to your problem, but I can explain why this d

Re: QOTW (was Re: does anybody earn a living programming in python?)

2006-09-26 Thread Sybren Stuvel
Aahz enlightened us with: > Fredrik Lundh <[EMAIL PROTECTED]> wrote: >> >>well, if you're only watching mtv, it's easy to think that there's >>obviously not much demand for country singers, blues musicians, >>British hard rock bands, or melodic death metal acts. > > Any other votes for this being

Re: R.S.I. solutions?

2006-09-25 Thread Sybren Stuvel
Paddy enlightened us with: > All this keyboarding has finally caught up with me and I'm getting > aches in my fingers. Use more force with your fingers, and take regular typing breaks. Often RSI is caused by subtle movements without applying a lot of force. Another good way to beat RSI is to lea

Re: QuoteSQL

2006-09-25 Thread Sybren Stuvel
Lawrence D'Oliveiro enlightened us with: >> An escaping function should be small and not do all kinds of >> escaping for different situations at once. > > Even when the two situations are related? Yup, even then. Different situations need different escaping functions. Sybren -- Sybren Stüvel St

Re: QuoteSQL

2006-09-25 Thread Sybren Stuvel
Duncan Booth enlightened us with: > I think his point was that any '%' characters inside name act like > wildcards whereas his version looked for literal percents. But of course. > This could be an argument for having a utility function to escape > the wildcards for this sort of situation, but ce

Re: QuoteSQL

2006-09-25 Thread Sybren Stuvel
Lawrence D'Oliveiro enlightened us with: >> Wouldn't this be a whole lot better? >> >> cursor.execute( >> "select * from details where person_name like ?", >> '%' + name + '%' >> ) > > No. Can you figure out why? Ok, should have tested it better. This works fine on my machine, though: cu

Re: QuoteSQL

2006-09-25 Thread Sybren Stuvel
Lawrence D'Oliveiro enlightened us with: > "select * from details where person_name like" > " concat(\"%%\", %s, \"%%\")" \ > % \ > QuoteSQL(name, True) Wouldn't this be a whole lot better? cursor.execute( "select * from details where person_name like ?", '%' +

Re: Talking to marketing people about Python

2006-09-25 Thread Sybren Stuvel
Roy Smith enlightened us with: > I'm working on a product which for a long time has had a Perl > binding for our remote access API. A while ago, I wrote a Python > binding on my own, chatted it up a bit internally, and recently had > a (large) customer enquire about getting access to it. > > I ask

Re: QuoteSQL

2006-09-24 Thread Sybren Stuvel
Lawrence D'Oliveiro enlightened us with: > Yes, I have done blobs. Still need a quoting function for the > specials, though. Why? What makes your data so different from mine? I can store newlines and the likes just fine in a regular text field. Sybren -- Sybren Stüvel Stüvel IT - http://www.st

Re: Automatic import PEP

2006-09-24 Thread Sybren Stuvel
Connelly Barnes enlightened us with: > I wrote the 'autoimp' module [1], which allows you to import lazy modules: > > The main point of autoimp is to make usage of the interactive Python > prompt more productive by including "from autoimp import *" in the > PYTHONSTARTUP file. Sounds like a great

Re: License / Registration key enabled software

2006-09-24 Thread Sybren Stuvel
T enlightened us with: > We all know that there are many softwares that require some license > key or registration key to enable them. How does one implement > something like this in python? Why do you want to? I've never seen software successfully protected by such schemes. If you really want to

Re: QuoteSQL

2006-09-24 Thread Sybren Stuvel
Lawrence D'Oliveiro enlightened us with: > Why doesn't MySQLdb provide a function like this: Because generally you're able to pass newlines and the like just fine. You can even store binary data into a BLOB column. Sybren -- Sybren Stüvel Stüvel IT - http://www.stuvel.eu/ -- http://mail.pytho

Re: Request for tips on my first python script.

2006-09-08 Thread Sybren Stuvel
Lex Hider enlightened us with: > Any tips on the code quality and use of python would be appreciated. > I've got a feeling the overall structure is up the creek. I'll post some remarks about the code ;-) > HOME = os.path.expanduser("~") I wouldn't use this. Just use os.environ['HOME']. In most c

Re: How to build extensions on Windows?

2006-09-07 Thread Sybren Stuvel
Kevin D Smith enlightened us with: > I've written a simple Python extension for UNIX, but I need to get > it working on Windows now. I'm having some difficulties figuring > out how to do this. I had to do the same, and I didn't get much result. My solution: install Cygwin, use the Python that co

Re: sending emails using python

2006-09-07 Thread Sybren Stuvel
Tim Williams enlightened us with: > Can you send email via it using outlook express or a similar > POP3/IMAP mail client? Wouldn't you use a SMTP client to send email? Sybren -- Sybren Stüvel Stüvel IT - http://www.stuvel.eu/ -- http://mail.python.org/mailman/listinfo/python-list

Re: sending emails using python

2006-09-07 Thread Sybren Stuvel
Steve Holden enlightened us with: > This is untrue for the Python smtplib, though correct according to > the RFCs. The SMTP.data() method uses a locally-declared function > called quotedata() to ensure the correct line endings, so using "\n" > will result in the same message as using "\r\n". Ah, w

Re: sending emails using python

2006-09-07 Thread Sybren Stuvel
sridhar enlightened us with: > iam having user account on an exchangeserver. > with that can i send an email using python? > > if iam using the following code iam getting error > > > fromAddress = '[EMAIL PROTECTED]' > toAddress = '[EMAIL PROTECTED]' > msg = "Subject: Hello\n\nThis is the body of t

Re: OpenOffice.org and Python

2006-09-06 Thread Sybren Stuvel
olive enlightened us with: > you did not understand Michel question because Ubuntu seems to be > the only distribution coming with OpenOffice and Python 2.4 compiled > together. Ah, okay. I have no other distributions here, so I rely on others to give me more information about them. > Others plat

Re: [Article] OpenOffice.org and Python

2006-09-06 Thread Sybren Stuvel
MC enlightened us with: > Thanks! You're welcome! > - and Python 2.4.x? I've used Python 2.4.3 to write the article. > - I have Python 2.4 and then "embbed Python 2.3 of OOo" ; how > install some things in this last Python? I dream to call Pywin32 > from OOo... Please rephrase that qu

Re: [ANN] IronPython 1.0 released today!

2006-09-05 Thread Sybren Stuvel
Jim Hugunin enlightened us with: > I'm extremely happy to announce that we have released IronPython 1.0 > today! http://www.codeplex.com/IronPython Congratulations! > We were also able to release IronPython publicly from Microsoft with > a BSD-style license. [...] Without the drive and input of

[Article] OpenOffice.org and Python

2006-09-05 Thread Sybren Stuvel
Hi folks! The two small snippets I wrote two days ago were well received. With the danger of being called a hero I proceded and wrote a proper article about OpenOffice.org and Python. It contains the following sections: * Preparation * Gaining access to a document * Getting to the d

Re: threading support in python

2006-09-04 Thread Sybren Stuvel
km enlightened us with: > Is there any PEP to introduce true threading features into python's > next version as in java? i mean without having GIL. What is GIL? Except for the Dutch word for SCREAM that is... > when compared to other languages, python is fun to code but i feel > its is lacking be

Re: Exception EOFError.

2006-09-04 Thread Sybren Stuvel
Dennis Lee Bieber enlightened us with: > The above is windows, I believe Linux uses instead of > That's correct. And so do all unix systems including MacOS X. Sybren -- Sybren Stüvel Stüvel IT - http://www.stuvel.eu/ -- http://mail.python.org/mailman/listinfo/python-list

Re: FYI: getting data from an OpenOffice.org spreadsheet

2006-09-03 Thread Sybren Stuvel
John Machin enlightened us with: > Firstly, let me say that you are highly commended for wading so far > into the OOo docs and producing two pieces of code that actually do > something. I've opened up the docs two or three times, said "Waaahht > the " and closed them rapidly. Thanks. I had the

Re: FYI: getting data from an OpenOffice.org spreadsheet

2006-09-03 Thread Sybren Stuvel
John Machin enlightened us with: > Suppose one has over a hundred spreadsheets (real-life example: > budgets from an organisation's reporting centres) ... manually > opening each in OOo Calc is less than appealing, and not very > robust. True. There are functions that can load files as well. Combi

Re: FYI: getting data from an OpenOffice.org spreadsheet

2006-09-03 Thread Sybren Stuvel
Hi folks, I just noticed I still had the "no archive" header on, which is rather stupid. If I want to make life easier for people, the information I posted in this thread should be archived! Here is a small summary: Get data from an OpenOffice.org spreadsheet with a Python script. It works on the

Re: C# equivalent to range()

2006-06-06 Thread Sybren Stuvel
Erik Max Francis enlightened us with: >> The other zilion persons who were not interested (other than the four I >> mentioned above) silently and peacefully ignored the question on went >> on with their happy lifes. > > That's because many of them have killfiled you. I can say that I didn't killfi

Re: Max function question: How do I return the index of the maximum value of a list?

2006-06-04 Thread Sybren Stuvel
jj_frap enlightened us with: > When I try to print the "winner" (I've not coded for kicker strength > and ties yet) via the max function, it returns the maximum value in > the list rather than the index associated with that value. > > How do I return the index? You can't even be sure it exists - t

Re: Best way to do data source abstraction

2006-06-01 Thread Sybren Stuvel
Arthur Pemberton enlightened us with: > What is the best way to do data source abtraction? That depends on your data source. For files, file-like objects are an abstraction. For databases there is PEP 249. > I was thinking of almost having classA as my main class, and have > classA dynamically "a

Re: shuffling elements of a list

2006-05-31 Thread Sybren Stuvel
David C Ullrich enlightened us with: > I thought that the fact that you could use the same trick for > _shuffling_ a list was my idea, gonna make me rich and famous. I > guess I'm not the only one who thought of it. Anyway, you can use > DSU to _shuffle_ a list by decorating the list with random n

Re: Best Python Editor

2006-05-31 Thread Sybren Stuvel
Manoj Kumar P enlightened us with: > Can anyone tell me a good python editor/IDE? > It would be great if you can provide the download link also. VIM 7 is great, http://www.vim.org/ Sybren -- The problem with the world is stupidity. Not saying there should be a capital punishment for stupidity, b

Re: An algorithm problem

2006-05-31 Thread Sybren Stuvel
Bo Yang enlightened us with: > I have writen a python program to slove a problem described as > below: Please post again, but then leaving indentation intact, since this is unreadable. Sybren -- The problem with the world is stupidity. Not saying there should be a capital punishment for stupidit

Re: generating random passwords ... for a csv file with user details

2006-05-28 Thread Sybren Stuvel
k.i.n.g. enlightened us with: > Now I have to write a script to generate random password in the > password field for each user. A simple algorithm is sufficient for > passwords Check out the source of pwsafe, it has a great password generator. It can generate with different lengths, based on amoun

Re: Python - Web Display Technology

2006-05-22 Thread Sybren Stuvel
SamFeltus enlightened us with: > 1. Loss of back button > Isn't this really a myth? No, it isn't a myth. Pressing the back button is the action second most performed in a browser, clicking a link being the first. People want to go back from where they came. > A page with a time dimension, be it F

Re: Python - Web Display Technology

2006-05-22 Thread Sybren Stuvel
SamFeltus enlightened us with: > I do find it interesting that Flash folks readily will acknowledge > that Flash has shortcomings yet anti-Flash folks seem to have great > difficulty acknowledging Flash's positive features over HTML. I must say I've never seen a pro-Flash person acknowledging that

Re: XML/HTML Encoding problem

2006-05-22 Thread Sybren Stuvel
Dale Strickland-Clark enlightened us with: > So it encodes the entity reference to € (Euro sign).  I need it to > remain as € so that the resulting HTML can render properly in > a browser. If you want proper display, why not use UTF-8? Sybren -- The problem with the world is stupidity. Not sa

Re: Python - Web Display Technology

2006-05-21 Thread Sybren Stuvel
[EMAIL PROTECTED] enlightened us with: > None of you seem to know what you are talking about. That's not a way to make friends. I very well know what I'm talking about. None of the issues I've raised are negated by what you say, so every single one still stands. > Flash also behaves consistently

Re: FAQ for XML with Python

2006-05-19 Thread Sybren Stuvel
Dave Kuhlman enlightened us with: > For those who are beginners to using Python to process XML, I've > recently updated my Python XML FAQ (PyXMLFaq). It has a number of > code samples that may help you get started. You might want to include a list of things you assume the reader already knows, in

Re: Python - Web Display Technology

2006-05-19 Thread Sybren Stuvel
Florian Diesch enlightened us with: >> - Flash is a proprietary technology requiring a proprietary plugin. > > There seem to be at least two free implementations: But the website of OP together with the websites of many other people are incompatible with those, since they require the latest and gr

Re: Newbie append() question

2006-05-19 Thread Sybren Stuvel
Brian Blazer enlightened us with: > I'm still not sure why it was grabbing the prompt string though. Me neither. Try it in a standalone script instead of an interactive session. Sybren -- The problem with the world is stupidity. Not saying there should be a capital punishment for stupidity, but

Re: How to append to a dictionary

2006-05-19 Thread Sybren Stuvel
Harlin Seritt enlightened us with: > I have some code here: > > groups = {'IRISH' : 'green', 'AMERICAN' : 'blue'} > > I want to add another key: 'ITALIAN' : 'orange' > > How do I append this to 'groups'? groups['ITALIAN'] = 'orange' Sybren -- The problem with the world is stupidity. Not saying t

Re: Newbie append() question

2006-05-19 Thread Sybren Stuvel
Brian Blazer enlightened us with: > def getCurrentClasses(): > classes = [] > print 'Please enter the class name. When finished enter D.' > while (c != "D"): No need for the parentheses, and 'c' doesn't have a value yet. If you add 'c=""' before the while-loop, it should

Re: Opensource vs Microsoft, Wat do you think about opensource?

2006-05-19 Thread Sybren Stuvel
Ben Finney enlightened us with: > Please don't spam here to ask for discussion on another forum, on a > tangentially related topic. Hey, it's at least better than asking for a discussion on a tangentially related topic _here_ ;-) Sybren -- The problem with the world is stupidity. Not saying ther

Re: Tabs are *MISUNDERSTOOD*, *EVIL* AND *STUPID*, end of discussion. (Re: Tabs versus Spaces in Source Code)

2006-05-19 Thread Sybren Stuvel
Duncan Booth enlightened us with: > Can you point at any significant body of publically visible Python > code which uses tabs exclusively? Everything Python at http://www.stuvel.eu/software > Also, in the open source universe you are quite likely to pull in > bits of code from other projects, and

Re: SPE output

2006-05-18 Thread Sybren Stuvel
Alex Pavluck enlightened us with: > SPE is amazing with the intellisense but maybe there is a better > choice out there. Check VIM. The newly released VIM 7.0 has smart completion too (intellisense is a trademark of Microsoft) Sybren -- The problem with the world is stupidity. Not saying there s

Re: Python - Web Display Technology

2006-05-18 Thread Sybren Stuvel
SamFeltus enlightened us with: > I guess there isn't much to understand. If you are satisfied with a > text based, static image web, that is light on artistic > possabilities, all that HTML stuff is acceptable. You don't need Flash to be artistic. > Perhaps the HTML/JS group will even get off th

Re: Python - Web Display Technology

2006-05-18 Thread Sybren Stuvel
SamFeltus enlightened us with: > I am trying to figure out why so little web development in Python > uses Flash as a display technology. There are a couple of reasons: - Flash is bad for websites that are 100% done inside the Flash movie. In such a case the back-button doesn't work anym

Re: Python - Web Display Technology

2006-05-18 Thread Sybren Stuvel
Heiko Wundram enlightened us with: > And: the web is a platform to offer _information_. Not to offer > shiny graphics/sound [...] Many would disagree... Not me, but I know a lot of people that would. Sybren -- The problem with the world is stupidity. Not saying there should be a capital punishm

Re: Tabs versus Spaces in Source Code ('semantic' vs. arbitrary indentation)

2006-05-17 Thread Sybren Stuvel
Dave Hansen enlightened us with: > Assume the code was written by someone using 4-space tabs. To them, > the code is: > >def sqlcall(): >--->cursor.execute('select id, item, amount, field4, >--->--->--->--->...'from table1 where amount>100') > > (where ---> represents an 4-space t

Re: \t not working

2006-05-17 Thread Sybren Stuvel
Alex Pavluck enlightened us with: > Q: As an exercise, write a single string that: > Procuces >this >output. > > > A? > print "produces",'\n',"\t","this","\n","\t","output." Just nitpicking, since you already got your answer, but that's not a s

Re: Tabs are EVIL *and* STUPID, end of discussion. (Re: Tabs versus Spaces in Source Code)

2006-05-17 Thread Sybren Stuvel
Andy Sy enlightened us with: > Like I said, you'll *NEVER* get that fancy shmancy 'semantic > indentation' idea to work properly in the most basic utilities which > have the 8-space tabs assumption hardcoded in them. Fair enough. How much code is viewed with less and cat, and how much is viewed us

Re: Tabs are EVIL *and* STUPID, end of discussion. (Re: Tabs versus Spaces in Source Code)

2006-05-17 Thread Sybren Stuvel
Andy Sy enlightened us with: > Now... if you say you SHOULDN'T mix tabs and spaces (indeed this is > generally regarded as a BAD idea esp. in Python code) I indeed say so. > then WHAT THE HECK do you need to use tab characters in the source > code for anyway (besides saving a measly few bytes) ??

Re: Tabs versus Spaces in Source Code

2006-05-17 Thread Sybren Stuvel
achates enlightened us with: > True! but normally if I'm editing someone else's code then I'm only > making small changes and so can't be bothered to temporarily cripple my > editor. If I'm merging my code with someone else's space-indented code > then piping through sed 's/TAB/SPACES' does the tri

  1   2   3   4   5   >