Question on multiple Python users in one application

2016-10-06 Thread Jolly Good Spam
within this environment. So I intend to embed CPython access in the program. The basic embedding of CPython seems straight forward. But since I have multiple users, each needs their own Python sandbox, so if they all compile programs with variable 'spam', it doesn't collide. Of course they can

py3k: datetime resolution / isoformat

2011-02-25 Thread spam
When I do: datetime.datetime.now().isoformat(' ') I get the time with the microseconds. The docs says: if microsecond is 0 -MM-DDTHH:MM:SS+HH:MM. How do I set microsecond to 0? datetime.datetime.microsecond = 0 Traceback (most recent call last): File stdin, line 1, in

py3k: converting int to bytes

2011-02-24 Thread spam
Is there a better way to convert int to bytes then going through strings: x=5 str(x).encode() Thanks. -- Yves. http://www.SollerS.ca/ http://blog.zioup.org/ --

Making Line Graphs

2011-02-18 Thread spam head
I'm looking for an easy way to display simple line graphs generated by a python program in Windows. It could be done from within the program, or I could write the information out to a file and call an external program. Either is fine. Does anybody have any recommendations for a good program

return an object of a different class

2011-02-15 Thread spam
How can I do something like this in python: #!/usr/bin/python3.1 class MyNumbers: def __init__(self, n): self.original_value = n if n = 100: self = SmallNumers(self) else: self = BigNumbers(self) class SmallNumbers: def __init__(self, n): self.size = 'small'

Re: return an object of a different class

