Re: other ways to check for type 'function'?
elderic enlightened us with: are there other ways than the ones below to check for type '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üvel IT - http://www.stuvel.eu/ -- http://mail.python.org/mailman/listinfo/python-list
Re: other ways to check for type 'function'?
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? Sybren -- Sybren Stüvel Stüvel IT - http://www.stuvel.eu/ -- http://mail.python.org/mailman/listinfo/python-list
Re: displaying \n-less prompts in a pythonic way
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 is carried over to the following lines and the indentation gets messed up. I can use sys.stdout.write('enter command:') instead but kind of do not like sys.stdout.write mixed up with print's statements used to display other informations. Is there a pythonic solution for the problem? Yeah, write a function: def prompt(label): '''Prompts the user, returning the typed text''' sys.stdout.write(label) return sys.stdin.readline() Sybren -- Sybren Stüvel Stüvel IT - http://www.stuvel.eu/ -- http://mail.python.org/mailman/listinfo/python-list
Re: which one of these is better?
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 locate the file labtables.sql File Not Found is plain wrong. Sybren -- Sybren Stüvel Stüvel IT - http://www.stuvel.eu/ -- http://mail.python.org/mailman/listinfo/python-list
Re: Change on file
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/listinfo/python-list
Re: A py2exe like tool for Linux
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 not several libraries. You can use Freeze: http://lists.fourthought.com/pipermail/4suite/2005-March/007127.html Sybren -- Sybren Stüvel Stüvel IT - http://www.stuvel.eu/ -- http://mail.python.org/mailman/listinfo/python-list
Re: Python and CMS
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üvel Stüvel IT - http://www.stuvel.eu/ -- http://mail.python.org/mailman/listinfo/python-list
Re: Python Source
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://www.stuvel.eu/ -- http://mail.python.org/mailman/listinfo/python-list
Re: Detect Unused Modules
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 -- Sybren Stüvel Stüvel IT - http://www.stuvel.eu/ -- http://mail.python.org/mailman/listinfo/python-list
Re: Classes and Functions - General Questions
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 correct. or would I still need to call it as: class Class2(classes.Class1) pass Nope, since the name classes is unknown. Sybren -- Sybren Stüvel Stüvel IT - http://www.stuvel.eu/ -- http://mail.python.org/mailman/listinfo/python-list
Re: Classes and Functions - General Questions
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' is a valid class name. This works too: import x class Classname(x.A): do stuff It's common to start classnames with a captial letter. Can my directory structure look like .. /class1.py /class2.py And have class2 inherit class1 without any import statements, or need it be imported first? It needs to be imported first: class1.py: class Class1(object): pass class2.py: import class1 class Class2(class1.Class1): pass 2) Function overloading - is it possible? Nope. At least, not that I'm aware of. Can I have the following code, or something which acts the same in python?: def function(a, b) do things def function(a, b, c) do things only if I get a third argument def function(a, b, c=None): do things, do other things if c is not None. Sybren -- Sybren Stüvel Stüvel IT - http://www.stuvel.eu/ -- http://mail.python.org/mailman/listinfo/python-list
Re: Save/Store whole class (or another object) in a file
[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-list
Re: building extensions for Windows Python
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 contract!) seems to show that it works. Congratulations! Sybren -- Sybren Stüvel Stüvel IT - http://www.stuvel.eu/ -- http://mail.python.org/mailman/listinfo/python-list
Re: HTML Encoded Translation
Dave enlightened us with: How can I translate this: #103;#105; 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 that... Sybren -- Sybren Stüvel Stüvel IT - http://www.stuvel.eu/ -- http://mail.python.org/mailman/listinfo/python-list
Re: How to send E-mail without an external SMTP server ?
[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.stuvel.eu/ -- http://mail.python.org/mailman/listinfo/python-list
Re: Need a Regular expression to remove a char for Unicode text
à°¶à±à°°à±à°¨à°¿à°µà°¾à°¸ 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 before and after '' char, the text should be kept as it is. So basically, you want to match 200c and replace it with 200c, but only if it's not surrounded by whitespace, right? r(?!\s)\x200c(?!\s) should match. I'm sure you'll be able to take it from there. Sybren -- Sybren Stüvel Stüvel IT - http://www.stuvel.eu/ -- http://mail.python.org/mailman/listinfo/python-list
Re: Converting MSWord Docs to PDF
[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/ -- http://mail.python.org/mailman/listinfo/python-list
Re: Funky file contents when os.rename or os.remove are interrupted
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 wrong... They require multiple blocks to be written to disc, so if you're not using a journaling filesystem, bad things can happen. Any insight from someone with knowledge of the internal operations of os.remove and/or os.rename would be greatly appreciated, although I expect the crux may be at the os level and not in python. You're right about that. Sybren -- Sybren Stüvel Stüvel IT - http://www.stuvel.eu/ -- http://mail.python.org/mailman/listinfo/python-list
Re: WSGI - How Does It Affect Me?
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 WSGI describes things like the method and property names on those objects etc. What I'm most confused about is how it affects me. I've been writing small CGI programs in Python for a while now whenever I have a need for a web program. Is CGI now considered Bad? I've never considered CGI bad, but I do consider it to be a hassle to make anything non-trivial. If you want a website with template engine, web-based database admin, and automatic form generation and validation, it's easier to use an existing web framework. What is the equivalent of a quick CGI script in WSGI, or do I have to use a framework even for that? I'd simply use CGI for that. What do I do if frameworks don't meet my needs and I don't have a desire to program my own? That depends on the needs I guess. Examples of how frameworks don't meet my needs sometimes: 1. Working with SQL Server (Most frameworks seem to at least make it extra work) I've never seen a framework that's unable to work with an SQL server. 2. Need web app to get data from other programs via API (eg QuickBooks) Can any web framework work happily with win32 extensions? You can use any module you want in a Django view, including win32. 3. Using IIS at all for that matter, does WSGI work on IIS, do any frameworks? Why would you want to use that monstrosity? Sybren -- Sybren Stüvel Stüvel IT - http://www.stuvel.eu/ -- http://mail.python.org/mailman/listinfo/python-list
Re: WSGI - How Does It Affect Me?
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 -- Sybren Stüvel Stüvel IT - http://www.stuvel.eu/ -- http://mail.python.org/mailman/listinfo/python-list
Re: ANN: SimpleJSONRPCServer
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 -- Sybren Stüvel Stüvel IT - http://www.stuvel.eu/ -- http://mail.python.org/mailman/listinfo/python-list
Re: operator overloading + - / * = etc...
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/python-list
Re: operator overloading + - / * = etc...
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://mail.python.org/mailman/listinfo/python-list
Re: How to get keyboard event in Linux console?
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 connected to pts/0. If you read from /dev/pts/0, you'll see everything I type. Sybren -- Sybren Stüvel Stüvel IT - http://www.stuvel.eu/ -- http://mail.python.org/mailman/listinfo/python-list
Re: Best way to handle large lists?
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 those occurrences? And how would that beat O(n)? Every element of bigList has to be scanned at one point, either to compare it to every earlier element in bigList and eliminate it, or to compare it to every element in smallList. Run benchmarks on the suggestions, and see which is fastest for yourself. Sybren -- Sybren Stüvel Stüvel IT - http://www.stuvel.eu/ -- http://mail.python.org/mailman/listinfo/python-list
Re: Python/UNO/OpenOffice?
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://www.stuvel.eu/ -- http://mail.python.org/mailman/listinfo/python-list
Re: Pythonic API design: detailed errors when you usually don't care
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 function won't care about the reason; they'll just want a True or False answer. Then they can use an except clause that catches the superclass of all the possible exceptions your function raises. Their ideal API would look like this: if do_something(): # It succeeded else: # It failed This is the C way of doing things. The problem with relying on a return value, is that failure could go unnoticed if the value isn't checked. This might introduce nasty bugs. Sybren -- Sybren Stüvel Stüvel IT - http://www.stuvel.eu/ -- http://mail.python.org/mailman/listinfo/python-list
Re: Python/UNO/OpenOffice?
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 further than this on Windows (XP Pro, SP 2)? Not me - I'm not using Windows. If anyone knows more about this, please post here or post a comment at http://www.stuvel.eu/archive/31/article-about-openofficeorg-and-python so that I can improve the article. Sybren -- Sybren Stüvel Stüvel IT - http://www.stuvel.eu/ -- http://mail.python.org/mailman/listinfo/python-list
Re: Python/UNO/OpenOffice?
[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 from what has already been said, it might be nice for you to read my article about OOo and Python at http://www.stuvel.eu/ooo-python ;-) Sybren -- Sybren Stüvel Stüvel IT - http://www.stuvel.eu/ -- http://mail.python.org/mailman/listinfo/python-list
Re: for: else: - any practical uses for the else clause?
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 block in stack if block.is_marked()] if all_heights: height = sum(all_heights) else: raise SomeError(No marked block) Alternatively (lower memory usage for large list): all_heights = (block.height for block in stack if block.is_marked()) try: height = all_heights.next() height += sum(all_heights) except StopIteration: raise SomeError(No marked block) I must say that the for/else construct is a LOT more readable than the rewritten alternatives. Sybren -- Sybren Stüvel Stüvel IT - http://www.stuvel.eu/ -- http://mail.python.org/mailman/listinfo/python-list
Re: builtin regular expressions?
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 implicit'. May it be related to this? The creators of Python chose not to include an extention of the Python syntax for regular expressions. It's a lot simpler to have a straight-forward syntax, and simply pass the regular expressions to the appropriate functions. Sybren -- Sybren Stüvel Stüvel IT - http://www.stuvel.eu/ -- http://mail.python.org/mailman/listinfo/python-list
Re: Escapeism
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? print_str( c ) prints representation '\a' to stdout for c = '\a' print_str( c ) prints representation '\n' for c = '\n' ... It is required that not a beep or a linebreak shall be printed. try print repr(c). Sybren -- Sybren Stüvel Stüvel IT - http://www.stuvel.eu/ -- http://mail.python.org/mailman/listinfo/python-list
Re: retry in exception
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/ -- http://mail.python.org/mailman/listinfo/python-list
Re: Making sure script only runs once instance at a time.
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') Checking for a lock, and later acquiring the lock, seems non-atomic to me. It's easier to simply create a lock directory. If it fails, the dir already exists and someone else holds the lock. If it succeeds, the lock is immediately yours, since you just created the directory. This is atomic on most OSses AFAIK. Sybren -- Sybren Stüvel Stüvel IT - http://www.stuvel.eu/ -- http://mail.python.org/mailman/listinfo/python-list
Re: License / Registration key enabled software
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üvel IT - http://www.stuvel.eu/ -- http://mail.python.org/mailman/listinfo/python-list
Re: License / Registration key enabled software
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, so for convenience you want to install it on every PC in the building. Having installed it all over the shop, how can you be sure that only 5 people are using it at any one time? Write the software in such a way that it needs a certificate on a smartcard, then supply the company with five smartcards. Sybren -- Sybren Stüvel Stüvel IT - http://www.stuvel.eu/ -- http://mail.python.org/mailman/listinfo/python-list
Re: License / Registration key enabled software
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 thoroughly monitor them 24/7, violating every privacy law in existance. Sybren -- Sybren Stüvel Stüvel IT - http://www.stuvel.eu/ -- http://mail.python.org/mailman/listinfo/python-list
Re: using the email module
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-Disposition: Attachment header. Check out the accompanying headers as well, by simply emailing yourself an attached HTML file and examining the email source. Sybren -- Sybren Stüvel Stüvel IT - http://www.stuvel.eu/ -- http://mail.python.org/mailman/listinfo/python-list
Re: using the email module
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: QOTW (was Re: does anybody earn a living programming in python?)
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 QOTW? +1 here Sybren -- Sybren Stüvel Stüvel IT - http://www.stuvel.eu/ -- http://mail.python.org/mailman/listinfo/python-list
Re: Extend file type
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 doesn't work. __call__ is used when an instance if MyFile is called as if it were a function: mf = MyFile(blabla) mf() Sybren -- Sybren Stüvel Stüvel IT - http://www.stuvel.eu/ -- http://mail.python.org/mailman/listinfo/python-list
Re: QuoteSQL
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 this in detail, because I think it's a proper way of doing it. Sybren -- Sybren Stüvel Stüvel IT - http://www.stuvel.eu/ -- http://mail.python.org/mailman/listinfo/python-list
Re: concat next line with previous
[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: where are isinstance types documented?
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'. That is because 'string' is not a class: print abc.__class__.__name__ The name is 'str', not 'string'. Sybren -- Sybren Stüvel Stüvel IT - http://www.stuvel.eu/ -- http://mail.python.org/mailman/listinfo/python-list
Re: QuoteSQL
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 wildcard strings for a query using LIKE etc. 2) Quoting of values for putting into queries. You only need the first one, since every database interface that follows PEP 249. I guess I don't have a strong preference for which way we do it, but I would suggest confining our discussion to non-stupid solutions. Good suggestion. I'd say, write a function that escapes for use in LIKE queries, and leave the other quoting to the database interface. Sybren -- Sybren Stüvel Stüvel IT - http://www.stuvel.eu/ -- http://mail.python.org/mailman/listinfo/python-list
Re: QuoteSQL
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 PostgreSQL you can use any escape character for the pattern, check out http://www.postgresql.org/docs/8.0/interactive/functions-matching.html Sybren -- Sybren Stüvel Stüvel IT - http://www.stuvel.eu/ -- http://mail.python.org/mailman/listinfo/python-list
Re: does anybody earn a living programming in python?
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 -- Sybren Stüvel Stüvel IT - http://www.stuvel.eu/ -- http://mail.python.org/mailman/listinfo/python-list
Re: QuoteSQL
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) % ','.join('%s' for i in t), t) Sybren -- Sybren Stüvel Stüvel IT - http://www.stuvel.eu/ -- http://mail.python.org/mailman/listinfo/python-list
Re: QuoteSQL
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 followups) I didn't care anything about all that. I just found the way I wrote it somewhat easier to read, that's all. Sybren -- Sybren Stüvel Stüvel IT - http://www.stuvel.eu/ -- http://mail.python.org/mailman/listinfo/python-list
Re: Talking to marketing people about Python
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 asked for permission to distribute the Python binding, and after a few weeks of winding its way through the corporate bureaucracy I got an email from a product manager who wants to meet with me to understand the market demand for Python API before we commercialize it. 1) The customer wants it already. 2) The language is good enough for NASA and Google. Sybren -- Sybren Stüvel Stüvel IT - http://www.stuvel.eu/ -- http://mail.python.org/mailman/listinfo/python-list
Re: QuoteSQL
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 ?, '%' + name + '%' ) Sybren -- Sybren Stüvel Stüvel IT - http://www.stuvel.eu/ -- http://mail.python.org/mailman/listinfo/python-list
Re: QuoteSQL
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: curs.execute( select * from details where person_name like ?, ('%' + name + '%', ) ) Including all sorts of quotes, newlines, backslashes etc. in the name. Sybren -- Sybren Stüvel Stüvel IT - http://www.stuvel.eu/ -- http://mail.python.org/mailman/listinfo/python-list
Re: QuoteSQL
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 certainly not an argument for his proposed QuoteSQL. Indeed. An escaping function should be small and not do all kinds of escaping for different situations at once. Sybren -- Sybren Stüvel Stüvel IT - http://www.stuvel.eu/ -- http://mail.python.org/mailman/listinfo/python-list
Re: QuoteSQL
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üvel IT - http://www.stuvel.eu/ -- http://mail.python.org/mailman/listinfo/python-list
Re: R.S.I. solutions?
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 learn juggling! Get three balls, search Google Video for some juggling lessons, and get going. It's great fun, and a good way to exercise your upper body. Sybren -- Sybren Stüvel Stüvel IT - http://www.stuvel.eu/ -- http://mail.python.org/mailman/listinfo/python-list
Re: QuoteSQL
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.python.org/mailman/listinfo/python-list
Re: License / Registration key enabled software
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 protect your software, turn it into a web application/service. Sybren -- Sybren Stüvel Stüvel IT - http://www.stuvel.eu/ -- http://mail.python.org/mailman/listinfo/python-list
Re: Automatic import PEP
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 idea. I have also found autoimp useful in writing normal Python applications; one can use from autoimp import * at the top of a Python source file and thus have all Python modules available to that source file That sounds like a source of new bugs to me. Besides that, you have no overview at all of which modules are used by the program. It also prevents automated checking of that using pylint and friends. Sybren -- Sybren Stüvel Stüvel IT - http://www.stuvel.eu/ -- http://mail.python.org/mailman/listinfo/python-list
Re: QuoteSQL
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.stuvel.eu/ -- http://mail.python.org/mailman/listinfo/python-list
Re: Request for tips on my first python script.
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 cases it turns out to be the same directory, but it adds more flexibility. If someone wants your app to read/write to another directory, he/she can simply change the HOME environment variable. # user configurable #maxChecksPerDay = 8 #maxChecksPerDay = 12 maxChecksPerDay = 24 myTemp = '/tmp' #podDir = os.path.join(HOME, 'Audio/Podcasts') podDir = os.path.join(HOME, 'Podcasts') # end user configurable A bit of nitpicking: place a blank line between the user configurable part and the rest of the code. def exitFunc(): #f.close() #log.close() if boz: print boz Write function comments! Use the docstring to describe your function - what does it do, and what does it return? Do this for all functions you write. # render is used because feeds use a lot of html, not just plain text. def render(html): if html: html = re.sub('', '\\', html.encode('utf8')) Use a raw string for the second argument to make it more readable: html = re.sub('', r'\', html.encode('utf8')) command = 'echo ' + html + ' | lynx -dump -stdin -force_html' os.system(command) Use the subprocess module or the popen2 module to open lynx. That way, you can feed the HTML to lynx directly, and you're not bound to the maximum line length of the shell. It also removes the need to escape quotes. def updateCache(feeds): l = [] Use longer names than 'l'. print updating local xml cache... for feed in file(feeds, r).read().split('\n'): if not re.match('^http://', feed): # feedList ignores # anything but urls Here you say you only match URLs starting with http://;, but at the start you claimed to only use URLs starting with http. Be sure to keep your documentation and your code in sync. def htmlTitle(mainTitle, subTitle): s = 'HR' s += 'H2' + mainTitle + '/H2' s += 'H3' + subTitle + '/H3' return s It might be easier on the eyes if you use: s = 'hrh2%s/h2h3%s/h3' % (mainTitle, subTitle) It might also be wise to use lower-case HTML tags to remain compatible with XHTML. def downloadPod(url, dest): kb = 2 success = 0 command = 'wget --continue -O ' + dest + ' ' + url + '' status = os.system(command) Here you pass the arguments of the function to a system call. This means that before the downloadPod function is called, the 'url' and 'dest' should have been escaped or cleared of unwanted characters. This should really be documented. Overall, your code needs to be commented and documented much better. Think of other people reading the code, and explain _why_ you do something, instead of explaining _what_ you're doing. Sybren -- Sybren Stüvel Stüvel IT - http://www.stuvel.eu/ -- http://mail.python.org/mailman/listinfo/python-list
Re: sending emails using python
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 the message. You need \r\n\r\n there. Line-ends in email messages should be DOS line-ends. Traceback (most recent call last): File C:\sridhar\Beginning_Python\Beginning_Python\Chapter16\tryitout\InitialMailExample.py, line 5, in ? server = smtplib.SMTP(hstmsg002,25) File C:\Python24\lib\smtplib.py, line 244, in __init__ (code, msg) = self.connect(host, port) File C:\Python24\lib\smtplib.py, line 307, in connect (code, msg) = self.getreply() File C:\Python24\lib\smtplib.py, line 351, in getreply raise SMTPServerDisconnected(Connection unexpectedly closed) SMTPServerDisconnected: Connection unexpectedly closed Well that's useless. You could install a network sniffer (http://www.ethereal.com/) and find out what's actually sent over the network connection, and where things go wrong. Sybren -- Sybren Stüvel Stüvel IT - http://www.stuvel.eu/ -- http://mail.python.org/mailman/listinfo/python-list
Re: sending emails using python
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, wonderful. Useless it might be, but it's a lot more clueful than some questions we see, so it seems a little dismissive just to say it's useless - the OP has provided the traceback, which is so often missing in questions from newbies, and has correctly localized the error to a small chunk of code. I agree with you. My remark might indeed have sounded harsher than intended. It referred to the traceback itself, not the posting of the traceback. That was rather useful. Ethereal trace will provide little more data than the traceback. I don't know until I see it. Perhaps the socket is closed in response to something the client sends. That can be seen in the Ethereal trace. I suppose it'll tell you whether the server is sending RST or FIN to terminate the connection, but it won't give much insight into why. A quick peek in the SMTP logfiles should tell you that. Perhaps the SMTP server is strapped down to accepting connections from specific IP addresses by some firewall? In that case I'd expect the SMTP server to simply ignore the connection attempt and cause a timeout in the connecting phase. I wouldn't expect a connection to be created and then closed again, which is what I read in the posted traceback. It would probably be a good idea to have a chat with the server's administrator to see if they can suggest what might be going wrong. Good idea indeed. Another idea would be to use something like netcat or telnet to connect to the port and see what happens if you manually type an SMTP connection. Sybren -- Sybren Stüvel Stüvel IT - http://www.stuvel.eu/ -- http://mail.python.org/mailman/listinfo/python-list
Re: sending emails using python
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: How to build extensions on Windows?
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 comes with that, and use gcc just like you're used to. Works like a charm, but the compiled extension is incompatible with the regular Windows Pythons from python.org and ActiveState. Sybren -- Sybren Stüvel Stüvel IT - http://www.stuvel.eu/ -- http://mail.python.org/mailman/listinfo/python-list
Re: [Article] OpenOffice.org and Python
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 question, it doesn't make much sense to me. - when I drive OOo from Python, via COM/Ole-automation, many things not run (getStruct...); no solution? I don't know, I don't use Windows. You also describe a method that wasn't used in my article. Perhaps it would be better if you did use the methods I describe. Sybren -- Sybren Stüvel Stüvel IT - http://www.stuvel.eu/ -- http://mail.python.org/mailman/listinfo/python-list
Re: OpenOffice.org and Python
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 platform such as Windoze are limitated to Python 2.3 when working with OpenOffice and compiling is a pain especially under Windoze. Poor people. If there is anything in my code that doesn't work with Python 2.3, or with your system in general, please let me know what code that is, and how to fix it. I'll implement the changes into the article. Sybren -- Sybren Stüvel Stüvel IT - http://www.stuvel.eu/ -- http://mail.python.org/mailman/listinfo/python-list
[Article] OpenOffice.org and Python
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 data * Converting from/to Excel or to PDF * Processing all files in a directory * Automatically starting OOo * More information Please post feedback here or on my website at http://www.stuvel.eu/archive/31 Enjoy the article at http://www.stuvel.eu/ooo-python Sybren -- Sybren Stüvel Stüvel IT - http://www.stuvel.eu/ -- http://mail.python.org/mailman/listinfo/python-list
Re: [ANN] IronPython 1.0 released today!
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 our users, IronPython would be a much weaker project. I hope they take your example to heart and start releasing more Open Source code. Sybren -- Sybren Stüvel Stüvel IT - http://www.stuvel.eu/ -- http://mail.python.org/mailman/listinfo/python-list
Re: Exception EOFError.
Dennis Lee Bieber enlightened us with: The above is windows, I believe Linux uses ctrl-d instead of ctrl-z 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: threading support in python
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 behind in threading What's wrong with the current threading? AFAIK it's directly linked to the threading of the underlying platform. 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
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 currently opened spreadsheet, so you can just as well open an Excel sheet in OpenOffice.org and get the data from that. http://www.stuvel.eu/archive/28/getting-data-from-an-openofficeorg-spreadsheet Saving the currently opened OpenOffice.org spreadsheet to an Excel sheet with just a few lines of Python code. There are still people that favour MS Office and request Excel output from software. This is easily done with OpenOffice.org and Python: http://www.stuvel.eu/archive/29/ooo-spreadsheet-to-excel-with-python 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
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. Combined with the glob module, this could automatically handle all files in a certain directory. With the 2nd example (alf's question: copy OOo Calc file to Excel xls file), I don't see any advantage at all over the manual procedure (1) start OOo Calc (2) open Calc file (3) File Save As select Microsoft Excel 97 etc format ... what am I missing? Your solution requires (1) edit script to change name of output file; save script (where?) (2) start OOo Calc with magic-spell on the command line (3) open calc file (4) run script. It's just a demonstration of the file saving process. Indeed, the saving not all that useful, but someone requested it and I wrote it. How does one write a script that can be in control e.g. script starts OOo (if necessary), That's easily done with a system call or the subprocess or popen2 modules. and extracts some data from all spreadsheet files in a given directory (while one is at lunch)? Just add a few lines to load the file instead of picking the currently opened one. Do you want me to do more digging and extend the code? I'm willing to do that, but only if it makes you happy :) 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
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 same response, except that I had the gut feeling that in the end things were going to be easy ;-) I don't want you to do anything. However the interests of evangelising/spreading the use of OOo software might be advanced were you to go the extra step or two and post a recipe for simple data extraction from a named file, rather than the currently open file. Add a few hints like what are the types of the data that you get back (especially how dates are distinguished from numbers, if at all) and you'll be a hero :-) Sounds very tempting. I'll see what I can come up with, and write a proper article on my website. Don't count on it being finished soon, though, because this week is going to be very busy for me, and after that I'll be on a two-week holiday. Sybren -- Sybren Stüvel Stüvel IT - http://www.stuvel.eu/ -- http://mail.python.org/mailman/listinfo/python-list
Re: C# equivalent to range()
Erik Max Francis enlightened us with: The other zilion persons who were not interested (other than the four I mentioned above) silently and peacefully ignored the question on went on with their happy lifes. That's because many of them have killfiled you. I can say that I didn't killfile him. I just peacefully ignored the question and went on with my happy life - I simply don't know anything about C#. Sybren -- The problem with the world is stupidity. Not saying there should be a capital punishment for stupidity, but why don't we just take the safety labels off of everything and let the problem solve itself? Frank Zappa -- http://mail.python.org/mailman/listinfo/python-list
Re: Max function question: How do I return the index of the maximum value of a list?
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 - there might be multiple maximum values. What would you expect in such a case? 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: Best way to do data source abstraction
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 absorb classFood into to based on the extension of the input file received by classA. But this doesn't seem possible. You don't explain the most important part - absorb. What does that mean? And what does it mean to have classA almost as your main class? 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: An algorithm problem
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 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: Best Python Editor
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, 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: shuffling elements of a list
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 numbers. This is often done in database queries that need to randomize the data ;-) 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: generating random passwords ... for a csv file with user details
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 amount of entropy, and can also generate different types (alpha/digit, hex, easy to read alpha/digit, etc.) 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: XML/HTML Encoding problem
Dale Strickland-Clark enlightened us with: So it encodes the entity reference to ⬠(Euro sign).  I need it to remain as #8364; 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 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: Python - Web Display Technology
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 99.9% of the Flash usage is done badly. Google Video is a nice example of more or less good Flash usage, although it's a shame they say Download for Windows/Mac instead of Download as AVI - but that's got nothing to do with Flash ;-) Such situations always make me suspicious Ludditism is at work. If you suspect that, you didn't understand a single thing about the usability drawbacks I told you about. Not being able to use a scrollwheel, loss of the backbutton-functionality, and fonts that don't scale along with the browser's font, are all too common practice with Flash websites. I love new technology, as long as it's good technology. I've had my mouse with tiltwheel for a short time, and I'm completely hooked to the new functionality. 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: Python - Web Display Technology
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 Flash, HTML/JS or whatever, breaks the back button. No it doesn't. If something is interactive and lets the user go somewhere by performing an action, they expect to be able to go back using the back button. People want to be in control over their computer, their time, and their attention. If they aren't, they go away. Fonts are problematic in Flash, this is a weakness of Flash. Scaling Fonts is even more problematic, but, fonts are an issue in any precise design on the web. Websites shouldn't be designed to be pixel-perfect. They should be designed to scale and stretch, and to accommodate a user's wishes. If you want something exactly like you envision it, go direct a movie. I wouldn't argue Flash is better for text sites at the moment, due to Search Engine shortcomings. And due to being incompatible with the browser's own search functionality. As for the blind issue,that makes no sense to me. Is the suggestion that we should give up using images in web sites since some people can't see them. Might as well throw out the use of the img tag while we are at it? Go and read some usability studies, and get acquainted with the HTML standards, before commenting on them. The 'alt' attribute is mandatory, and should describe the image for those who can only interpret text. 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: Python - Web Display Technology
[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 cross-browser, cross/platform That's where you are wrong. Flash on Mac/MSIE behaves differently than other platform/browser combinations. There are also many browsers and platforms that can't use Flash. Even though Flash is available for Linux, it isn't available for my Zaurus, for instance. -- and most features cannot be disabled by the user. (compare that to a user being able to turn off JS, or Java -- something often mandated in a corporate environment.) It's either all on or all off. And in many corporate environments, it's off. Flash has such a large install base, that it could be argued it is the most widely available platform for delivering media-rich applications over the web. True, but 99.9% of all Flash usage is more an annoyance than truely useful and rich. (And code does not involve anywhere near the same level of attention to kludges and workarounds that one would have to use to replicate similar feature -- where possible -- in different browsers and browser *versions.*) -- ActionScript is a horrible klidge it itself. Don't try to portrait it as something else. Not to sound like I work for MM/Adobe, but, here's what the Flash Player can do at *run time*: When should it do that if not at run time? At compile time? Flash can render text -- w/ custom-defined and packaged fonts. (not possible in a browser!) It can apply a limited set of CSS to the rendered text, BTW. But when using my scrollwheel to scroll the page it is used on, my browser stops scrolling when the mouse is over such a flash file. Very annoying! Flash can load/parse/serialize/send XML. So can JavaScript. Flash can POST and GET a variety of data (true, it may access browser controls to manage this.) So can HTML. Flash can access you webcam, allowing you to create your own video chat/IM app. So can NetMeeting and many others. Flash can load and render jpegs, gifs(v8), and pngs(v8) -- and in version 8, composite all that w/ vector graphics (+video?) -- *and,* sample the resulting display pixel by pixel. (passing that data back to a server would allow dynamic creation of a jpeg or gif.) But version 8 is not even available for Linux. Flash 8 has a new file upload ability that goes beyond what a browser is capable of: You can *multi-select* files, filter files by type or size, and have programatic access to the state of the upload. It accesses an Operating System GUI control to do this -- and I have tested that these features work in MSIE, Moz FF, and Safari on OSX. *** But version 8 is not even available for Linux. Flash can #animate# stuff!!! So can GIF and MNG. Flash is like a 2 MB download that works in almost *every* browser out there. Not on Linux/x86, nor Liinux/ARM, nor Linux/MIPS, (like: a built-in interpreter for a late-version-EcmaScript-compliant scripting language -- that, in many ways, is far more capable than what is available w/ JavaScript in most browsers!) But it is horrible to work with. I can know, I've had to develop quite a few advanced Flash websites for my work. My work even went to the high folks at Disney. I don't need to brag, but apparently I do need to show you I *do* know what I'm talking about. *** This feature can be used for a web-based CMS! It would blow-away anything (non-Java) now available for managing and uploading assets. LOL I can write an application that runs circles around Flash. And it would have the advantage it isn't web-based either - yes, I see that as an advantage. Web-based is overrated. I ask of you to take a look at the serious issues many people have with Flash. It's not just geeks and nerds that are annoyed by non-functioning scrollwheels, badly designed GUIs, and badly searchable websites. People that are less familiar with the web are even more annoyed, but are less capable of expressing that in a structured and well-defined way, because they simply lack the jargon. 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: Tabs are *MISUNDERSTOOD*, *EVIL* AND *STUPID*, end of discussion. (Re: Tabs versus Spaces in Source Code)
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 you don't want to either have to reformat it or to switch your editor settings for some files. If I grab a module, I just leave the module as is. If I grab a code snippet, I always reformat it to my own style. That's very easy using VIM's retab command. Do you know of any open-source projects which actually try to enforce a 'tab only' convention for Python? My software is, although I'm still the only one working on them ;-) 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: Opensource vs Microsoft, Wat do you think about opensource?
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 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: Newbie append() question
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 be fine. c = raw_input(Enter class name) if (c != D): Here there is also no need for parentheses. 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: How to append to a dictionary
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 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: Newbie append() question
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 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: Python - Web Display Technology
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 greatest Macromedia Flash plugin; that's version 8, while the latest version for Linux is version 7. I doubt that the Free implementations are up to par with a version that hasn't even been released by Macromedia. 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: FAQ for XML with Python
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, including links to pages where the reader can learn about them if it's not the case. 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: Python - Web Display Technology
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 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: Python - Web Display Technology
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 anymore, which is a major usability issue. - In the above case, bookmarking a page doesn't work either. - You need an extra plugin. Even though it's available for the major OSses and hardware systems, it's not available for every platform that can run a browser. - The plugin is closed-source. - The format that is the source for the SWF files is a closed, proprietary format. - Many user-interface widgets are generally badly implemented in Flash. For instance, on many scrolling thingies, the scrollwheel doesn't work. Or, the regular scrollwheel works, but for scrolling horizontally the tilt wheel isn't supported. Another example: sometimes it's only clear what a link points to when you hover over it (revealing a text behind an image, for instance), which is impossible on some devices (think handhelds with a touch-screen). - Search engines don't understand Flash movies. They are also unable to link directly to relevant pages. - Many more reasons... It seems most Python applications choose HTML/CSS/JS as the display technology, yet Flash is a far more powerful and elegant display technology. Flash is indeed more powerful, but not elegant at all. On the other hand, HTML/JS seems clunky and antiquated. It's getting a lot better. Try using XHTML 1.1 and only up to date, platform/browser-independent JavaScript, it'll be much better. I am a gardener, and not a coder by trade, but Flash seems to integrate just fine with Python. It's absolute crap when it comes to coding. ActionScript stands almost perpendicular to Python when it comes to the Python way of thinking. In ActionScript there are many ways of doing the same thing, none of which are obvious. Another thing is that when you call a function that doesn't exist, that call is silently ignored. The same holds for getting the value of a non-existing variable. This makes debugging very difficult. http://SamFeltus.com Your site looks quite unstyled without flash... And I don't have Flash player 8... 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: Python - Web Display Technology
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 their rear ends and bring some decent cross platform graphics capabilities to the web one decade? Perhaps you can get Mickeysoft to get SVG support in their browser. WC3 at Work - Beware Falling Luddites MSIE doesn't even properly support PNG files (at least last time I looked), so you should start blaming the people that actually don't implement all the goodies that are already there. 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: SPE output
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 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: Tabs versus Spaces in Source Code
Duncan Booth enlightened us with: In particular a common convention is to have indentations at 4 spaces and tabs expanding to 8 spaces. Aaaw that is SO ugly! Sure, it displays correctly on systems that have tab stops every 8 spaces given a monospaced font, but that is about all that is positive about that. 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: Tabs versus Spaces in Source Code
Duncan Booth enlightened us with: It is strange. You use many of the same words as me, but they don't make any sense. You forgot to add to me to the end of that sentence. Personally, Achates' words made perfect sense to me. The point is about separating the presentation of the source file from the semantic content. When displaying the file you can choose to expand tabs to any suitable positions. These may be evenly spaced every n characters, or may vary across the page. True. However the important thing is that a tab does not map to a single indentation level in Python: it can map to any number of indents, True, but doesn't the same hold for spaces? An indent level can be made from any number of spaces. You could use two spaces to indent a class' contents, four for functions, and two again for loops. and unless I know the convention you are using to display the tabs I cannot know how many indents are equivalent to a tabstop. That is only true if you mix spaces and tabs. If you use only tabs OR only spaces to indent, everything is perfectly clear. Seriously people, this is about separating the content of a source file from how it is displayed. It's about letting people work together while also allowing them to have control over their own environments, something which is and always has been central to the hacker ethos. Precisely. Using spaces everywhere allows this No it doesn't! I have tabstops every four characters, which is a pleasant indent level for me. Other people have trouble reading the code that way, and want two or eight character wide indents. When using tabs, everybody can place the tabstops for themselves, and as long as tabstop N is more to the left than tabstop N+1, everything is fine. By using spaces, the writer of the code determines the size of the indentation, not the viewer. Since code is generally read more than it is written, the viewer is quite important. 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: Tabs versus Spaces in Source Code
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 trick. I just type 'retab' in my editor, and everything is fine. I use VIM, which is great for tab/space management. 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: Tabs are EVIL *and* STUPID, end of discussion. (Re: Tabs versus Spaces in Source Code)
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) ??!? To separate layout (how much indentation is used) from semantics (how many intentation levels). Tab characters are EVIL *AND* STUPID. And someone who needs to resort to all-caps words (which many consider shouting) needs to relax and use proper arguments. 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: Tabs are EVIL *and* STUPID, end of discussion. (Re: Tabs versus Spaces in Source Code)
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 using smart viewers/editors? I think the majority is viewed using the latter. 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