Re: class level properties
On Apr 13, 12:33 am, Charles D Hixson [EMAIL PROTECTED] wrote: Arnaud Delobelle wrote: class MetaX(type): ... @property ... def spam(self): return 'eggs' ... class X(object): ... __metaclass__ = MetaX ... X.spam 'eggs' HTH -- Arnau Thanks. I can make that work. Is it possible to move the entire implementation of the interpretation of _valueMap, below, into properties in some similar way? I'm referring to the part managed by __getattr__ below. I want a hundred or so read-only variables, and I'm not sure the best way to achieve it. [snip code sample] * Do you want to be able to access your attributes from instances as well or from the class object only? The metaclass trick creates attributes only accessible from the class object, i.e. in my example above: x=X() x.spam Traceback (most recent call last): File stdin, line 1, in module AttributeError: 'X' object has no attribute 'spam' * If you have a hundred of so names and values, are you sure you want to expose them as attributes? It seems to me that they should be in their own namespace (as keys in a mapping or attributes of a subobject) -- Arnaud -- http://mail.python.org/mailman/listinfo/python-list
Re: str(bytes) in Python 3.0
John Roth [EMAIL PROTECTED] wrote in message news:[EMAIL PROTECTED] | On Apr 12, 8:52 am, [EMAIL PROTECTED] (John J. Lee) wrote: | Christian Heimes [EMAIL PROTECTED] writes: | Gabriel Genellina schrieb: | On the last line, str(x), I would expect 'abc' - same as str(x, 'ascii') | above. But I get the same as repr(x) - is this on purpose? | | Yes, it's on purpose but it's a bug in your application to call str() on | a bytes object or to compare bytes and unicode directly. Several months | ago I added a bytes warning option to Python. Start Python as python | -bb and try it again. ;) | | Why hasn't the one-argument str(bytes_obj) been designed to raise an | exception in Python 3? | | John | | Because it's a fundamental rule that you should be able to call str() | on any object and get a sensible result. | | The reason that calling str() on a bytes object returns a bytes | literal rather than an unadorned character string is that there are no | default encodings or decodings: there is no way of determining what | the corresponding string should be. In having a double meaning, str is much like type. Type(obj) echoes the existing class of the object. Type(o,p,q) attempts to construct a new class. Similarly, Str(obj) gives a string representing the obj (which, for a string, is the string;-). Str(obj,obj2) attemps to construct a new string. tjr -- http://mail.python.org/mailman/listinfo/python-list
Re: Where is the function of 'apply' always used?
??? [EMAIL PROTECTED] wrote in message news:[EMAIL PROTECTED] | I'am a beginner of Python.In the course of reading the Python book,I | found the function:apply;But | I don't understand its use.Help! Apply has been deprecated. It has been replaced by the use of *args in function calls. It is only still present for old code and will disappear in 3.0. So you do not need it and should ignore it for now. -- http://mail.python.org/mailman/listinfo/python-list
Re: Where is the function of 'apply' always used?
楼主,为何不用中英又语呢?这里也有其它中国人的. -- http://mail.python.org/mailman/listinfo/python-list
Recommendation for Web Framework
Let me explain my situation a bit. I've been contracted to develop an ecommerce site. It's nothing too huge but requires a lot of custom development that's not typical for your run of the mill webstore. I've got about three weeks to get the project delivered and I've written quite a bit of code already. I'd like to find some sort of tool to generate some of the repetative bits like data management (think phpMyAdmin but for Python) so I don't have to write a stupid mangement script for every single module (users, customers, inventory, etc). I know there's tools out there that will do this for ASP code with a SQL server backend, but I haven't seen anything for Python outside of the web application frameworks. Ideally, I'd like something like Ruby on Rails that would provide scaffolding support so I can bootstrap the system, so to speak. I've looked at Django, but the client is only running Apache 1.x and Python 2.3. I've given Turbo Gears a try, but couldn't get SQLObject to run (threw an error that I didn't have time to struggle with). So basically I need something with low dependencies, easy to develop in, and releatively easy to deploy. Anyone have any recommendations? I really need something on which I can ramp up quickly to get this project out of the door fast. I'm also a framework newbie, so I know there's a learning curve. Any input is appreciated, thank you. - james -- http://mail.python.org/mailman/listinfo/python-list
有中国人乎?
Python这种语言有前途吗?在下想学他一学. -- http://mail.python.org/mailman/listinfo/python-list
Re: class level properties
Charles D Hixson wrote: I want a hundred or so read-only variables, and I'm not sure the best way to achieve it. What do you really want to do? I recommend that you forget about bondage and rely upon displine: class Test(object): Never change an attribute with an uppercase name. SIMPLE = simple example working Now that was easy... Peter -- http://mail.python.org/mailman/listinfo/python-list
Re: str(bytes) in Python 3.0
On Apr 12, 11:51 am, Kay Schluehr [EMAIL PROTECTED] wrote: On 12 Apr., 16:29, Carl Banks [EMAIL PROTECTED] wrote: And making an utf-8 encoding default is not possible without writing a new function? I believe the Zen in effect here is, In the face of ambiguity, refuse the temptation to guess. How do you know if the bytes are utf-8 encoded? How many encodings would you define for a Rectangle constructor? I'm not sure what you're insinuating. If you are arguing that it's inappropriate for a constructor to take an encoding argument (as you put it), be my guest. I wasn't commenting on that specifically. I was commenting on your suggestion of having str assume utf-8 encoding, which IMO would be very unPythonic, whether you can pass encodings to it or not. Whatever happened to the decode method anyway? Why has str() been coopted for this purpose? I had expected that str objects would retain the encode method, bytes the decode method, and everyone would live happily ever after. If decode is a confusing name (and I know I have to engage a few extra neurons to figure out which way it goes), why not rename it to something like to_unicode instead of overloading the constructors more. Carl Banks -- http://mail.python.org/mailman/listinfo/python-list
Re: Rounding a number to nearest even
On Apr 12, 3:44 am, hdante [EMAIL PROTECTED] wrote: (snip) In this table, we consider that a number is rounded down when the But then, the Round up table gives inconsistent results if, by the same argument, we consider 2.0 - 2 rounding up. (you get 12 round ups and 8 round downs just by rethinking the argument). So, rounding up is, at the same time, better and worse than rounding to nearest even. It's not round up, why? In the usual sense -- when not comparing against round-half-even -- the number range we're talking is from x to lim((x+1)-y)[y - 0 from the positive side], e.g. 1 to nearly 2 (thus the integer 2 itself is not included in the number range we're talking since it belongs to the next set), then we choose a uniformly distributed samples, i.e. 1.0, 1.1, 1.2, 1.3, 1.4, 1.5, 1.6, 1.7, 1.8, and 1.9. From these samples, we chose which are rounded down and which are rounded up, it happens that 1.0 is rounded down, while 1.5 is rounded up. IF for the sake of argument, you choose the number range to be lim(x + y)[y - 0 from the positive side] to x + 1, e.g. barely above 1 to 2, then the number sample you use is 1.1, 1.2, 1.3, 1.4, 1.5, 1.6, 1.7, 1.8, 1.9, and 2.0, in this second number range, there are 5 round downs (1.1, 1.2, 1.3, 1.4, 1.5) and 5 round ups (1.6, 1.7, 1.8, 1.9, 2.0), but how logical is it to choose this number range (barely above 1 to 2) against choosing the more natural range (1 to nearly 2): in the correctly chosen number range (1 to nearly 2) all numbers in the form of 1.x (where x is any positive number and 0) is contained within it and there is nothing else in it, but in the second number range (barely above 1 to 2) the number 1.0 is not included while the number 2.0 is contained in it, clearly not a clean separation of numbers in the form of y.x where y is pre-determined and x is variable from other possible values of y. In short, choosing that x.0 is rounded down and x.5 is rounded up is arbitrary but not without a reason. -- http://mail.python.org/mailman/listinfo/python-list
Re: 有中国人乎?
(My Mandarin is not very good.) -On [20080413 09:24], [EMAIL PROTECTED] ([EMAIL PROTECTED]) wrote: Python这种语言有前途吗?在下想学他一学. Python indeed does have a good future. I am not quite sure with 在下想学他一学 if you are asking for someone to teach to you or if you want to teach others. -- Jeroen Ruigrok van der Werven asmodai(-at-)in-nomine.org / asmodai イェルーン ラウフロック ヴァン デル ウェルヴェン http://www.in-nomine.org/ | http://www.rangaku.org/ My greatest fear... Is that all my Memories will be lost... Like tears, in the rain... -- http://mail.python.org/mailman/listinfo/python-list
Re: Recommendation for Web Framework
On Apr 13, 8:18 am, James West [EMAIL PROTECTED] wrote: [...] Ideally, I'd like something like Ruby on Rails that would provide scaffolding support so I can bootstrap the system, so to speak. I've looked at Django, but the client is only running Apache 1.x and Python 2.3. Django only requires Python 2.3 IIRC, and I think you can use it with FastCGI instead of mod_python. Doesn't FastCGI only require apache 1.3.x ? -- Arnaud -- http://mail.python.org/mailman/listinfo/python-list
Call a classmethod on a variable class name
I would like to be able to call a specific classmethod on a class name that is going to be passed from another parameter. In other words, I have a call that looks something like: x = Foo.bar() and I would like to generalise this so that I can make this call on any particular class which provides the bar classmethod. I have implemented this using exec, like so: className = parameters.className exec x = + className + .bar() but this feels somewhat clumsy. (I do have the requisite exception handling to cope with the supplied class not existing or not implementing the bar method, by the way). Is there any more Pythonesque way of doing this ? I guess what I'm probably looking for is something like the way I understand the send function works in Ruby -- http://mail.python.org/mailman/listinfo/python-list
Graphical grammar in python
hi Is exist any graphical library with resize, rotate, shape recognition, ...? suitable for graphical grammar at this moment I have OpenGL (resize rotate) and recognition solved as saved set of shapes (classes) feel free to write down any ideas :) -- http://mail.python.org/mailman/listinfo/python-list
Re: Call a classmethod on a variable class name
On Apr 13, 9:51 am, Matthew Keene [EMAIL PROTECTED] wrote: I would like to be able to call a specific classmethod on a class name that is going to be passed from another parameter. In other words, I have a call that looks something like: x = Foo.bar() and I would like to generalise this so that I can make this call on any particular class which provides the bar classmethod. I have implemented this using exec, like so: className = parameters.className exec x = + className + .bar() but this feels somewhat clumsy. (I do have the requisite exception handling to cope with the supplied class not existing or not implementing the bar method, by the way). Is there any more Pythonesque way of doing this ? I guess what I'm probably looking for is something like the way I understand the send function works in Ruby If your class lives in the current global namespace, you can get it with cls = globals()[classname] Then you can access its .bar() method directly: cls.bar() Example: class Foo(object): ... @classmethod ... def bar(cls): print 'Oh my Baz!' ... globals()['Foo'] class '__main__.Foo' globals()['Foo'].bar() Oh my Baz! If your class lives in a module, just do getattr(module, classname) instead to get the class object. HTH -- Arnaud -- http://mail.python.org/mailman/listinfo/python-list
Re: from __future__ import print
On Apr 11, 7:26 pm, Bruno Desthuilliers bruno. [EMAIL PROTECTED] wrote: [EMAIL PROTECTED] a écrit : Am I the only one that thinks this would be useful? :) I'd really like to be able to use python 3.0's print statement in 2.x. nitpick mode=pedantic FWIW, the whole point is that in 3.0, print stop being a statement to become a function... /nitpick But the reason it becomes a function is because being a statement it is inflexible and there is no way to pass arguments to the print function, at the cost of extra typing of parentheses. I wish py3k would make it an option whether to treat print as statement or function though. Since not all programs require the power of print as a function and having to type the extra parentheses is a bit tiring if you're printing lots of things. Probably it may be coupled with a translator (for source code from statement to function, since the reverse would not be practical) if you changed your mind. -- http://mail.python.org/mailman/listinfo/python-list
Re: How is GUI programming in Python?
-BEGIN PGP SIGNED MESSAGE- Hash: SHA1 Torsten Bronger wrote: Hallöchen! Und auch ein hallo, aus den Niederlanden! :P Michel Bouwmans writes: Gabriel Genellina wrote: Michel Bouwmans [EMAIL PROTECTED] escribió: Gabriel Genellina wrote: Another annoying thing with the Qt license is that you have to choose it at the very start of the project. You cannot develop something using the open source license and later decide to switch to the commercial licence and buy it. Unless you're a company with a risk of being checked for legal software etc., you can always ignore that allthough not very legal. I just ignore Qt itself. Then you're ignorant. What do you prefer than? Well ... don't expect answers that you like when you suggest doing something which is not allowed. [...] - WxPython is terribly unstable. I can't confirm that. When I chose wxPython after thorough consideration one year ago, my impression was that reports of instability were indeed frequent but rather old. Apparently, the situation had improved. Does your experience rely on recent use? Tschö, Torsten. About half a year/a year ago. Segfaults is simply not something I like to see when I use an API binding. For me it didn't feel that right when using it so I made the temporary switch to Tkinter. greetz MFB -BEGIN PGP SIGNATURE- Version: GnuPG v1.4.7 (GNU/Linux) iD8DBQFIAc3PDpaqHmOKFdQRAi3PAJ4idF7KLdOQfpfARBjA839wyKBQAQCcDIMA GX41PYj5t+ap8nEwkWRtb4Q= =LTVd -END PGP SIGNATURE- -- http://mail.python.org/mailman/listinfo/python-list
Re: Call a classmethod on a variable class name
Arnaud Delobelle wrote: If your class lives in the current global namespace, you can get it with cls = globals()[classname] Then you can access its .bar() method directly: cls.bar() Example: class Foo(object): ... @classmethod ... def bar(cls): print 'Oh my Baz!' ... globals()['Foo'] class ' main .Foo' globals()['Foo'].bar() Oh my Baz! If your class lives in a module, just do getattr(module, classname) instead to get the class object. HTH Yes, that feels much nicer and works well. Thanks for the prompt reply ! -- http://mail.python.org/mailman/listinfo/python-list
latest command from toplevel?
windows vista and python 2.5, is there a way to get the latest command entered? would be very useful. if not by default, anything i could download or write myself? -- http://mail.python.org/mailman/listinfo/python-list
Re: 有中国人乎?
[EMAIL PROTECTED] 写道: Python这种语言有前途吗?在下想学他一学. hehe, so humorous you are! Yes I think python has good future. But it depends on what you use it to do. If you're a singer, a financier, a historian etc, you don't need python. But if you are playing in computer programming, it's valuable for you to take some time learning python. btw,I'm also newbie to python,but I like it. --penny -- http://mail.python.org/mailman/listinfo/python-list
Re: SQLite OperationalError near ?
On 13 avr, 03:00, John Machin [EMAIL PROTECTED] wrote: On Apr 13, 8:45 am, Hexade [EMAIL PROTECTED] wrote: Hello I would like to use the safe ? placeholder in my SQLite requests but I got the following error: Traceback (most recent call last): (...) cursor.execute(SELECT ? FROM ? WHERE name = ? , (key, self.table, self.name)) OperationalError: near ?: syntax error key, self.table and self.name are standart strings. Any idea about how to solve this problem ? You may like to read the answer to the question on sqlite3 that was posted 45 minutes before yours. Thank you. I guess you are speaking about http://groups.google.com/group/comp.lang.python/browse_thread/thread/50a8ad977ed31e2a# -- http://mail.python.org/mailman/listinfo/python-list
Re: Looking for a way to include Pyhtho scripting INSIDE a python program
On Apr 13, 4:16 am, John Antypas [EMAIL PROTECTED] wrote: Hello all, I'm writing in tool in Python that manipulates various data objects read from various streams. I wanted to give the user a chance to do advanced work that could not easily be done from a GUI. At first, I tried putting in a lightweight scripting language, and then I thought, why not include Python in itself -- it is certainly powerful enough. I had assumed I'd present the user with a text window in which they could type arbitrary python code. I'd wrap that code around a function and pass that function a call of objects they could manipulate by calling the methods of that class. 1. How can a python program invoke ANOTHER interpreter? 2. How can I pass the class in as its argument and get the modified class back? I know I can do something very ugly -- call a C method that calls a new python interpreter but that seems VERY ugly. Help? Thanks. You might try ipython at http://ipython.scipy.org/moin/; or 'python - i'; or the exec and eval statements. There is also the compiler module: http://docs.python.org/lib/compiler.html - Paddy. -- http://mail.python.org/mailman/listinfo/python-list
Re: 有中国人乎?
[EMAIL PROTECTED] wrote: Python这种语言有前途吗?在下想学他一学. 是, Python 有未来。但学会从未是立即, 和将需要一点时间。 regards Steve -- Steve Holden+1 571 484 6266 +1 800 494 3119 Holden Web LLC http://www.holdenweb.com/ -- http://mail.python.org/mailman/listinfo/python-list
Re: C to python conversion
On Apr 13, 7:58 am, Gabriel Genellina [EMAIL PROTECTED] wrote: En Sat, 12 Apr 2008 07:58:47 -0300, Michele Petrazzo [EMAIL PROTECTED] escribió: Hi all, I'm trying to translate a simple C code into a python + ctypes (where need), but I have some problems on char conversion. The code have to work on Linux and talk with the serial port. I think that the problem is that I don't translate correctly the strings. C code: #define START 0x33 #define RETURN_START 0x22 #define ADDR 0x01 #define WRITE_CMD 0x03 #define ALL_CMD 0xFF ... char buf[10]; char buf_ret[10]; buf[0]=0; buf[0]=START; buf[1]=ADDR; buf[2]=WRITE_CMD; write(_fd, buf, 6); read(_fd,buf_ret,6); You don't even need ctypes. In C, `char` is a small integer: 'A' and the number 65 are interchangeable. In Python, there are no chars but strings of length 1, which are not the same thing as their ordinal integer. The easiest way is to define those constants as strings instead: START = chr(0x33) RETURN_START = chr(0x22) ADDR = chr(0x01) WRITE_CMD = chr(0x03) ALL_CMD = chr(0xFF) NUL = chr(0) buf = START + ADDR + WRITE_CMD + NUL + NUL + NUL # I assume the buffer was initialized to NULs, because only 3 bytes # are filled but 6 bytes are written. os.write(_fd, buf) buf_ret = os.read(_fd, 6) -- Gabriel Genellina The easiest way is to use struct: START = 0x33 RETURN_START = 0x22 ADDR = 0x01 WRITE_CMD = 0x03 ALL_CMD = 0xFF buf = struct.pack('3b3x', START, ADDR, WRITE_CMD) os.write(_fd, buf) buf_ret = os.read(_fd, 6) And, definitely, no need for ctypes here. -- Ivan Illarionov -- http://mail.python.org/mailman/listinfo/python-list
Re: String Literal to Blob
Jason Scheirer wrote: [...] There _is_ a way to embed image data in HTML that is supported by every major browser. It is ugly. Using the RFC 2397 (http:// www.ietf.org/rfc/rfc2397) spec for data URLs you could go 'img src=data:image/jpg;base64,%s' % base64.b64encode(image_data) Obviously you need to import the base64 module somewhere in your code and base64-encoded data is about a third larger than it would be otherwise, so embedding anything particularly large is going to be a huge pain and affect page load times pretty badly. This is hardly likely to help someone who hasn't yet grasped the concept of referencing graphics and prefers to write database output to disk to serve it statically. But who knows, maybe it will ... regards Steve -- Steve Holden+1 571 484 6266 +1 800 494 3119 Holden Web LLC http://www.holdenweb.com/ -- http://mail.python.org/mailman/listinfo/python-list
How to Choose an Unlimited Web Hosting for free
How to Choose an Unlimited Web Hosting 1) Visit www.axealis.com to get domain and hosting 2) Unlimited Bandwidth ,this mean unlimited data transmission for your client access. 2) Unlimited Space , you can upload file for unlimited . 3) Unlimited Email , many of email account can created . 5) SSL Security , used SSL / HTTPS to protect your web . 6) LINUX , WINDOWS and MAC , can access form many operating system. -- http://mail.python.org/mailman/listinfo/python-list
Re: Rounding a number to nearest even
Lie wrote: On Apr 12, 3:44 am, hdante [EMAIL PROTECTED] wrote: [snip] In short, choosing that x.0 is rounded down and x.5 is rounded up is arbitrary but not without a reason. Don't arbitrary and not without a reason directly contradict one another? regards Steve -- Steve Holden+1 571 484 6266 +1 800 494 3119 Holden Web LLC http://www.holdenweb.com/ -- http://mail.python.org/mailman/listinfo/python-list
Re: from __future__ import print
In article [EMAIL PROTECTED], Lie [EMAIL PROTECTED] wrote: I wish py3k would make it an option whether to treat print as statement or function though. Arrrggh! No, don't even go there. If you want optional parens, use Perl :-) -- http://mail.python.org/mailman/listinfo/python-list
Re: Looking for a way to include Pyhtho scripting INSIDE a python program
On Apr 13, 7:16 am, John Antypas [EMAIL PROTECTED] wrote: Hello all, I'm writing in tool in Python that manipulates various data objects read from various streams. I wanted to give the user a chance to do advanced work that could not easily be done from a GUI. At first, I tried putting in a lightweight scripting language, and then I thought, why not include Python in itself -- it is certainly powerful enough. I had assumed I'd present the user with a text window in which they could type arbitrary python code. I'd wrap that code around a function and pass that function a call of objects they could manipulate by calling the methods of that class. 1. How can a python program invoke ANOTHER interpreter? 2. How can I pass the class in as its argument and get the modified class back? I know I can do something very ugly -- call a C method that calls a new python interpreter but that seems VERY ugly. Help? Thanks. You don't need to envoke another interpreter. Python can interpret arbitrary python code with exec statement. Wrap user's string inside function definition, and exec it. You might want to disable words like `import`, `exec` and `eval` in user's code because it's a big security risk. -- Ivan Illarionov -- http://mail.python.org/mailman/listinfo/python-list
Re: tkinter, annoying grid-problem
[EMAIL PROTECTED] wrote: so my little calculator works perfectly now. just having some trouble with the layout. this whole tkinter-thing seems to be more tricky than it should be. how can i make the 4 column of buttons have the same distance and size between them as the other 3 columns? and how can i make the top entry end where the 2nd row entry ends(meaning the top entry will be longer)? why are the 4th row split from the others? hard to fix the problems when u dont even understand why things happen. seems so llogical a lot of it. i change something then something unexpected happens. The best answer I can give (being a Tk expert but not yet a tkinter expert) is to start with a piece of graph paper. Draw the GUI out and you'll probably see what the problems are. For one, the second entry (for the answer) spans 4 columns and begins at column 3, so it ends up in column 6. This ends up affecting the whole layout because nothing else goes to column six. You'll probably find it much easier going to break down your GUI into sections. One for the calculator buttons and one for everything else. Create a frame for the buttons and it becomes trivial to layout out all the buttons in a 4x6 grid, unaffected by things outside that grid. Then, create your other widgets and grid the whole frame of buttons as a single unit inside the outermost frame. I quite often use grid for interior groupings, then use pack on the outter-most frame to manager the various groups. Using the grid layout manager is trivial if you do a little thinking and planning up front. If you don't, you can spend all day chasing down why you end up with an extra blank row or column, unusually sized rows and columns, etc. Again, get a piece of graph paper and draw it out -- that helps immensely when you're first coming up to speed using grid. -- http://mail.python.org/mailman/listinfo/python-list
py2exe, program has stoped working!?
so i used py2exe and i have the build and the dist-folders. in the distfolder there is a Calculator.exe file. when i run it it just says Calculator.exe has stopped working in a popup but the program itself never shows up. wtf!? and when im distributing my program i have to include both catalogues right? -- http://mail.python.org/mailman/listinfo/python-list
PIL and true type fonts
Attached a screenshot from a text rendered by GIMP (left side) and PIL (right side). Same truetype font. Is this a bug in PIL? Thanks, Laszlo inline: 1.JPG-- http://mail.python.org/mailman/listinfo/python-list
Re: Rounding a number to nearest even
On Apr 13, 4:18 am, Lie [EMAIL PROTECTED] wrote: [...] it and there is nothing else in it, but in the second number range (barely above 1 to 2) the number 1.0 is not included while the number 2.0 is contained in it, clearly not a clean separation of numbers in the form of y.x where y is pre-determined and x is variable from other possible values of y. Have you considered the fact that the real numbers of the form 1.x... are those in the range [1.0, 2.0], including *both* endpoints? That is, 2.0 = 1.99... Similarly, the midpoint of this range can be written both in the form 1.50... and 1.49... This is relevant if you think of rounding as an operation on *decimal representations* of real numbers rather than as an operation on real numbers themselves. I'm not sure which point of view you're taking here. Either way, your arguments don't change the fact that the average rounding error is strictly positive for positive quantized results, under round-half-away-from-zero. Mark -- http://mail.python.org/mailman/listinfo/python-list
Module to read input from commandline
Hi all, I did some quick searching but I haven't found anything like I want. It probably has to do with the terms I am searching for so if I describe what I want then I hope someone can point me to a good module. I want to take input from the user at the command line. e.g.) Would you like to continue [Y/n]: y What is your favorite color: green You get the idea. Basic question answer stuff. It should handle default options, case insensitivity, etc. Perhaps the module would compare the inputted text against a regexp for validation. If the module had an interface similar to OptParse that would be nice. Anyone know of a decent module that handles this type of thing? Writing from scratch would be simple but why re-invent the wheel. Cheers, James. -- http://mail.python.org/mailman/listinfo/python-list
Re: Call a classmethod on a variable class name
Matthew Keene wrote: I would like to be able to call a specific classmethod on a class name that is going to be passed from another parameter. In other words, I have a call that looks something like: x = Foo.bar() and I would like to generalise this so that I can make this call on any particular class which provides the bar classmethod. I have implemented this using exec, like so: className = parameters.className exec x = + className + .bar() Yuck. No. Don't do that. As a general rule, anything you could build and put into an exec is a functionality that is exposed more directly by Python. but this feels somewhat clumsy. (I do have the requisite exception handling to cope with the supplied class not existing or not implementing the bar method, by the way). Is there any more Pythonesque way of doing this ? I guess what I'm probably looking for is something like the way I understand the send function works in Ruby First off, if possible, don't pass the class name, but instead pass the class itself: class SomeClass: def foo(): ... whatever... ... parameters.theClass = SomeClass ... parameters.theClass.bar() If you can't do that, then look up that class from the class name and make your call: class SomeClass: def foo(): ... whatever... ... parameters.className = 'SomeClass' ... theClass = globals()[parameters.className] parameters.theClass.bar() (Hint: It matters not whether foo is a classmethod, saticmathod or normal method.) Gary Herron -- http://mail.python.org/mailman/listinfo/python-list
Re: How to Choose an Unlimited Web Hosting for free
Unlimited Free Domain Web Hosting wrote: How to Choose an Unlimited Web Hosting 1) Visit www.axealis.com to get domain and hosting 2) Unlimited Bandwidth ,this mean unlimited data transmission for your client access. 2) Unlimited Space , you can upload file for unlimited . 3) Unlimited Email , many of email account can created . 5) SSL Security , used SSL / HTTPS to protect your web . 6) LINUX , WINDOWS and MAC , can access form many operating system. This is some spamming reseller for Byet Hosting. Which does not support Python. John Nagle -- http://mail.python.org/mailman/listinfo/python-list
Re: How to Choose an Unlimited Web Hosting for free
On Sun, 13 Apr 2008 08:42:52 -0700, John Nagle wrote: Unlimited Free Domain Web Hosting wrote: How to Choose an Unlimited Web Hosting 1) Visit www.xxx.com to get domain and hosting 2) Unlimited Bandwidth ,this mean unlimited data transmission for your client access. 2) Unlimited Space , you can upload file for unlimited . 3) Unlimited Email , many of email account can created . 5) SSL Security , used SSL / HTTPS to protect your web . 6) LINUX , WINDOWS and MAC , can access form many operating system. This is some spamming reseller for Xxxx Hosting. And now you've spread the spam to those whose news servers filtered the original message. Thanks... Ciao, Marc 'BlackJack' Rintsch -- http://mail.python.org/mailman/listinfo/python-list
Re: str(bytes) in Python 3.0
On 13 Apr., 09:24, Carl Banks [EMAIL PROTECTED] wrote: On Apr 12, 11:51 am, Kay Schluehr [EMAIL PROTECTED] wrote: On 12 Apr., 16:29, Carl Banks [EMAIL PROTECTED] wrote: And making an utf-8 encoding default is not possible without writing a new function? I believe the Zen in effect here is, In the face of ambiguity, refuse the temptation to guess. How do you know if the bytes are utf-8 encoded? How many encodings would you define for a Rectangle constructor? I'm not sure what you're insinuating. If you are arguing that it's inappropriate for a constructor to take an encoding argument (as you put it), be my guest. I wasn't commenting on that specifically. I was commenting on your suggestion of having str assume utf-8 encoding, which IMO would be very unPythonic, whether you can pass encodings to it or not. That's o.k. I don't primarily advocate default values or such things just reduction of mental and scripting overhead. We shouldn't lose the goal out of sight. I played a bit with several encodings but this didn't enable much of an impression how it will feel in real code. I can see though the inadequacy of my original claim mainly due to the overlooked fact that there isn't even a mapping of the range \x0 - \xff to utf-8 but only one from \x0 - \x7f. Same with the ASCII encoding which is limited to 7 bits as well. One has to be careful not just because you can select the wrong encoding but stringification with an utf-8 encoding can simply activate the exception handler even though there will be no type error! A default value shall work under all circumstances supposed you pass in an object of the correct type. -- http://mail.python.org/mailman/listinfo/python-list
Tkinter, image not appearing in function but without function
why is the first program not working? when i click the screen the map is not appearing. the second program works. from Tkinter import * master = Tk() w = Canvas(master, width=700, height=600) w.pack(expand = YES, fill = BOTH) def mapper(): mapq = PhotoImage(file = 'C:\Users\saftarn\Desktop\world-map.gif') w.create_image(10, 10, image = mapq, anchor = NW) def key(event): print pressed, repr(event.char) def callback(event): w.focus_set() print clicked at, event.x, event.y mapper() print 'yo' square = w.create_oval(event.x-5,event.y-5,event.x+5,event.y+5, fill=black) w.bind(Key, key) w.bind(Button-1, callback) w.pack() mainloop() from Tkinter import * master = Tk() w = Canvas(master, width=700, height=600) w.pack(expand = YES, fill = BOTH) q=raw_input(Choose: i=India, s=sweden, else World: ) if q==i: mapq = PhotoImage(file = 'C:\Users\saftarn\Desktop\map-india.bmp') elif q=='s': mapq = PhotoImage(file = 'C:\Users\saftarn\Desktop\provinces-of- sweden.gif') else: mapq = PhotoImage(file = 'C:\Users\saftarn\Desktop\world-map.gif') print mapq.height(), mapq.width() w.create_image(10, 10, image = mapq, anchor = NW) def key(event): print pressed, repr(event.char) def callback(event): w.focus_set() print clicked at, event.x, event.y square = w.create_oval(event.x-5,event.y-5,event.x+5,event.y+5, fill=black) hur hitta om inom ratt-kolla color of w.bind(Key, key) w.bind(Button-1, callback) w.pack() mainloop() -- http://mail.python.org/mailman/listinfo/python-list
email module windows and suse
Hi, all! I have to make a custom email module, based on the standard one. The custom module has to be able to work with extremely large mails (1GB +), having memory footprint much smaller. The modified program has to work in SUSE environment, while the development is done under Windows. I'm not too good with linux and do not know if speedup in Windows translates one-to-one into speedup in SUSE. For example, if the bottleneck is IO, in windows I can spawn a separate thread or 2 to do read-ahead. Are threads available and as effective in SUSE as they are in Windows? I'd appreciate any suggestions concerning the modifications of the module and concerning cross platform development. -- http://mail.python.org/mailman/listinfo/python-list
Re: PythonWin Print Problem.. Build 210
Roger Upole [EMAIL PROTECTED] wrote in message news:[EMAIL PROTECTED] Hutch [EMAIL PROTECTED] wrote in message news:[EMAIL PROTECTED] PythonWin has been a very good ide from early version thru 2.4. All work ok on THREE of my computers with THREE different HP printers. Now comes 2.5. Every thing seems to work the same except when I want to print out a copy of the source code of my project (about 38 pages) Version 2.5 acts like it is going to print out the source code but instead prints from several 100 to over 2000 BLANK PAGES pages and no source. Attempting to print out Source on SAME equipment (computers and printers) using 2.4 (WITH NO CHANGES TO EQUIPMENT OR SOFTWARE ) results in proper print out of source. Problem has been reported via direct and SourceForge but no response. Any body else having the same problem? -- http://mail.python.org/mailman/listinfo/python-list Did you see the response to the bug report on SF ? http://sourceforge.net/tracker/index.php?func=detailaid=1907148group_id=78018atid=551954 There is also some more info in this thread on the python-win32 mailing list: http://mail.python.org/pipermail/python-win32/2006-December/005397.html Roger Sorry to report after uninstalling both Python 2.5 and Pythonwin 2.5 and reinstalling.. THE PROBLEM IS STILL WITH US... -- http://mail.python.org/mailman/listinfo/python-list
Re: Tremendous slowdown due to garbage collection
On Apr 12, 6:58 pm, Steve Holden [EMAIL PROTECTED] wrote: Paul Rubin wrote: Steve Holden [EMAIL PROTECTED] writes: I believe you are making surmises outside your range of competence there. While your faith in the developers is touching, the garbage collection scheme is something that has received a lot of attention with respect to performance under typical workloads over the years. Really, Python's cyclic gc is quite crude and should be upgraded to something that doesn't fall into that quadratic behavior. There was some fairly detailed discussion of this in another thread last time the subject came up. I'll take your word for it. I discussed it not too long ago, but I can't seem to find the thread.. Basically, python's gen2 collections are to blame. You get a full (gen2) collection a linear number of times for a linear number of allocations, but the cost of each collection is also linear, giving you O(n**2) cost. I think it's fairly clear that it should not be that expensive. -- http://mail.python.org/mailman/listinfo/python-list
Re: C API design flaw (was: Re: Multiple independent Python interpreters in a C/C++ program?)
On Apr 12, 2:02 pm, sturlamolden [EMAIL PROTECTED] wrote: On Apr 12, 7:05 pm, sturlamolden [EMAIL PROTECTED] wrote: In theory, a GIL private to each (sub)interpreter would make Python more scalable. The current GIL behaves like the BKL in earlier Linux kernels. However, some third-party software, notably Apache's mod_python, is claimed to depend on this behaviour. I just looked into the reason why ctypes, mod_python, etc. depend on a shared GIL. Well ... PyGILState_Ensure() does not take an argument, so it does not know which interpreter's GIL to acquire. Duh! The sad fact is, the functions in Python's C API does not take the interpreter as an argument, so they default to the one that is currently active (i.e. the one that PyThreadState_Get()-interp points to). This is unlike Java's JNI, in which all functions take the environment (a Java VM instance) as the first argument. IMHO, I consider this a major design flaw in Python's C API. In a more well thought API, PyGILState_Ensure would take the interpreter returned by Py_NewInterpreter as an argument, and thus know the interpreter with which to synchronize. I complained about this before, but the answer I got was that the simplified GIL API would not work if interpreters has a separate GIL. Obviously it would not work as long as the PyGILState_Ensure does not take any arguments. The lack of a leading VM argument in PyGILState_Ensure, and almost every function in Python's C API, is the heart of the problem. Alternatively, the multiple interpreter API could be ripped out, and you could just use separate threads. Do you have a use case that requires it? -- http://mail.python.org/mailman/listinfo/python-list
Re: Looking for a way to include Pyhtho scripting INSIDE a python program
Ivan Illarionov wrote: You don't need to envoke another interpreter. Python can interpret arbitrary python code with exec statement. Wrap user's string inside function definition, and exec it. You might want to disable words like `import`, `exec` and `eval` in user's code because it's a big security risk. The above statement is exactly why one would want to eval the code inside a separate interpreter. Not just for security, but to prevent user code from stomping all over the application code by creating or destroying global resources. Is it possible to create a nested interpreter like you can do in some other languages? -- http://mail.python.org/mailman/listinfo/python-list
Re: Interesting math problem
On Mar 19, 2:17 pm, BJörn Lindqvist [EMAIL PROTECTED] wrote: On Mon, Mar 17, 2008 at 11:57 PM, Arnaud Delobelle [EMAIL PROTECTED] wrote: def make_slope(distance, parts): step = distance / float(parts) intstep = int(step) floatstep = step - intstep steps = [] acc = 0.0 for i in range(parts): acc += floatstep step = intstep if acc 0.999: step += 1 acc -= 1.0 steps.append(step) return steps OK then, using list comprehensions. It is more succint, is it easier to read? def slope(dist, parts): return [(i+1)*dist/parts - i*dist/parts for i in xrange(parts)] Congratulations! You Won! Jeff Schwab's recursive approach is also cool but this is the most interesting abuse of integer division I have seen. I don't think any of the variants are readable at a first glance, but with a comment it should be ok. -- mvh Björn I really want to revive this discussion. Arnaud's approach is definetly cool, but it turns out that in real-world situations it doesn't work as succint as here. Try to use it to draw a simple non-anitaliased line in a standrad python array or buffer object. Suppose we have an array of unsigned bytes called `buf` where each line takes `pitch` bytes. That's what I got while trying to take advantage of this approach. No advantage at all. And what about ability to port the code to C for speed? def draw_line(buf, pitch, x, y, dx, dy): if dx == dy == 0: buf[y * pitch + x] = 0 return xdir, ydir = 1, 1 if dx 0: xdir = -1 dx = abs(dx) if dy 0: ydir = -1 dy = abs(dy) if dy dx: steps = ((i+1) * dx / dy - i * dx / dy for i in xrange(dy)) for step in steps: start = y * pitch + x if xdir 0: buf[start : start + step] = array('B', [0] * step) else: buf[start - step : start] = array('B', [0] * step) x += step * xdir y += ydir else: steps = ((i+1) * dy / dx - i * dy / dx for i in xrange(dx)) for step in steps: start = y * pitch + x if ydir 0: for i in range(start, start + pitch * step, pitch): buf[i] = 0 else: for i in range(start, start - pitch * step, -pitch): buf[i] = 0 x += xdir y += step * ydir Please, tell me that I'm wrong and it's really possible to draw lines, do scan-conversion and so on with such a cool succint constructs! -- Ivan -- http://mail.python.org/mailman/listinfo/python-list
Compiling Python 2.5.2 on AIX 5.2
I'm investigating the possible use of Mecurial SCM as a replacement for CVS. Mecurial is written in Python. I have a background in GNU/ Linux, Solaris, sparc and Perl. However AIX, powerpc and Python are new to me. --uname output-- $ uname -rvp 2 5 powerpc --end uname output-- I used this script to compile Python: --script-- export PATH=/usr/bin:/usr/vacpp/bin export CC=xlC_r export OBJECT_MODE=32 gunzip -c Python-2.5.2.tar.gz | tar xvf - cd Python-2.5.2 ./configure --with-gcc=xlc_r --with-cxx=xlC_r \ --disable-ipv6 AR=ar --prefix=$HOME make --end script-- My concern is when I run make test I get this output: --make test output-- 275 tests OK. 2 tests failed: test_mmap test_wait4 45 tests skipped: test_aepack test_al test_applesingle test_bsddb test_bsddb185 test_bsddb3 test_bz2 test_cd test_cl test_codecmaps_cn test_codecmaps_hk test_codecmaps_jp test_codecmaps_kr test_codecmaps_tw test_ctypes test_curses test_dl test_gdbm test_gl test_gzip test_imgfile test_largefile test_linuxaudiodev test_macfs test_macostools test_nis test_normalization test_ossaudiodev test_pep277 test_plistlib test_scriptpackages test_socket_ssl test_socketserver test_sqlite test_startfile test_sunaudiodev test_tcl test_timeout test_urllib2net test_urllibnet test_winreg test_winsound test_zipfile64 test_zipimport test_zlib 2 skips unexpected on aix5: test_largefile test_ctypes make: *** [test] Error 1 --end make test output-- My question are: (a) Have you successfully compiled Python 2.5.2 on AIX 5.2? If so, which options did you place in the environment and send to ./ configure? (b) Given the choice between xlc and gcc 4.2.2 (which we have on the platform) which one is considered more suitable? (c) I am concerned about the two failing test cases: test_mmap and test_wait4. Are there good reasons why these failures can be safely ignored? (d) Should I be concerned with the skips of test_largefile and test_ctypes? Much thanks in advance. Kind regards, -Randy Galbraith -- http://mail.python.org/mailman/listinfo/python-list
tkinter, canvas, get color of image?
mapq = PhotoImage(file = 'C:\Users\saftarn\Desktop\elmapovic.gif') w.create_image(10, 10, image = mapq, anchor = NW) after doing this is there any possibility of getting the characteristics of the GIF-picture(or bitmap if i use that)? it would be very helpfull if i for example could do something like canvas.getcolor(image, mouseclick.x,mouseclick.y) if u get the point. get the color of the image where i clicked. -- http://mail.python.org/mailman/listinfo/python-list
Re: Module to read input from commandline
Unless I misunderstand your needs, you could just use raw_input(prompt) to get your answers. - Original Message From: [EMAIL PROTECTED] [EMAIL PROTECTED] To: python-list@python.org Sent: Sunday, April 13, 2008 11:12:06 AM Subject: Module to read input from commandline Hi all, I did some quick searching but I haven't found anything like I want. It probably has to do with the terms I am searching for so if I describe what I want then I hope someone can point me to a good module. I want to take input from the user at the command line. e.g.) Would you like to continue [Y/n]: y What is your favorite color: green You get the idea. Basic question answer stuff. It should handle default options, case insensitivity, etc. Perhaps the module would compare the inputted text against a regexp for validation. If the module had an interface similar to OptParse that would be nice. Anyone know of a decent module that handles this type of thing? Writing from scratch would be simple but why re-invent the wheel. Cheers, James. -- http://mail.python.org/mailman/listinfo/python-list __ Do You Yahoo!? Tired of spam? Yahoo! Mail has the best spam protection around http://mail.yahoo.com -- http://mail.python.org/mailman/listinfo/python-list
Re: Tkinter, image not appearing in function but without function
On Sun, 13 Apr 2008 08:57:29 -0700, skanemupp wrote: why is the first program not working? when i click the screen the map is not appearing. the second program works. from Tkinter import * master = Tk() w = Canvas(master, width=700, height=600) w.pack(expand = YES, fill = BOTH) def mapper(): mapq = PhotoImage(file = 'C:\Users\saftarn\Desktop\world-map.gif') w.create_image(10, 10, image = mapq, anchor = NW) def key(event): print pressed, repr(event.char) def callback(event): w.focus_set() print clicked at, event.x, event.y mapper() print 'yo' square = w.create_oval(event.x-5,event.y-5,event.x+5,event.y+5, fill=black) w.bind(Key, key) w.bind(Button-1, callback) w.pack() mainloop() Python doesn't know that the Tk side still needs the image and frees the memory when `mapper()` is done and `mapq` the only name to the `PhotoImage` instance goes out of scope. Ciao, Marc 'BlackJack' Rintsch -- http://mail.python.org/mailman/listinfo/python-list
Re: tkinter, canvas, get color of image?
[EMAIL PROTECTED] wrote: mapq = PhotoImage(file = 'C:\Users\saftarn\Desktop\elmapovic.gif') w.create_image(10, 10, image = mapq, anchor = NW) after doing this is there any possibility of getting the characteristics of the GIF-picture(or bitmap if i use that)? it would be very helpfull if i for example could do something like canvas.getcolor(image, mouseclick.x,mouseclick.y) if u get the point. get the color of the image where i clicked. The image isn't painted on the canvas, so to answer your specific question, no, you can't get the color of a pixel on the canvas in the way that you ask. However, when you click on the canvas you can get the item that was clicked on and the x/y of the click. From that you can figure out which pixel of the image is under the cursor. And from that you can query the image for the color of a specific pixel. -- http://mail.python.org/mailman/listinfo/python-list
Re: Looking for a way to include Pyhtho scripting INSIDE a python program
On Apr 13, 8:20 pm, Bryan Oakley [EMAIL PROTECTED] wrote: Ivan Illarionov wrote: You don't need to envoke another interpreter. Python can interpret arbitrary python code with exec statement. Wrap user's string inside function definition, and exec it. You might want to disable words like `import`, `exec` and `eval` in user's code because it's a big security risk. The above statement is exactly why one would want to eval the code inside a separate interpreter. Not just for security, but to prevent user code from stomping all over the application code by creating or destroying global resources. Is it possible to create a nested interpreter like you can do in some other languages? Yes. Call PyRun_SimpleString from ctypes or call PyRun_SimpleString from custom python extension. But it does nothing what exec can't do. We have: exec `something` in `where_we_exec` if `where_we_exec` is an empty dictionary the exec'd code has no access to app code or global resources. Even more, it's harder to control the nested interpreter than strings about to be exec'd. And you still have to worry about security. So, not only you gain nothing by this approach, you make your software more vulnerable. The code like `import os\n os.*killme*` or eval(__import__('os').*killme*) will be harder to disable. -- Ivan -- http://mail.python.org/mailman/listinfo/python-list
urllib2 Basic authentication, what am I doing wrong?
-BEGIN PGP SIGNED MESSAGE- Hash: SHA1 Hey everybody, I'm having a little problem with urllib2 and Basic HTTP authentication. I have the following code: auth = urllib2.HTTPPasswordMgrWithDefaultRealm() auth.add_password(None, 'https://webmail.osg-erasmus.nl/oneNet/NetStorage/', user, password) authhandler = urllib2.HTTPBasicAuthHandler(auth) opener = urllib2.build_opener(auth) opener.addheaders = [('User-agent', 'Mozilla/5.0 Something/1.0')] try: return self.opener.open('https://webmail.osg-erasmus.nl/oneNet/NetStorage/') except urllib2.HTTPError, e: print e.code print e.headers This however does not allow me to authenticate. I keep getting back a 401: 401 Date: Sun, 13 Apr 2008 18:11:32 GMT Server: Apache/2.0.54 (NETWARE) mod_perl/1.99_12 Perl/v5.8.4 PHP/5.0.5 mod_nsn/1.0_0 mod_jk/1.2.14 Set-Cookie: novellsession1=8KuAO0iLyAEAAA==; path=/ WWW-Authenticate: Basic realm=ERASMUS-TREE Vary: accept-language,accept-charset Accept-Ranges: bytes Connection: close Transfer-Encoding: chunked Content-Type: text/html; charset=iso-8859-1 Content-Language: en Using this nice class (adapted to urllib2) as a basehandler I see that no Authentication-header is being send out: http://aspn.activestate.com/ASPN/Cookbook/Python/Recipe/440574 What am I doing wrong here? I spend almost my entire free time today on this and couldn't find any problem with my code, anyone else has a thought? Thanks in advance. MFB -BEGIN PGP SIGNATURE- Version: GnuPG v1.4.7 (GNU/Linux) iD8DBQFIAkzaDpaqHmOKFdQRAh8WAJ0XbQD5EEmKxVdjndRWWzjwZzWaAgCgjdhR Esk6VBkZ+bEHsxFhg8h3Sy4= =XWrv -END PGP SIGNATURE- -- http://mail.python.org/mailman/listinfo/python-list
Re: class level properties
Peter Otten wrote: Charles D Hixson wrote: I want a hundred or so read-only variables, and I'm not sure the best way to achieve it. What do you really want to do? I recommend that you forget about bondage and rely upon displine: class Test(object): Never change an attribute with an uppercase name. SIMPLE = simple example working Now that was easy... Peter What I'm doing it translating Java code which has a large number of public static final (type) variables. As to your answer ... yes, and with good discipline you can write object oriented code in C and never need a garbage collector. It's *not* a good answer. Before I'd chose that one, I'd make it necessary to instantiate the class before testing the value of it's constants. It's just that that seems to be a silly requirement, so I'd like to avoid it. (That's the solution that I currently have working with __getattr__.) -- http://mail.python.org/mailman/listinfo/python-list
Re: Module to read input from commandline
What you're looking for is no module, it is included in the standard python namespace. raw_input Use it like this: value_a = raw_input(Please give a value for a: ) # do your thing to value_a But this belongs to the real basics, I suggest you get some reading done on python. GL -- http://mail.python.org/mailman/listinfo/python-list
Re: toplevel, get latest entry?
En Sat, 12 Apr 2008 17:50:36 -0300, [EMAIL PROTECTED] escribió: windows vista and python 2.5, is there a way to get the latest command entered? would be very useful. if not by default, anything i could download or write myself? Do you mean inside the interpreter? Use up arrow/down arrow. Type a few characters and press F8 to search for matches. F7 to select from a list. Courtesy of doskey. -- Gabriel Genellina -- http://mail.python.org/mailman/listinfo/python-list
Re: Controlling copying and pickling of objects written in C
En Sun, 13 Apr 2008 01:57:42 -0300, Adam Bregenzer [EMAIL PROTECTED] escribió: I am writing an extension and have hidden data included in the object's C structure that is not visible to python. I am unsure what would happen to that data if the python object were copied or pickled and would prefer to raise an exception whenever code tries to copy/deep copy/pickle or marshal the object since it would not make sense. Where would I look to control that? You could raise an exception in __getstate__ - that would make pickle fail, and probably copy too but I'm not sure of that. -- Gabriel Genellina -- http://mail.python.org/mailman/listinfo/python-list
Re: py2exe, program has stoped working!?
En Sun, 13 Apr 2008 10:52:06 -0300, [EMAIL PROTECTED] escribió: so i used py2exe and i have the build and the dist-folders. and when im distributing my program i have to include both catalogues right? You only have to distribute the contents of the dist directory. (I have no idea what the message error means) -- Gabriel Genellina -- http://mail.python.org/mailman/listinfo/python-list
Re: urllib2 Basic authentication, what am I doing wrong?
On Apr 13, 2:11 pm, Michel Bouwmans [EMAIL PROTECTED] wrote: Using this nice class (adapted to urllib2) as a basehandler I see that no Authentication-header is being send out:http://aspn.activestate.com/ASPN/Cookbook/Python/Recipe/440574 What am I doing wrong here? I spend almost my entire free time today on this and couldn't find any problem with my code, anyone else has a thought? Thanks in advance. MFB I've attempted to use a password manager and auth manager and failed in the past, so this is only a guess, but presumably, between the realm and uri that you are providing to the password manager, it isn't providing a password for the page you want to load. I've had success just explicitly setting the authorization header, using the method discussed in the comments on this page: http://aspn.activestate.com/ASPN/Cookbook/Python/Recipe/267197 max -- http://mail.python.org/mailman/listinfo/python-list
Re: Module to read input from commandline
On Apr 13, 7:44 pm, [EMAIL PROTECTED] wrote: What you're looking for is no module, it is included in the standard python namespace. raw_input Use it like this: value_a = raw_input(Please give a value for a: ) # do your thing to value_a But this belongs to the real basics, I suggest you get some reading done on python. GL Thanks for the response GL. What I am looking for is a module to wrap raw_input so it can handle some of the validation. e.g.) response = display_prompt( question, valid_responses, default_response ) or similar. valid_responses could be a tuple of regexp strings that would compare against a raw_input and return one in the list. Ideally I could customize the error message (for responses not in valid_response), etc. I know it isn't rocket science to write it and I have something already in place. I'd rather use a module built for the purpose now that I have several scripts that will use the functionality. Thanks! James. FYI: This is what I have so far: from re import compile def yes_no(question, default=None): Prompt the user with a yes or no question. if default == y: question = .join((question, [Y/n]: )) elif default == n: question = .join((question, [y/N]: )) else: question = .join((question, [y/n]: )) valid_answer = [yn] invalid_message = Answer must be y or n answer = prompt(question, valid_answer, invalid_message, default) return answer == 'y' def prompt(question, valid_answer, invalid_message, default=None): Prompt the user with a question and validate their response. is_valid = False; compiled_valid_answers = compile(valid_answer) while not is_valid: answer = raw_input(question).lower() if answer == and default is not None: answer = default is_valid = compiled_valid_answers.match(answer) if not is_valid: print invalid_message return answer -- http://mail.python.org/mailman/listinfo/python-list
Re: Interesting math problem
On Apr 13, 5:35 pm, Ivan Illarionov [EMAIL PROTECTED] wrote: On Mar 19, 2:17 pm, BJörn Lindqvist [EMAIL PROTECTED] wrote: On Mon, Mar 17, 2008 at 11:57 PM, Arnaud Delobelle [EMAIL PROTECTED] wrote: def make_slope(distance, parts): step = distance / float(parts) intstep = int(step) floatstep = step - intstep steps = [] acc = 0.0 for i in range(parts): acc += floatstep step = intstep if acc 0.999: step += 1 acc -= 1.0 steps.append(step) return steps OK then, using list comprehensions. It is more succint, is it easier to read? def slope(dist, parts): return [(i+1)*dist/parts - i*dist/parts for i in xrange(parts)] Congratulations! You Won! Jeff Schwab's recursive approach is also cool but this is the most interesting abuse of integer division I have seen. I don't think any of the variants are readable at a first glance, but with a comment it should be ok. -- mvh Björn I really want to revive this discussion. Arnaud's approach is definetly cool, but it turns out that in real-world situations it doesn't work as succint as here. Try to use it to draw a simple non-anitaliased line in a standrad python array or buffer object. Suppose we have an array of unsigned bytes called `buf` where each line takes `pitch` bytes. That's what I got while trying to take advantage of this approach. No advantage at all. And what about ability to port the code to C for speed? def draw_line(buf, pitch, x, y, dx, dy): if dx == dy == 0: buf[y * pitch + x] = 0 return xdir, ydir = 1, 1 if dx 0: xdir = -1 dx = abs(dx) if dy 0: ydir = -1 dy = abs(dy) if dy dx: steps = ((i+1) * dx / dy - i * dx / dy for i in xrange(dy)) for step in steps: start = y * pitch + x if xdir 0: buf[start : start + step] = array('B', [0] * step) else: buf[start - step : start] = array('B', [0] * step) x += step * xdir y += ydir else: steps = ((i+1) * dy / dx - i * dy / dx for i in xrange(dx)) for step in steps: start = y * pitch + x if ydir 0: for i in range(start, start + pitch * step, pitch): buf[i] = 0 else: for i in range(start, start - pitch * step, -pitch): buf[i] = 0 x += xdir y += step * ydir Please, tell me that I'm wrong and it's really possible to draw lines, do scan-conversion and so on with such a cool succint constructs! -- Ivan I don't think my answer is suitable for drawing a line the way you are doing it. FWIW, this is how I would go about it (not tested): def draw_rectangle(buf, pitch, x, y, w, h): # Make a mask for w and apply it across h lines def draw_line(buf, pitch, x, y, w, h): # w and h can't be 0 if w h: limits = ((i, i*h/w) for i in xrange(1, w+1)) else: limits = ((i*w/h, i) for i in xrange(1, h+1)) dx0, dy0 = 0, 0 for dx, dy in limits: draw_rectangle(x+dx0, y+dy0, dx-dx0, dy-dy0) dx0, dy0 = dx, dy The positive thing is that it is trivial to extend draw_line so that it accepts a thickness parameter as well. -- Arnaud -- http://mail.python.org/mailman/listinfo/python-list
Re: PythonWin Print Problem.. Build 210
On Apr 13, 9:07 am, Hutch [EMAIL PROTECTED] wrote: Roger Upole [EMAIL PROTECTED] wrote in message news:[EMAIL PROTECTED] Hutch [EMAIL PROTECTED] wrote in message news:[EMAIL PROTECTED] PythonWin has been a very good ide from early version thru 2.4. All work ok on THREE of my computers with THREE different HP printers. Now comes 2.5. Every thing seems to work the same except when I want to print out a copy of the source code of my project (about 38 pages) Version 2.5 acts like it is going to print out the source code but instead prints from several 100 to over 2000 BLANK PAGES pages and no source. Attempting to print out Source on SAME equipment (computers and printers) using 2.4 (WITH NO CHANGES TO EQUIPMENT OR SOFTWARE ) results in proper print out of source. Problem has been reported via direct and SourceForge but no response. Any body else having the same problem? -- http://mail.python.org/mailman/listinfo/python-list Did you see the response to the bug report on SF ? http://sourceforge.net/tracker/index.php?func=detailaid=1907148grou... There is also some more info in this thread on the python-win32 mailing list: http://mail.python.org/pipermail/python-win32/2006-December/005397.html Roger Sorry to report after uninstalling both Python 2.5 and Pythonwin 2.5 and reinstalling.. THE PROBLEM IS STILL WITH US... Did you make the change that Roger suggested in the file view.py per the link: http://mail.python.org/pipermail/python-win32/2006-December/005397.html It has been working for me on Python 2.5. -Jesus -- http://mail.python.org/mailman/listinfo/python-list
Re: class level properties
Charles D Hixson wrote: Peter Otten wrote: Charles D Hixson wrote: I want a hundred or so read-only variables, and I'm not sure the best way to achieve it. What do you really want to do? I recommend that you forget about bondage and rely upon displine: class Test(object): Never change an attribute with an uppercase name. SIMPLE = simple example working Now that was easy... Peter What I'm doing it translating Java code which has a large number of public static final (type) variables. Ah, Java, the class is an artefact of the language then, and my example becomes SIMPLE = simple example working As to your answer ... yes, and with good discipline you can write object oriented code in C and never need a garbage collector. It's *not* a good answer. Before I'd chose that one, I'd make it necessary to Hmm, if you were to choose between a Java dialect without garbage collection or without the 'final' keyword, would you throw a coin? instantiate the class before testing the value of it's constants. It's just that that seems to be a silly requirement, so I'd like to avoid Silly or not, it keeps your code simpler, and simplicity just cannot be overvalued. it. (That's the solution that I currently have working with __getattr__.) I'm confident that after you have been coding in Python for a while the Javaisms will wither away. For now, if you feel that uppercase module-level names are too big a leap I suggest that you add a __setattr__() method that records any attempts to modify read-only attributes. That way you'll have a way to learn whether that particular safety net was a useful investment or just dead code. Peter -- http://mail.python.org/mailman/listinfo/python-list
Re: subprocess.popen function with quotes
On Mar 26, 10:33 pm, skunkwerk [EMAIL PROTECTED] wrote: On Mar 26, 8:05 am, Jeffrey Froman [EMAIL PROTECTED] wrote: skunkwerkwrote: p = subprocess.Popen(['rename','-vn','s/(.*)\.htm$/ model.html/','*.htm'],stdout=subprocess.PIPE,stderr=subprocess.PIPE) print p.communicate()[0] i change to print p.communicate()[1] in case the output is blank the first time this is the output: *.htm renamed as model.html Without shell=True, your glob characters will not be expanded. Hence, the command looks for a file actually named *.htm when I add shell=True to the subprocess command, I get the following output: Usage: rename [-v] [-n] [-f] perlexpr [filenames] Here the use of the shell may be confounding the arguments passed. Your command will probably work better if you avoid using shell=True. However, you will need to perform your own globbing: # Untested (no perl-rename here): command = ['rename','-vn', 's/(.*)\.htm$/model.html/'] files = glob.glob('*.htm') command.extend(files) p = subprocess.Popen( command, stdout=subprocess.PIPE, stderr=subprocess.PIPE, ) Jeffrey thanks Jeffrey, that worked like a charm! I'm trying to detect when the subprocess has terminated using the wait() function - but when there is an error with the call to rename (ie the file doesn't exist) rename (when run from the command line just terminates and displays the error). In the code above, though, my call to p.wait() just hangs when rename should throw an error... I've tried adding shell=True but that stops the rename from working. any ideas? thanks -- http://mail.python.org/mailman/listinfo/python-list
Re: urllib2 Basic authentication, what am I doing wrong?
Michel Bouwmans wrote: -BEGIN PGP SIGNED MESSAGE- Hash: SHA1 Hey everybody, I'm having a little problem with urllib2 and Basic HTTP authentication. I have the following code: auth = urllib2.HTTPPasswordMgrWithDefaultRealm() auth.add_password(None, 'https://webmail.osg-erasmus.nl/oneNet/NetStorage/', user, password) authhandler = urllib2.HTTPBasicAuthHandler(auth) opener = urllib2.build_opener(auth) opener.addheaders = [('User-agent', 'Mozilla/5.0 Something/1.0')] try: return self.opener.open('https://webmail.osg-erasmus.nl/oneNet/NetStorage/') except urllib2.HTTPError, e: print e.code print e.headers This however does not allow me to authenticate. I keep getting back a 401: 401 Date: Sun, 13 Apr 2008 18:11:32 GMT Server: Apache/2.0.54 (NETWARE) mod_perl/1.99_12 Perl/v5.8.4 PHP/5.0.5 mod_nsn/1.0_0 mod_jk/1.2.14 Set-Cookie: novellsession1=8KuAO0iLyAEAAA==; path=/ WWW-Authenticate: Basic realm=ERASMUS-TREE Vary: accept-language,accept-charset Accept-Ranges: bytes Connection: close Transfer-Encoding: chunked Content-Type: text/html; charset=iso-8859-1 Content-Language: en Using this nice class (adapted to urllib2) as a basehandler I see that no Authentication-header is being send out: http://aspn.activestate.com/ASPN/Cookbook/Python/Recipe/440574 What am I doing wrong here? I spend almost my entire free time today on this and couldn't find any problem with my code, anyone else has a thought? Thanks in advance. Can you get something like the following to work: import urllib2 pword_manager = urllib2.HTTPPasswordMgrWithDefaultRealm() pword_manager.add_password(None, 'http://localhost/ pwordProtectedStuff/', 'jane', 'janes_password') authentication_handler = urllib2.HTTPBasicAuthHandler(pword_manager) my_custom_urlopen_function = urllib2.build_opener(authentication_handler) urllib2.install_opener(my_custom_urlopen_function) f = urllib2.urlopen('http://localhost/pwordProtectedStuff/test.htm') print f.read() -- http://mail.python.org/mailman/listinfo/python-list
A Fixed Tk Text widget
I have just completed and uploaded to the Tkinter wiki a Fixed version of the Tk Text widget called EnhancedText. This new widget (subclassed from Text) is intended to fix some of the quirks of the Text widget involving cursor movement. Namely, in Text, the cursor moves by paragraph rather than display-line when using the Up and Down arrow keys and it jumps to the beginning and end of a paragraph when using the 'Home' and 'End' keys. EnhancedText rewrites all the event handling of the Text widget. With EnhancedText, Up, Down, Home and End now move according to display lines rather than Paragraphs. This widget can be found here http://tkinter.unpythonic.net/wiki/EnhancedText. Thanks for any comments, bug reports, etc. Ron Longo-- http://mail.python.org/mailman/listinfo/python-list
Re: urllib2 Basic authentication, what am I doing wrong?
-BEGIN PGP SIGNED MESSAGE- Hash: SHA1 Max Erickson wrote: On Apr 13, 2:11 pm, Michel Bouwmans [EMAIL PROTECTED] wrote: Using this nice class (adapted to urllib2) as a basehandler I see that no Authentication-header is being send out:http://aspn.activestate.com/ASPN/Cookbook/Python/Recipe/440574 What am I doing wrong here? I spend almost my entire free time today on this and couldn't find any problem with my code, anyone else has a thought? Thanks in advance. MFB I've attempted to use a password manager and auth manager and failed in the past, so this is only a guess, but presumably, between the realm and uri that you are providing to the password manager, it isn't providing a password for the page you want to load. I've had success just explicitly setting the authorization header, using the method discussed in the comments on this page: http://aspn.activestate.com/ASPN/Cookbook/Python/Recipe/267197 max Thanks for that tip. I tried that and found out that I was still being rejected eventhough the correct Authorization was being send. I then experimented a bit with liveHTTPheaders and it's replay function in firefox and found out that it needed the cookie to succesfully authenticate. I'll try to fix it with that knowledge. Strange software I'm dealing with here, that's for sure. MFB -BEGIN PGP SIGNATURE- Version: GnuPG v1.4.7 (GNU/Linux) iD8DBQFIAovCDpaqHmOKFdQRAuHXAJ9vGNdR2e8s8iA0Z5zIzxASjES3LgCfbVSU 339iu5iO1rv1Ufh0xNntNeY= =2xbX -END PGP SIGNATURE- -- http://mail.python.org/mailman/listinfo/python-list
Re: email module windows and suse
Lev Elbert [EMAIL PROTECTED] wrote: I have to make a custom email module, based on the standard one. The custom module has to be able to work with extremely large mails (1GB +), having memory footprint much smaller. Then you have a design problem right from the start. It is extremely rare to find a mail server today that will transmit email messages larger than a few dozen megabytes. Even on a 100 megabit network, it's takes a minute and a half for a 1GB message to go from the server to the user's workstation. What are you really trying to do here? In most cases, you would be better off storing your attachments on a web server and transmitting links in the email. The modified program has to work in SUSE environment, while the development is done under Windows. I'm not too good with linux and do not know if speedup in Windows translates one-to-one into speedup in SUSE. For example, if the bottleneck is IO, in windows I can spawn a separate thread or 2 to do read-ahead. We would need more information on your processing to advise you on this. Disk I/O is slow, network I/O is slower. You can't go any faster than your slowest link. Are threads available and as effective in SUSE as they are in Windows? Threads are available in Linux. There is considerable debate over the relative performace improvement. -- Tim Roberts, [EMAIL PROTECTED] Providenza Boekelheide, Inc. -- http://mail.python.org/mailman/listinfo/python-list
Re: Controlling copying and pickling of objects written in C
On Sun, 13 Apr 2008 16:49:51 -0300, Gabriel Genellina wrote: En Sun, 13 Apr 2008 01:57:42 -0300, Adam Bregenzer [EMAIL PROTECTED] escribió: I am writing an extension and have hidden data included in the object's C structure that is not visible to python. I am unsure what would happen to that data if the python object were copied or pickled and would prefer to raise an exception whenever code tries to copy/deep copy/pickle or marshal the object since it would not make sense. Where would I look to control that? You could raise an exception in __getstate__ - that would make pickle fail, and probably copy too but I'm not sure of that. Thank you for pointing me in the right direction. Implementing __getstate__ does trigger the exception for copy, however I seem to get the most helpful error messages by implementing __reduce__ and __getstate__ with a reduce related exception message and implementing __copy__ with a copy related exception message. Final question: What is the best exception to use. I am using NotImplementedError since it is deliberately not implemented. Is that correct or would a TypeError exception be more appropriate? Thanks, Adam -- http://mail.python.org/mailman/listinfo/python-list
Re: py2exe, program has stoped working!?
On Apr 13, 11:52 pm, [EMAIL PROTECTED] wrote: so i used py2exe and i have the build and the dist-folders. in the distfolder there is a Calculator.exe file. when i run it it just says Calculator.exe has stopped working in a popup but the program itself never shows up. Is it a console program or a gui program? What happens when you run it without py2exe? Have you searched for has stopped working in (a) your source code (b) the py2exe source code? Have you managed to get any py2exe-created program to run properly? -- http://mail.python.org/mailman/listinfo/python-list
Re: email module windows and suse
On Apr 13, 3:55 pm, Tim Roberts [EMAIL PROTECTED] wrote: Lev Elbert [EMAIL PROTECTED] wrote: I have to make a custom email module, based on the standard one. The custom module has to be able to work with extremely large mails (1GB +), having memory footprint much smaller. Then you have a design problem right from the start. It is extremely rare to find a mail server today that will transmit email messages larger than a few dozen megabytes. Even on a 100 megabit network, it's takes a minute and a half for a 1GB message to go from the server to the user's workstation. What are you really trying to do here? In most cases, you would be better off storing your attachments on a web server and transmitting links in the email. The modified program has to work in SUSE environment, while the development is done under Windows. I'm not too good with linux and do not know if speedup in Windows translates one-to-one into speedup in SUSE. For example, if the bottleneck is IO, in windows I can spawn a separate thread or 2 to do read-ahead. We would need more information on your processing to advise you on this. Disk I/O is slow, network I/O is slower. You can't go any faster than your slowest link. Are threads available and as effective in SUSE as they are in Windows? Threads are available in Linux. There is considerable debate over the relative performace improvement. -- Tim Roberts, [EMAIL PROTECTED] Providenza Boekelheide, Inc. Thank you. I have a 100mb mail file. I just made a very simple expiremnt the message_from_file method boils down to a loop: 1while True: 2data = fp.read(block_size) 3if not data: 4break 5feedparser.feed(data) 6 Total time is 21 seconds (lines 1-6), while processing (non IO) lines 3-5 is 20 seconds. This means, that no IO optimization would help. This also explains the following fact: changing the block_size from 8K to 1M has almost no processing time impact. Also multithreading wouldn't help. I beleive I have to change Message class (more exactly: derive another class, which would store pieces on a disk. -- http://mail.python.org/mailman/listinfo/python-list
Remove my mail, please !
Please, remove my mail in to python list. I don´t receive mails. Thank´s. Alderos. -- http://mail.python.org/mailman/listinfo/python-list
Re: Tkinter, image not appearing in function but without function
On Apr 13, 11:12 am, Marc 'BlackJack' Rintsch [EMAIL PROTECTED] wrote: On Sun, 13 Apr 2008 08:57:29 -0700, skanemupp wrote: why is the first program not working? when i click the screen the map is not appearing. the second program works. from Tkinter import * master = Tk() w = Canvas(master, width=700, height=600) w.pack(expand = YES, fill = BOTH) def mapper(): mapq = PhotoImage(file = 'C:\Users\saftarn\Desktop\world-map.gif') w.create_image(10, 10, image = mapq, anchor = NW) def key(event): print pressed, repr(event.char) def callback(event): w.focus_set() print clicked at, event.x, event.y mapper() print 'yo' square = w.create_oval(event.x-5,event.y-5,event.x+5,event.y+5, fill=black) w.bind(Key, key) w.bind(Button-1, callback) w.pack() mainloop() Python doesn't know that the Tk side still needs the image and frees the memory when `mapper()` is done and `mapq` the only name to the `PhotoImage` instance goes out of scope. Ciao, Marc 'BlackJack' Rintsch ...so you should do something like this(untested): def mapper(height, width, widget, img, position): widget.create_image(height, width, image=img, anchor=position) w = Canvas(master, width=700, height=600) w.pack(expand = YES, fill = BOTH) #Create a permanent reference to the image, i.e. the variable is not #created inside a function: my_img = PhotoImage(file = 'C:\Users\saftarn\Desktop\world-map.gif') mapper(10, 10, w, my_img, NW) -- http://mail.python.org/mailman/listinfo/python-list
Best way to update a settings file?
I'm thinking about writing a small script that will update an xml file with whatever game settings the user enters. I imagine that the user will have a single-screen GUI application with several different settings, like this: CROSSHAIRS ON LOCATION ON HEALTHBAROFF etc. These settings will somehow be toggleable with an ON/OFF button, or something. Anyway, I can think of two ways to do this: 1. After the user chooses his settings and clicks the Save button, Python reads all the settings from the GUI application and updates *every* entry in the xml file (whether it has changed or not). 2. After the user chooses his settings and clicks the Save button, Python reads all the settings from the GUI application, compares these settings to those in the xml file, and updates only the ones that have been changed. Now, #2 seems, at first glance, like the more efficient option, because you are only updating what needs to be updated, and leaving the rest alone. However, I wonder if the extra step of comparing all the settings from the user input and the xml file will end up taking longer than just simply rewriting all the settings. Probably neither method will take much longer than the other, but I'm asking more from a good design/efficiency standpoint. Which of these two methods is the better way, or is there perhaps another way I'm not thinking of? Thanks! -- http://mail.python.org/mailman/listinfo/python-list
about the ';'
I saw many python programmers add a ';' at the end of each line. As good style, should or should not we do coding with that? Thanks. -- http://mail.python.org/mailman/listinfo/python-list
Re: Best way to update a settings file?
John Salerno wrote: I'm thinking about writing a small script that will update an xml file with whatever game settings the user enters. I imagine that the user will have a single-screen GUI application with several different settings, like this: CROSSHAIRS ON LOCATION ON HEALTHBAROFF etc. These settings will somehow be toggleable with an ON/OFF button, or something. Anyway, I can think of two ways to do this: 1. After the user chooses his settings and clicks the Save button, Python reads all the settings from the GUI application and updates *every* entry in the xml file (whether it has changed or not). 2. After the user chooses his settings and clicks the Save button, Python reads all the settings from the GUI application, compares these settings to those in the xml file, and updates only the ones that have been changed. You can't write into the middle of an XML file effectively; any field that has changed length won't fit. You generally have to create a new XML file. Read this on how to replace a file with a new one, as an atomic operation: http://blogs.msdn.com/adioltean/archive/2005/12/28/507866.aspx If you really want to update files in place, use a database, like SQLite. If you find yourself rewriting big files for minor changes, switch to a database. For small files, just rewrite the whole thing. John Nagle -- http://mail.python.org/mailman/listinfo/python-list
Re: about the ';'
On Apr 13, 10:33 pm, Penny Y. [EMAIL PROTECTED] wrote: I saw many python programmers add a ';' at the end of each line. As good style, should or should not we do coding with that? That's just because their fingers are stuck in C mode. The recommended style is NOT to use unnecessary semicolons. -- http://mail.python.org/mailman/listinfo/python-list
urllib working differently when run from crontab
I've written a python script which, using urllib, and urllib2 will fetch a number of files that that I'm interested in from various websites (they're updated everyday). When I run the script from my command line everything works as intended. However, when the script is run from crontab every single url that I attempt to open gets connection refused. Has anyone ever seen anything like this? If so, what's causing it, and what can I do about it? Victor -- http://mail.python.org/mailman/listinfo/python-list
Re: about the ';'
Penny Y. [EMAIL PROTECTED] wrote in message news:[EMAIL PROTECTED] |I saw many python programmers add a ';' at the end of each line. | As good style, should or should not we do coding with that? NOO... Read PEP8 for one style guide (for new stdlib code). -- http://mail.python.org/mailman/listinfo/python-list
Host: header
Hello, I have a problem with a request url,for example, I have the code below, import httplib try: conn = httplib.HTTPConnection(192.168.1.1) conn.request(GET, /) r1 = conn.getresponse() if r1.status == 200: result = 0 except Exception: result = -1 but the server on 192.168.1.1 accept virtual host request only. That's to say, I need to specify a Host: header in the request. How to do it? thanks. -- http://mail.python.org/mailman/listinfo/python-list
Re: How is GUI programming in Python?
En Sat, 12 Apr 2008 15:38:22 -0300, Michel Bouwmans [EMAIL PROTECTED] escribió: Gabriel Genellina wrote: En Fri, 11 Apr 2008 11:31:42 -0300, Michel Bouwmans [EMAIL PROTECTED] escribió: Gabriel Genellina wrote: Another annoying thing with the Qt license is that you have to choose it at the very start of the project. You cannot developsomething using the open source license and later decide to switch to thecommercial licence and buy it. Unless you're a company with a risk of being checked forlegal software etc., you can always ignore that allthough not very legal. I just ignore Qt itself. Then you're ignorant. What do you prefer than? Yes I am. But that doesn't change the fact that I don't like Qt, I don't like Qt license, my company doesn't use Qt and probably will never use it, and what we do prefer is not your business. -- Gabriel Genellina -- http://mail.python.org/mailman/listinfo/python-list
ANN: Tobu-0.5.0
Tobu 0.5.0 is now available. Tobu is something between a freeform information organizer and a database. Changes since last version were: Added multiple undo/redo, toolbar icon for list recent; Fixed loading a previously selected item from listing, disabled closing of last remaining tab, fixed panes disappearing when dragged all the way down or up, fixed removing of favorites, changed last used tag to pop to the top of recently used tags, fixed tab key deleting tags when they are selected, set exact match in filter dropdown to highlight ahead of inexact matches, fixed replacing file name when dragged and dropped instead of appending to old filename, removed 'new copy' icon from toolbar, fixed gvim not saving changes in linux when set as external editor - see note in tutorial, fixed saved views / saved templates interfering with each other, automatic windows installer was added. Tobu's homepage is here: http://tobu.lightbird.net -- ak Tobu | http://tobu.lightbird.net/ | Freeform DB / Tagger / PIM Python-by-Example | http://pbe.lightbird.net/ | Guide to LibRef -- http://mail.python.org/mailman/listinfo/python-list
Re: Recommendation for Web Framework
On Sun, Apr 13, 2008 at 12:18 AM, James West [EMAIL PROTECTED] wrote: Let me explain my situation a bit. I've been contracted to develop an ecommerce site. It's nothing too huge but requires a lot of custom development that's not typical for your run of the mill webstore. I've got about three weeks to get the project delivered and I've written quite a bit of code already. I'd like to find some sort of tool to generate some of the repetative bits like data management (think phpMyAdmin but for Python) so I don't have to write a stupid mangement script for every single module (users, customers, inventory, etc). I know there's tools out there that will do this for ASP code with a SQL server backend, but I haven't seen anything for Python outside of the web application frameworks. Ideally, I'd like something like Ruby on Rails that would provide scaffolding support so I can bootstrap the system, so to speak. I've looked at Django, but the client is only running Apache 1.x and Python 2.3. I've given Turbo Gears a try, but couldn't get SQLObject to run (threw an error that I didn't have time to struggle with). So basically I need something with low dependencies, easy to develop in, and releatively easy to deploy. Anyone have any recommendations? I really need something on which I can ramp up quickly to get this project out of the door fast. I'm also a framework newbie, so I know there's a learning curve. Any input is appreciated, thank you. - james -- http://mail.python.org/mailman/listinfo/python-list Have you looked at http://code.google.com/p/dbsprockets/ and/or http://code.google.com/p/dbsprockets/wiki/DBMechanic ? HTH, Daniel -- http://mail.python.org/mailman/listinfo/python-list
how to remove \n in the list
hi, l=['5\n', '2\n', '7\n', '3\n', '6\n'] how to remove \n from the given list -- http://mail.python.org/mailman/listinfo/python-list
Re: Host: header
En Mon, 14 Apr 2008 01:04:40 -0300, Penny Y. [EMAIL PROTECTED] escribió: I have a problem with a request url,for example, I have the code below, import httplib try: conn = httplib.HTTPConnection(192.168.1.1) conn.request(GET, /) r1 = conn.getresponse() if r1.status == 200: result = 0 except Exception: result = -1 but the server on 192.168.1.1 accept virtual host request only. That's to say, I need to specify a Host: header in the request. How to do it? thanks. Add a `headers` parameter to the request method. See http://docs.python.org/lib/httpconnection-objects.html Something like this (untested): headers = {'Host', 'the.host.name'} conn = httplib.HTTPConnection(192.168.1.1) conn.request(GET, /, headers=headers) -- Gabriel Genellina -- http://mail.python.org/mailman/listinfo/python-list
Re: how to remove \n in the list
En Mon, 14 Apr 2008 01:41:55 -0300, reetesh nigam [EMAIL PROTECTED] escribió: hi, l=['5\n', '2\n', '7\n', '3\n', '6\n'] how to remove \n from the given list l is is very poor name... I'll use lines instead: lines[:] = [line.rstrip('\n') for line in lines] -- Gabriel Genellina -- http://mail.python.org/mailman/listinfo/python-list
Re: urllib working differently when run from crontab
On Apr 13, 8:50 pm, VictorMiller [EMAIL PROTECTED] wrote: I've written a python script which, using urllib, and urllib2 will fetch a number of files that that I'm interested in from various websites (they're updated everyday). When I run the script from my command line everything works as intended. However, when the script is run from crontab every single url that I attempt to open gets connection refused. Has anyone ever seen anything like this? If so, what's causing it, and what can I do about it? Try su'ing as the user and running the scripts. Maybe that will shed some light on the problem. -- http://mail.python.org/mailman/listinfo/python-list
[issue1481036] IOBaseError
Armin Rigo [EMAIL PROTECTED] added the comment: This will break many existing applications, no? I can easily think of examples of reasonable code that would no longer work as intended. What's even worse, breakage might only show up in exceptional cases and give obscure results (e.g. reporting the wrong problem to the user). -- nosy: +arigo _ Tracker [EMAIL PROTECTED] http://bugs.python.org/issue1481036 _ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue2530] Document IO module
Georg Brandl [EMAIL PROTECTED] added the comment: Should be fixed now with the latest Sphinx revision. __ Tracker [EMAIL PROTECTED] http://bugs.python.org/issue2530 __ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue992389] attribute error after non-from import
Torsten Bronger [EMAIL PROTECTED] added the comment: I dare to make a follow-up although I have no idea at all about the internal processes in the Python interpreter. But I've experimented with circular imports a lot recently. Just two points: First, I think that circular imports don't necessarily exhibit a sub-opimal programming style. I had a large parser module which I just wanted to split in order to get handy file sizes. However, the parser parses human documents, and layout element A defined in module A may contain element B from module B and vice versa. In a language with declarations, you just include a big header file but in Python, you end up with circular imports. Or, you must stay with large files. So, while I think that this clean error message Nick suggests is a good provisional solution, it should not make the impression that the circular import is a flaw by itself. And secondly, the problem with modules that are not yet populated with objects is how circular imports have worked in Python anyway. You can easily cope with it by not referencing the imported module's objects in the top-level code of the importing module (but only in functions and methods). Tracker [EMAIL PROTECTED] http://bugs.python.org/issue992389 ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue2624] swig support in distutils should use the build and temp dirs
Kjell Braden [EMAIL PROTECTED] added the comment: Note that the language specific files can't be handled via py_modules because this is processed before their generation. __ Tracker [EMAIL PROTECTED] http://bugs.python.org/issue2624 __ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue2620] Multiple buffer overflows in unicode processing
Marc-Andre Lemburg [EMAIL PROTECTED] added the comment: On 32-bit platforms, it's probably best to add a size check. I don't it's worth doing that on 64-bit platforms - overflows are rather unlikely there. __ Tracker [EMAIL PROTECTED] http://bugs.python.org/issue2620 __ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue1481036] IOBaseError
Benjamin Peterson [EMAIL PROTECTED] added the comment: Py3k then? -- versions: +Python 3.0 -Python 2.6 _ Tracker [EMAIL PROTECTED] http://bugs.python.org/issue1481036 _ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue2530] Document IO module
Benjamin Peterson [EMAIL PROTECTED] added the comment: And I have fleshed out the doc strings and backported it to 2.6. __ Tracker [EMAIL PROTECTED] http://bugs.python.org/issue2530 __ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue1751] Fast BytesIO implementation + misc changes
Christian Heimes [EMAIL PROTECTED] added the comment: I'm going to review the patch later. How are we going to back port the stuff to 2.6? -- nosy: +tiran __ Tracker [EMAIL PROTECTED] http://bugs.python.org/issue1751 __ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue1751] Fast BytesIO implementation + misc changes
Christian Heimes [EMAIL PROTECTED] added the comment: Hey Alexandre! The latest patch doesn't apply cleanly. Please provide a new patch. __ Tracker [EMAIL PROTECTED] http://bugs.python.org/issue1751 __ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue902061] pydoc insists upon producing file: URLs
Ron Adam [EMAIL PROTECTED] added the comment: The following patch also fixes this along with other improvements. Maybe someone can review it. http://bugs.python.org/issue2001 -- nosy: +ron_adam Tracker [EMAIL PROTECTED] http://bugs.python.org/issue902061 ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue2627] mark pgen generated files
New submission from Benjamin Peterson [EMAIL PROTECTED]: This patch makes pgen note that it generated the file at the top. -- assignee: georg.brandl components: Interpreter Core files: pgen_generated.patch keywords: easy, patch messages: 65447 nosy: benjamin.peterson, georg.brandl priority: low severity: normal status: open title: mark pgen generated files type: feature request versions: Python 2.6 Added file: http://bugs.python.org/file10021/pgen_generated.patch __ Tracker [EMAIL PROTECTED] http://bugs.python.org/issue2627 __ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue2627] mark pgen generated files
Georg Brandl [EMAIL PROTECTED] added the comment: Fine with me if you convert the spaces to a tab first. -- assignee: georg.brandl - benjamin.peterson __ Tracker [EMAIL PROTECTED] http://bugs.python.org/issue2627 __ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue2624] swig support in distutils should use the build and temp dirs
Changes by Kjell Braden [EMAIL PROTECTED]: Removed file: http://bugs.python.org/file10017/python_distutils+swig.patch __ Tracker [EMAIL PROTECTED] http://bugs.python.org/issue2624 __ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue2624] swig support in distutils should use the build and temp dirs
Changes by Kjell Braden [EMAIL PROTECTED]: -- components: +Distutils -Demos and Tools __ Tracker [EMAIL PROTECTED] http://bugs.python.org/issue2624 __ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue2627] mark pgen generated files
Benjamin Peterson [EMAIL PROTECTED] added the comment: Committed in r62329. -- resolution: - accepted status: open - closed __ Tracker [EMAIL PROTECTED] http://bugs.python.org/issue2627 __ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com