2011-02-15 Thread spam
On 11-02-15 07:45 PM, alex23 wrote: Firstly, does MyNumbers _have_ to be a class? Or would a function acting as a class factory be sufficient? Yes it does. I didn't explain my problem, chose a terrible example. This is more what I'm trying to do: class thingy: def __init__(self,

Re: return an object of a different class

2011-02-15 Thread spam
I didn't explain my problem, chose a terrible example. This is more what I'm trying to do: class thingy: def __init__(self, athingy): self.basic_extract() if self.typeof = A .../... def basic_extract(self): # complicated logic to extract data out of the thingy here

Re: return an object of a different class

2011-02-15 Thread spam
I didn't explain my problem, chose a terrible example. This is more what I'm trying to do: Basically the subclass I want to use is based on some of the data I extract from a blob of data. If I use a function to extract the data before I create the objects, then I need to do a bunch of

Re: email.encoders.encode_base64 creates one line only

2011-02-10 Thread spam
This is with python 3.1.2 (r312:79147). I have not tried with 2.7. When I create an attachment with email.mime.image.MIMEImage, by default it uses email.encoders.encode_base64 for the encoder, but that results in a single line base64 string, instead of the recommended multiple 76-chars lines.

email.encoders.encode_base64 creates one line only

2011-02-06 Thread spam
This is with python 3.1.2 (r312:79147). I have not tried with 2.7. When I create an attachment with email.mime.image.MIMEImage, by default it uses email.encoders.encode_base64 for the encoder, but that results in a single line base64 string, instead of the recommended multiple 76-chars lines.

pyqt drop to open a file

2009-03-27 Thread rui . li . spam
Hi, anyone can give a simple example or a link on how to use 'drop' with pyqt. what I'm looking for is drop a file to main widget then program get the path\filename something like: main_widget set to accept 'drop event', set filename when 'drop event happens' then the filename is path\filename

Re: How can I know how much to read from a subprocess

2007-09-18 Thread spam . noam
On Sep 18, 1:48 pm, A.T.Hofkamp [EMAIL PROTECTED] wrote: On 2007-09-17, [EMAIL PROTECTED] [EMAIL PROTECTED] wrote: It seems that another solution is gobject.io_add_watch, but I don't see how it tells me how much I can read from the file - if I don't know that, I won't know the argument to

How can I know how much to read from a subprocess

2007-09-17 Thread spam . noam
Hello, I want to write a terminal program in pygtk. It will run a subprocess, display everything it writes in its standard output and standard error, and let the user write text into its standard input. The question is, how can I know if the process wrote something to its output, and how much it

Re: How can I know how much to read from a subprocess

2007-09-17 Thread spam . noam
Ok, I could have researched this before posting, but here's an explanation how to do it with twisted: http://unpythonic.blogspot.com/2007/08/spawning-subprocess-with-pygtk-using.html It seems that another solution is gobject.io_add_watch, but I don't see how it tells me how much I can read from

TypeError: unbound method must be called with class instance 1st argument

2006-12-20 Thread void . no . spam . com
I'm a novice at Python, and found some code samples on how to use threads. My script is being run by a product that contains a Jython interpreter. Can someone please explain why I get the following error: Traceback (innermost last): File /full/path/to/file/GenerateData.py, line 104, in ?

Re: TypeError: unbound method must be called with class instance 1st argument

2006-12-20 Thread void . no . spam . com
Matimus wrote: Can someone please explain why I get the following error: The following line: threading.Thread.__init__() Should be written as: threading.Thread.__init__(self) Thank you! -- http://mail.python.org/mailman/listinfo/python-list

Re: Lead Software Engineer

2006-10-19 Thread Edward Diener No Spam
Emma wrote: Successful candidates meet the following requirements: · A burning desire to build rock-solid apps that people will be unable to live without I use to have a burning desire to cleverly answer questionnaires for companies which either don't exist or, if they do, don't tell you who

Re: Python component model

2006-10-14 Thread Edward Diener No Spam
Peter Wang wrote: Edward Diener wrote: It looks as if traits is an attempt to create a property in the component terminology which I originally specified. I will take a look at it. Traits is frighteningly similar to the requirements that you laid out in your post (the example for Skip),

Re: Python component model

2006-10-14 Thread Edward Diener No Spam
Kay Schluehr wrote: val bykoski wrote: Peter Wang wrote: Edward, This isn't in response to any specific one of the 100+ posts on this thread, but I justed wanted to encourage you to continue your investigation into Python component models and maybe looking for some common ground between

Re: Python component model

2006-10-10 Thread Edward Diener No Spam
Nick Vatamaniuc wrote: Edward Diener No Spam wrote: Michael wrote: Python does not _need_ a component model just as you don't _need_ a RAD IDE tool to write Python code. The reason for having a component model or a RAD IDE tool is to avoid writing a lot of boiler plate code. Python

Re: Python component model

2006-10-10 Thread Edward Diener No Spam
Paul Rubin wrote: Nick Vatamaniuc [EMAIL PROTECTED] writes: Python does not _need_ a component model just as you don't _need_ a RAD IDE tool to write Python code. The reason for having a component model or a RAD IDE tool is to avoid writing a lot of boiler plate code. It's also so that

Re: Python component model

2006-10-10 Thread Edward Diener No Spam
Diez B. Roggisch wrote: Paul Rubin schrieb: Nick Vatamaniuc [EMAIL PROTECTED] writes: Python does not _need_ a component model just as you don't _need_ a RAD IDE tool to write Python code. The reason for having a component model or a RAD IDE tool is to avoid writing a lot of boiler plate

Re: Python component model

2006-10-10 Thread Edward Diener No Spam
Steve Holden wrote: Diez B. Roggisch wrote: [...] Just the same, one can use IronPython to call components written in other languages. And, I believe, vice versa. Sure, as I can do it in jython. But the key point is: can your ordinary python-object be published as a component? At least for

Re: Python component model

2006-10-10 Thread Edward Diener No Spam
Fredrik Lundh wrote: Nick Vatamaniuc wrote: At the same time one could claim that Python already has certain policies that makes it seem as if it has a component model. every Python object surely qualifies as a component, for any non-myopic definition of that word, and everything inside

Re: Python component model

2006-10-10 Thread Edward Diener No Spam
Michael Sparks wrote: Edward Diener No Spam wrote: Michael wrote: Edward Diener No Spam wrote: Has there ever been, or is there presently anybody, in the Python developer community who sees the same need and is working toward that goal of a common component model in Python, blessed

Re: Python component model

2006-10-10 Thread Edward Diener No Spam
Richard Brodie wrote: Edward Diener No Spam [EMAIL PROTECTED] wrote in message news:[EMAIL PROTECTED] Thinking in Java or C++ as opposed to Python does not mean anything to me as a general statement. I am well aware of the difference between statically and dynamically typed languages

Re: Python component model

2006-10-10 Thread Edward Diener No Spam
Fredrik Lundh wrote: Edward Diener No Spam wrote: A RAD IDE tool to hook up components into an application or library ( module in Python ) has nothing to do with terseness and everything to do with ease of programming. python already has excellent and ridiculously easy-to-program ways

Re: Python component model

2006-10-10 Thread Edward Diener No Spam
Diez B. Roggisch wrote: While I understand dynamic typing, I still think it is possible to create attributes in a Python component model which could tell a RAD tool what type the attribute will encompass for the purpose of properties and events. Obviously a name, type tuple, among other

Re: Python component model

2006-10-10 Thread Edward Diener No Spam
Tim Chase wrote: There's no doubt that Python's excellent introspection mechanism allows an outside RAD-like tool to inspect the workings of any Python object. But that does not make it a component model in my original use of the term on this thread. A RAD tool needs to know what properties

Re: Python component model

2006-10-10 Thread Edward Diener No Spam
Fredrik Lundh wrote: Edward Diener No Spam wrote: There's no doubt that Python's excellent introspection mechanism allows an outside RAD-like tool to inspect the workings of any Python object. But that does not make it a component model in my original use of the term on this thread. A RAD

Re: Python component model

2006-10-10 Thread Edward Diener No Spam
Paul Boddie wrote: [EMAIL PROTECTED] wrote: Edward My OP was just to query whether a component model existed for Edward Python, like JavaBeans for Java or .Net for C#, C++/CLI Edward etc. For those of us who've never used Java, .Net or C++/CLI, a more concrete description of what you were

Re: Python component model

2006-10-10 Thread Edward Diener No Spam
fumanchu wrote: Edward Diener No Spam wrote: OK, here is my idea of what such a component model envisages as a list of items. After this, unless I get some intelligent comments from people who might be interested in what I envision, or something very similar, I will be off to investigate

Re: Python component model

2006-10-10 Thread Edward Diener No Spam
Kay Schluehr wrote: fumanchu wrote: 4) Custom property and component editors: A component editor can present a property editor or an editor for an entire component which the visual design-time RAD environment can use to allow the programmer end-user of the component to set or get component

