Re: Parrot Project for Python
See http://pirate.tangentcode.com/ - Swaroop -- http://mail.python.org/mailman/listinfo/python-list
Re: How to set program name in Python? ($0 in Perl)
Thanks Fredrik for the info. It was not a must-have, I was just curious if it was possible. Thanks, Swaroop www.SwaroopCH.info -- http://mail.python.org/mailman/listinfo/python-list
Re: How to access database?
Florian Lindner wrote: Hello, AFAIK python has a generic API for database access which adapters are supposed to implement. How can I found API documentation on the API? I found these pages useful when learning the DB API: * http://www.kitebird.com/articles/pydbapi.html * http://www.amk.ca/python/writing/DB-API.html HTH, -- Swaroop C H Blog: http://www.swaroopch.info/ -- http://mail.python.org/mailman/listinfo/python-list
Re: How to input one char at a time from stdin?
On Tue, 25 Jan 2005 12:38:13 -0700, Brent W. Hughes <[EMAIL PROTECTED]> wrote: > I'd like to get a character from stdin, perform some action, get another > character, etc. If I just use stdin.read(1), it waits until I finish typing > a whole line before I can get the first character. How do I deal with this? This is exactly what you need: http://aspn.activestate.com/ASPN/Cookbook/Python/Recipe/134892 Title: "getch()-like unbuffered character reading from stdin on both Windows and Unix" This recipe was a lifesaver for me once :-) Regards, -- Swaroop C H Blog: http://www.swaroopch.info Book: http://www.byteofpython.info -- http://mail.python.org/mailman/listinfo/python-list
Re: MySQLdb
On Tue, 25 Jan 2005 20:43:54 +, Daniel Bowett <[EMAIL PROTECTED]> wrote: > I have just started playing around with MySQLdb for a project I am planning. > > As a test I have written a script that executes 3000 insert statements > on a table. The table contains 10 fields with a mix of text and numbers > - its a product table for a website eg UPC, ProductName, Price etc. > > The problem I have is that it takes just over two minuted to execute the > 3000 insert statements which seems really slow! I am running it on a > machine with a 1.5 Ghz Pentium M Processor and Gig Of Ram. I dont think > the machine is to blame for the speed because during execution the > processor sits at about 10% and there is loads of free RAM. I think a better option is to have the rows in a text file and then use `mysqlimport` or 'load data infile' SQL[1] [1]: http://dev.mysql.com/doc/mysql/en/load-data.html -- Swaroop C H Blog: http://www.swaroopch.info Book: http://www.byteofpython.info -- http://mail.python.org/mailman/listinfo/python-list
Re: MySQLdb
> >I think a better option is to have the rows in a text file and then > >use `mysqlimport` or 'load data infile' SQL[1] > > > >[1]: http://dev.mysql.com/doc/mysql/en/load-data.html > > > I remember using that a while ago when I dabbled with mysql so I think > thats a potential solution. With my current solution I get full error > logging with each row i try to insert. Will mysqlimport fail completeley > if one row fails? I've not yet encountered an error using mysqlimport. But the docs at that link say that it might fail completely depending on the type of error. Excerpt: " If you specify IGNORE, input rows that duplicate an existing row on a unique key value are skipped. If you don't specify either option, the behavior depends on whether or not the LOCAL keyword is specified. Without LOCAL, an error occurs when a duplicate key value is found, and the rest of the text file is ignored. With LOCAL, the default behavior is the same as if IGNORE is specified; this is because the server has no way to stop transmission of the file in the middle of the operation. " P.S. Its best to take this discussion off the list since its not directly related to Python. -- Swaroop C H Blog: http://www.swaroopch.info Book: http://www.byteofpython.info -- http://mail.python.org/mailman/listinfo/python-list
Re: Hello
> Most ISPs provide > news servers, often at 'news.ispname.net' if the ISP is 'ispname.net'. > You need to get the correct details of which news server to use from > your ISP and configure your newsreader to use that. Once your newsread > is talking correctly to your ISP's news server, *then* you can subscribe > to comp.lang.python. If you can't find a Usenet server, try news.gmane.org -- Swaroop C H Blog: http://www.swaroopch.info Book: http://www.byteofpython.info -- http://mail.python.org/mailman/listinfo/python-list
Re: Execute a list
Groleo Marius wrote: How can i execute a string in python? How can I execute the code that "s" keeps inside, considering that the code is correct? Use the exec statement : `exec s` Details at http://www.python.org/doc/ref/exec.html Regards, -- Swaroop C H Blog: http://www.swaroopch.info Book: http://www.byteofpython.info -- http://mail.python.org/mailman/listinfo/python-list
Re: Hey, How Do I Distribute my New Completed Python Project?
[EMAIL PROTECTED] wrote: I'v just completed a small python project, which includes a main py file and a couple of classes in seperated py files. I can run it under the development directory, but how to distribute them? Is there any good practice here? "Distributing Python Modules" http://docs.python.org/dist/dist.html Excerpt: " This document describes the Python Distribution Utilities ('Distutils') from the module developer's point of view, describing how to use the Distutils to make Python modules and extensions easily available to a wider audience with very little overhead for build/release/install mechanics." Regards, -- Swaroop C H Blog: http://www.swaroopch.info Book: http://www.byteofpython.info -- http://mail.python.org/mailman/listinfo/python-list
RE: urllib (and urllib2) read all data from page on open()?
--- Alex Stapleton <[EMAIL PROTECTED]> wrote: > Except wouldn't it of already read the entire file when it opened, > or does it occour on the first read()? Also will the data returned > from handle.read(100) be raw HTTP? In which case what if the > encoding is chunked or gzipped? Maybe the httplib module can help you. >From http://docs.python.org/lib/httplib-examples.html : >>> import httplib >>> conn = httplib.HTTPConnection("www.python.org") >>> conn.request("GET", "/index.html") >>> r1 = conn.getresponse() >>> print r1.status, r1.reason 200 OK >>> data1 = r1.read() >>> conn.request("GET", "/parrot.spam") >>> r2 = conn.getresponse() >>> print r2.status, r2.reason 404 Not Found >>> data2 = r2.read() >>> conn.close() As far as I can understand, you can read() data only when you want to. Caveat: There's a warning that says "This module defines classes which implement the client side of the HTTP and HTTPS protocols. It is normally not used directly -- the module urllib uses it to handle URLs that use HTTP and HTTPS." HTH, Swaroop C H Blog: http://www.swaroopch.info Book: http://www.byteofpython.info -- http://mail.python.org/mailman/listinfo/python-list
Re: yum repository
--- "Donald L. Dietmeyer" <[EMAIL PROTECTED]> wrote: > What yum repository do you use to pick up > python rpms? Search for 'Yum' at: http://www.python.org/2.4/rpms.html Cheers, Swaroop C H Blog: http://www.swaroopch.info Book: http://www.byteofpython.info -- http://mail.python.org/mailman/listinfo/python-list
Re: Python info
--- Dave Zhu <[EMAIL PROTECTED]> wrote: > I would like to have a broad knowledge on Python. > Basically, I would like to know Python is designed, > how parsing, compilation, and interpretation take > place, how memory management works, how the Python > interpreter performs compared to others, etc. I > already looked at Python's documentation, but couldn't > find any detailed information. Any references would be > appreciated. Thank you for your help. There is a whole wiki dedicated to Python internals: http://wiki.cs.uiuc.edu/cs427/PYTHON However, I don't know how up-to-date the information is. HTH, Swaroop C H Blog: http://www.swaroopch.info Book: http://www.byteofpython.info -- http://mail.python.org/mailman/listinfo/python-list
Re: variable arguments question
--- vegetax <[EMAIL PROTECTED]> wrote: > how can i pass it to a generic function that takes variable > keywords as > arguments? same thing with variable arguments, i need to pass a > list of > arguments to the function > > def asd(**kw): print kw > def efg(*arg): print arg > > asd(d) > doesnt work > asd(kw = d) > doesnt work You need to use it as follows: >>> def foo(**args): ... '''Takes in key=value parameters.''' ... for key, value in args.items(): ... print key, '->', value ... >>> foo(a=1,b=2) a -> 1 b -> 2 Hope this makes some sense, Swaroop C H Blog: http://www.swaroopch.info Book: http://www.byteofpython.info -- http://mail.python.org/mailman/listinfo/python-list
Re: python version anachronism
--- Xah Lee <[EMAIL PROTECTED]> wrote: > so, python 2.3.5 is released about 2 months later than 2.4?? As far as I understand, 2.3.5 is a maintenance release in the 2.3 branch. It is independent of the 2.4 branch. Swaroop C H Blog: http://www.swaroopch.info Book: http://www.byteofpython.info -- http://mail.python.org/mailman/listinfo/python-list
Re: Database connection caching
On 18 Mar 2005 04:52:03 -0800, [EMAIL PROTECTED] <[EMAIL PROTECTED]> wrote: > Hi all, > > is there an alternative way of: > > - create a connection object > - open the connection > - close the connection > > every time one has to run a query. Why not use cursor objects with a single connection object? You can have any number of cursor objects and can run with a single connection object A good introduction is at http://www.amk.ca/python/writing/DB-API.html Regards, -- Swaroop C H Blog: http://www.swaroopch.info Book: http://www.byteofpython.info -- http://mail.python.org/mailman/listinfo/python-list
Re: Is Python like VB?
On Fri, 18 Mar 2005 07:40:54 -0700, at lycos.com"@bag.python.org Jim Smith <"jbzsmith> wrote: > Mike Cox wrote: > > Would Python meet our requirements? I need to make lots of > > GUI applications (message boxes, forms, etc.) and do the underlying business > > logic too. > > Python is my favorite language and I recommend that you experiment with > it. However, if you want the quickest replacement for VB I would look > at REALbasic. It has a nice IDE with an integrated GUI designer and it > is generally easy for a VBer to learn. You can even convert existing VB > apps as well. It won a Jolt Productivity award this year (along with > Python 2.4). I have heard Gambas to be a very good option too: http://gambas.sourceforge.net/ -- Swaroop C H Blog: http://www.swaroopch.info Book: http://www.byteofpython.info -- http://mail.python.org/mailman/listinfo/python-list
Re: syntax incorrect with regex
On Fri, 18 Mar 2005 21:57:15 +0800, sam <[EMAIL PROTECTED]> wrote: > Hi, > > What is the correct syntax of declaring a regex syntax in Python 2.3? > I got the following error: > > # python2.3 test.py >File "test.py", line 10 > macros_parser = re.compile (r""" (\s+)=\"(\s+)\"$ """,re.VERBOS) > ^ > SyntaxError: invalid syntax Please check the indentation you have used. Also, it should be re.VERBOSE (note the ending 'e') Regards, -- Swaroop C H Blog: http://www.swaroopch.info Book: http://www.byteofpython.info -- http://mail.python.org/mailman/listinfo/python-list
Re: Simple XML-to-Python conversion
On 18 Mar 2005 20:24:56 -0800, [EMAIL PROTECTED] <[EMAIL PROTECTED]> wrote: > >From what I understand, this is how XML was standardized, in a sort of > hierarchical structure of infinite possibilities. The problem I'm > having with these structures is that I need to actively search through > each level for the item I want. All I really want to do is access one > or more elements at the same time and know where they are without > searching. > > What I'm looking to use are basic structures such as: > root.path > root.input.method > root.input.filename > root.output.filename You should be using XPath (4suite has it) to get the parts that you want. A really quick intro is at http://simon.incutio.com/archive/2003/10/21/xpathRocks Regards, -- Swaroop C H Blog: http://www.swaroopch.info Book: http://www.byteofpython.info -- http://mail.python.org/mailman/listinfo/python-list
Re: survey of modules to be added to stdlib
On Sat, 19 Mar 2005 03:40:31 GMT, Ron <[EMAIL PROTECTED]> wrote: > I would prefer to have a install utility included that retrieves a > list of modules we can install, update, or uninstall, from the web in > a consistent easy way. It would really be nice if they listed what > modules they were dependant on also. > > If the updater listed them by who distributes and maintains them, it > could include many third party modules as well and not need to include > them in the standard library. Using the PyPI and distutils, the BangPypers (Bangalore Pythonistas) intend to work on the same kind of project along with ChiPy (Chicago Pythonistas) and of course, the distutils-sig and catalog-sig. For details, please see http://www.swaroopch.info/archives/2005/03/13/uraga-the-cpan-for-python/ We welcome you to help us in this endeavour. Regards, -- Swaroop C H Blog: http://www.swaroopch.info Book: http://www.byteofpython.info -- http://mail.python.org/mailman/listinfo/python-list
Re: wxPython vs. pyQt
On Sat, 19 Mar 2005 15:55:23 +1100, Mike P. <[EMAIL PROTECTED]> wrote: > Personally for ease of use Qt is the way to go. I'm really looking forward > to Qt 4 coming out, and then sometime later PyQt 4. Then I'll be able to > develop with my favourite APIs (Qt, OpenGL, and OpenSceneGraph) under a > completely Python environment - heaven from a development perspective. I totally agree. For those who don't know, Qt 4 on Windows will be available under GPL. So, you can write a (GPLed) app using Qt 4 and run it on Windows, Mac, Linux and even embedded! The announcement is at http://www.trolltech.com/newsroom/announcements/0192.html I hope the PyQt guys are on top of this ;) Regards, -- Swaroop C H Blog: http://www.swaroopch.info Book: http://www.byteofpython.info -- http://mail.python.org/mailman/listinfo/python-list
Re: simultaneous copy to multiple media
On Sun, 20 Mar 2005 11:41:10 -, Claudio Grondi <[EMAIL PROTECTED]> wrote: > I would like to save time copying the same file > (>6 GByte) to various different target storage > media connected to the system via USB. > > Is there a (Python or other) tool able to help me > to do this, so that I don't need to copy the > source file first to the first media, then to the > second, etc.? If you are using *nix, maybe you can use the `tee` command[1] and redirect the file to different places. For example, cat | tee file1 | tee file2 > file3 I haven't tried it out but it should work. [1]: http://unixhelp.ed.ac.uk/CGI/man-cgi?tee HTH, -- Swaroop C H Blog: http://www.swaroopch.info Book: http://www.byteofpython.info -- http://mail.python.org/mailman/listinfo/python-list
Re: How to pass parameter when importing a module?
On Sun, 20 Mar 2005 10:18:14 -0600, Bo Peng <[EMAIL PROTECTED]> wrote: > What I would like to do is something like: > In myModule.py ( a wrapper module for different versions of the module), >if lib == 'standard': > from myModule_std import * >elsif lib == 'optimized' > from myModule_op import * Suggestion: Maybe you use builtin `__import__` to load a module ? Note that in this way, you'll have to use the module name prefix. -- Swaroop C H Blog: http://www.swaroopch.info Book: http://www.byteofpython.info -- http://mail.python.org/mailman/listinfo/python-list
Re: Submission for Python Limmerick Contest
On 22 Mar 2005 11:44:03 -0500, Roy Smith wrote: > A tuple, a dict, and a list, > And whitespace which mus'n't be missed. > Imported together, > And stirred with a feather, > Yields a language whose name must be hissed! Nice! +1 -- Swaroop C H Blog: http://www.swaroopch.info Book: http://www.byteofpython.info -- http://mail.python.org/mailman/listinfo/python-list
Re: FW: Python help group
On Tue, 22 Mar 2005 13:15:15 -0500, Leeds, Mark wrote: > I want to do a sort on a list of objects based on a similar attributes in > each object for example time of creation of this object. >>> >>> class Student: ... def __init__(self, name, age): ... self.name = name ... self.age = age ... >>> >>> students = [Student('John', 18), Student('Jill', 17)] >>> students.sort(lambda x,y: cmp(x.age, y.age)) >>> [student.name for student in students] ['Jill', 'John'] >>> See `help(list.sort)` for details. -- Swaroop C H Blog: http://www.swaroopch.info Book: http://www.byteofpython.info -- http://mail.python.org/mailman/listinfo/python-list
Re: how to apply "mvc" pattern to gui-design in python
On Mon, 28 Mar 2005 17:26:14 +0800, Su Wei <[EMAIL PROTECTED]> wrote: > i have a project want to develop with python. > who can tell me that how to apply "mvc" pattern to gui-design in python. > please give me some advices! > ths in advanced. This may help you: http://pygtkmvc.sourceforge.net/index.php/Main/Features -- Swaroop C H Blog: http://www.swaroopch.info Book: http://www.byteofpython.info -- http://mail.python.org/mailman/listinfo/python-list
Re: html tags and python
On Sat, 26 Mar 2005 01:13:08 +0100, Hansan <[EMAIL PROTECTED]> wrote: > Do you know what I should google after, which key words ? "free javascript calendar" These look interesting: http://www.scriptsearch.com/JavaScript/Scripts/Calendars/ http://www.bigwebmaster.com/JavaScript/Scripts_and_Programs/Calendars/ IMHO, using Javascript is a better idea for this particular purpose instead of writing a lot of checking in Python. -- Swaroop C H Blog: http://www.swaroopch.info Book: http://www.byteofpython.info -- http://mail.python.org/mailman/listinfo/python-list
Re: passing input to running loop
On 27 Mar 2005 17:51:03 -0800, [EMAIL PROTECTED] <[EMAIL PROTECTED]> wrote: > I'm still very new to Python, after decideding to learn a true > programming language (rather then a scripting language, i like to think > i'm a intermediate PHP user). I decided for my first project I would > try to make a IRCbot. I am not sure if you want to write the program completely from scratch. If not, you could perhaps use the Twisted IRC module to do most of your work :) http://twistedmatrix.com/documents/current/api/twisted.protocols.irc.html Regards, -- Swaroop C H Blog: http://www.swaroopch.info Book: http://www.byteofpython.info -- http://mail.python.org/mailman/listinfo/python-list
Re: convert user input to Decimal objects using eval()?
On Mon, 28 Mar 2005 12:03:24 -0500, Julian Hernandez Gomez <[EMAIL PROTECTED]> wrote: > is there a "easy way" to make eval() convert all floating numbers to Decimal > objects and return a Decimal? > eval('1.0001+0.111') --> convert each number to a Decimal object, > perform the sum and obtain a Decimal object as a result? > maybe a parser is needed, but eval() already do the job, but I need the > precision that Decimal offers for numerical applications. If you need the precision, why are you using strings instead of the numbers directly? Also, why not simply use Decimal('1.000') + Decimal('0.111') ? -- Swaroop C H Blog: http://www.swaroopch.info Book: http://www.byteofpython.info -- http://mail.python.org/mailman/listinfo/python-list
Re: why and when we should do it?
On Wed, 30 Mar 2005 09:38:28 +0800, Su Wei <[EMAIL PROTECTED]> wrote: > hi,everybody,Sorry to bother you. > why and when we should add the keyword "pass" ? You can use the 'pass' keyword to indicate an empty block. For example, if True: pass pass is usually used as a placeholder so that you can add code later. > why and when we should inherit Object? You can inherit from Object if you want to have a 'new-style class'. See http://www.python.org/doc/newstyle.html -- Swaroop C H Blog: http://www.swaroopch.info Book: http://www.byteofpython.info -- http://mail.python.org/mailman/listinfo/python-list
Re: Unzipping Files
On Apr 1, 2005 8:14 PM, Greg Lindstrom <[EMAIL PROTECTED]> wrote: > How do I read the data from a file in a zip archive? http://www.devshed.com/c/a/Python/Python-UnZipped Regards, -- Swaroop C H Blog: http://www.swaroopch.info Book: http://www.byteofpython.info -- http://mail.python.org/mailman/listinfo/python-list
Re: pagecrawling websites with Python
On 1 Apr 2005 11:58:11 -0800, writeson <[EMAIL PROTECTED]> wrote: > We've got an application we wrote in Python called pagecrawler that > Does anyone have any insight if this is a reasonable approach to build web > pages, > or if we should look at another design? I don't have an answer to your particular question, but maybe you can have a look at how the HarvestMan works: http://freshmeat.net/projects/harvestman Regards, -- Swaroop C H Blog: http://www.swaroopch.info Book: http://www.byteofpython.info -- http://mail.python.org/mailman/listinfo/python-list
Re: re module non-greedy matches broken
On Apr 4, 2005 10:06 PM, Terry Reedy <[EMAIL PROTECTED]> wrote: > > what book or books on regexes > A standard is Mastering Regular Expressions, 2nd ed, by xxx (sorry, forget) Mastering Regular Expressions, by Jeffrey Friedl See http://www.regex.info/ Regards, -- Swaroop C H Blog: http://www.swaroopch.info Book: http://www.byteofpython.info -- http://mail.python.org/mailman/listinfo/python-list
Re: Calling a Perl Module from Python
On Apr 6, 2005 8:23 AM, gf gf <[EMAIL PROTECTED]> wrote: > I've recently made the switch. Wow, is Python great! > One thing which I haven't been able to do is replace > Perl's great lib collection (HTML::Parser, for > instance, can do a lot that Soup just can't). You've just discovered the only limitation of Python (in my view) - it doesn't have a module repository to rival CPAN. AFAIK, there isn't any reliable way to call Perl modules from Python. -- Swaroop C H Blog: http://www.swaroopch.info Book: http://www.byteofpython.info -- http://mail.python.org/mailman/listinfo/python-list
Re: Python & SQLite
On 5/3/05, Pajo <[EMAIL PROTECTED]> wrote: > What should I install so I can connect to sqlite from > Python. > One simple example would be very helpfull. You haven't mentioned which operating system you are using. For Windows, PySQLite binaries are available at http://initd.org/tracker/pysqlite For Linux/BSD, use your favorite package management software (yum in Fedora, urpmi in Mandrake, emerge in Gentoo, apt-get in Debian, pkg_add in FreeBSD), etc. For Mac, use Fink. HTH :-) -- Swaroop C H Blog: http://www.swaroopch.info Book: http://www.byteofpython.info -- http://mail.python.org/mailman/listinfo/python-list
Re: python+windows/linux -> write stdout text to always on top text?
On 2 May 2005 13:14:02 -0700, flamesrock <[EMAIL PROTECTED]> wrote: > I'm curious if theres a way in python to write stdout text to the > screen (ie top right) the way they do in some FPS games, so that its > always on top, in an invisible window of some set dimensions. No matter > what program is on top. Why would you want to do that ? -- Swaroop C H Blog: http://www.swaroopch.info Book: http://www.byteofpython.info -- http://mail.python.org/mailman/listinfo/python-list
Re: python+windows/linux -> write stdout text to always on top text?
On 3 May 2005 09:41:37 -0700, flamesrock <[EMAIL PROTECTED]> wrote: > I'm writing a multiplayer component to an existing closed source game, > and I'd like users to be able to see whats going on in the chat while > playing the game. > Is it possible? I do not have much knowledge in this area but your query is regarding the abilities of the game engine itself and not much to do with Python. One suggestion is to look up any documentation of that game engine's for this capability. Another suggestion is to look at how Doom 2 or some other open source game engines achieve the same. HTH, -- Swaroop C H Blog: http://www.swaroopch.info Book: http://www.byteofpython.info -- http://mail.python.org/mailman/listinfo/python-list
Re: file parsing/watching + qt
On 3 May 2005 22:43:02 -0700, aljosa <[EMAIL PROTECTED]> wrote: > i'm trying to fetch last line in file whenever isdnlog logs something > so that i can parse that line for a number and store it somewhere else, > is there a standard solution for this? > i'm using python2.3 on linux with PyQt3. Use the Python binding to FAM (File Alteration Monitor): http://python-fam.sourceforge.net/ HTH, -- Swaroop C H Blog: http://www.swaroopch.info Book: http://www.byteofpython.info -- http://mail.python.org/mailman/listinfo/python-list
Pipes of binaries - IPC::Run
Is there a Python equivalent of Perl's IPC::Run module [ http://search.cpan.org/dist/IPC-Run/lib/IPC/Run.pm ] ? Thanks! -- Swaroop C H Blog: http://www.swaroopch.info Book: http://www.byteofpython.info -- http://mail.python.org/mailman/listinfo/python-list
Re: Read tab delimited ascii file
On 5/12/05, Irvine, Wayne D <[EMAIL PROTECTED]> wrote: > I have a tab delimited ascii/excel file formated like ... The CSV module can help you: http://docs.python.org/lib/module-csv.html HTH, -- Swaroop C H Blog: http://www.swaroopch.info Book: http://www.byteofpython.info -- http://mail.python.org/mailman/listinfo/python-list