Re: Python component model

2006-10-10 Thread Edward Diener No Spam
Fredrik Lundh wrote: fumanchu wrote: 4) Custom property and component editors: A component editor can present a property editor or an editor for an entire component which the visual design-time RAD environment can use to allow the programmer end-user of the component to set or get component

Python component model

2006-10-09 Thread Edward Diener No Spam
The definition of a component model I use below is a class which allows properties, methods, and events in a structured way which can be recognized, usually through some form of introspection outside of that class. This structured way allows visual tools to host components, and allows

Re: Python component model

2006-10-09 Thread Edward Diener No Spam
[EMAIL PROTECTED] wrote: Edward The definition of a component model I use below is a class which Edward allows properties, methods, and events in a structured way which Edward can be recognized, usually through some form of introspection Edward outside of that class. This

Re: Python component model

2006-10-09 Thread Edward Diener No Spam
Echo wrote: On 10/9/06, Edward Diener No Spam [EMAIL PROTECTED] wrote: The definition of a component model I use below is a class which allows properties, methods, and events in a structured way which can be recognized, usually through some form of introspection outside of that class

Re: Python component model

2006-10-09 Thread Edward Diener No Spam
Chaz Ginger wrote: Edward Diener No Spam wrote: [EMAIL PROTECTED] wrote: Edward The definition of a component model I use below is a class which Edward allows properties, methods, and events in a structured way which Edward can be recognized, usually through some form

Re: Python component model

2006-10-09 Thread Edward Diener No Spam
Robert Kern wrote: Edward Diener No Spam wrote: There's nothing wrong with Python's introspection. In fact Python's facilities in this area and its support for metadata are stronger than any of these other languages ! However there is no common component model which specifies that X

Re: Python component model

2006-10-09 Thread Edward Diener No Spam
goon wrote: or IBM's Eclipse for Java Or Eclipse for Python using PyDev? [0] Those are very nice features but there is no re-usable Python bean support like there is a Java bean. That was my initial point. -- http://mail.python.org/mailman/listinfo/python-list

Re: Python component model

2006-10-09 Thread Edward Diener No Spam
Michael wrote: Edward Diener No Spam wrote: Has there ever been, or is there presently anybody, in the Python developer community who sees the same need and is working toward that goal of a common component model in Python, blessed and encouraged by those who maintain the Python language

ANN: byteplay - a bytecode assembler/disassembler

2006-08-15 Thread spam . noam
Hello, I would like to present a module that I have wrote, called byteplay. It's a Python bytecode assembler/disassembler, which means that you can take Python code object, disassemble them into equivalent objects which are easy to play with, play with them, and then assemble a new, modified,

Re: Allowing zero-dimensional subscripts

2006-06-10 Thread spam . noam
George Sakkis wrote: [EMAIL PROTECTED] wrote: However, I'm designing another library for managing multi-dimensional arrays of data. Its purpose is similiar to that of a spreadsheet - analyze data and preserve the relations between a source of a calculation and its destination. Sounds

Re: Allowing zero-dimensional subscripts

2006-06-09 Thread spam . noam
Hello, Sybren Stuvel wrote: I think it's ugly to begin with. In math, one would write simply 'x' to denote an unsubscribed (ubsubscripted?) 'x'. And another point, why would one call __getitem__ without an item to call? I think that in this case, mathematical notation is different from python

Re: Allowing zero-dimensional subscripts

2006-06-09 Thread spam . noam
Hello, Fredrik Lundh wrote: (but should it really result in an empty tuple? wouldn't None be a bit more Pythonic?) I don't think it would. First of all, x[()] already has the desired meaning in numpy. But I think it's the right thing - if you think of what's inside the brackets as a list of

Re: Allowing zero-dimensional subscripts

2006-06-09 Thread spam . noam
Hello, Following Fredrik's suggestion, I wrote a pre-PEP. It's available on the wiki, at http://wiki.python.org/moin/EmptySubscriptListPEP and I also copied it to this message. Have a good day, Noam PEP: XXX Title: Allow Empty Subscript List Without Parentheses Version: $Revision$

Allowing zero-dimensional subscripts

2006-06-08 Thread spam . noam
Hello, I discovered that I needed a small change to the Python grammar. I would like to hear what you think about it. In two lines: Currently, the expression x[] is a syntax error. I suggest that it will be evaluated like x[()], just as x[a, b] is evaluated like x[(a, b)] right now. In a few

Re: Allowing zero-dimensional subscripts

2006-06-08 Thread spam . noam
Hello, Terry Reedy wrote: In a few more words: Currently, an object can be subscripted by a few elements, separated by commas. It is evaluated as if the object was subscripted by a tuple containing those elements. It is not 'as if'. 'a,b' *is* a tuple and the object *is* subcripted by a

Re: Allowing zero-dimensional subscripts

2006-06-08 Thread spam . noam
Hello, Terry Reedy wrote: So I do not see any point or usefulness in saying that a tuple subcript is not what it is. I know that a tuple is *constructed*. The question is, is this, conceptually, the feature that allows you to ommit the parentheses of a tuple in some cases. If we see this as

Re: Getting HTTP responses - a python linkchecking script.

2006-05-08 Thread p-d-p=pas-de-spam
[EMAIL PROTECTED] a écrit : Hi Folks, I'm thinking about writing a script that can be run over a whole site and produce a report about broken links etc... I've been playing with the urllib2 and httplib modules as a starting point and have found that with urllib2 it doesn't seem possible

audio on os x using python, mad, ao

2006-05-03 Thread apa7hy . spam
this message was originally posted by someone else and closed without a proper answer. i'm reposting it in hopes that someone will provide a solution. Begin Quote: I'm attempting to play an mp3 file on OSX, but am running into some difficulty. When using py-mad and py-ao, I only get static

Re: Why keep identity-based equality comparison?

2006-01-10 Thread spam . noam
Can you provide a case where having a test for equality throw an exception is actually useful? Yes. It will be useful because: 1. The bug of not finding a key in a dict because it was implicitly hashed by identity and not by value, would not have happened. 2. You wouldn't get the weird

Re: Why keep identity-based equality comparison?

2006-01-10 Thread spam . noam
It seems to me that both Mike's and Fuzzyman's objections were that sometimes you want the current behaviour, of saying that two objects are equal if they are: 1. the same object or 2. have the same value (when it's meaningful). In both cases this can be accomplished pretty easily: You can do it

Why keep identity-based equality comparison?

2006-01-09 Thread spam . noam
Hello, Guido has decided, in python-dev, that in Py3K the id-based order comparisons will be dropped. This means that, for example, {} [] will raise a TypeError instead of the current behaviour, which is returning a value which is, really, id({}) id([]). He also said that default equality

Convention for C functions success/failure

2005-12-03 Thread spam . noam
Hello, What is the convention for writing C functions which don't return a value, but can fail? If I understand correctly, 1. PyArg_ParseTuple returns 0 on failure and 1 on success. 2. PySet_Add returns -1 on failure and 0 on success. Am I correct? What should I do with new C functions that I

Re: Python 2.4 | 7.3 The for statement

2005-03-22 Thread he . dicho . que . no . quiero . spam
brainsucker wrote: Python 2.4 | 7.3 The for statement: --- for_stmt ::= for target_list in expression_list : suite [else : suite] New for statement: -- for_stmt ::= for target_list in expression_list [ and expression ] : suite