Re: Clearing the keyboard buffer (wxPython)

2009-02-11 Thread Antoine De Groote
yes, the server seems to have been down :-( MarcusD wrote: > Whow. Thanks for the fast and comprehensive answer. To be honest I would > have posted to wxpython.org but the server seems to be down for the last > couple of days. > > I'll check this wx.Yield thing that I never heard of. And let's

Re: Guido's new method definition idea

2008-12-06 Thread Antoine De Groote
try this: >>> import this and look at the 15th line... I agree that for newcomers to Python, the class method definition might seem strange. I certainly had problems with it when starting with Python, coming from Java. But in the meantime it feels right. I don't know if it is because I'm used to

Re: Guido's new method definition idea

2008-12-06 Thread Antoine De Groote
Allowing "$" as a substitute for "self" wouldn't require this new syntax. class C: def method($, arg): $.value = arg I'm strongly against this. This looks ugly and reminds me of Perl and Ruby. (I don't have anything against these languages, but there's a reason I use Python). Russ P

Re: Guido's new method definition idea

2008-12-06 Thread Antoine De Groote
[EMAIL PROTECTED] wrote: > Antoine De Groote: >> Allowing "$" as a substitute for "self" wouldn't require this new syntax. >> class C: >> def method($, arg): >> $.value = arg > > I think this (that is just sugar) may

Re: Guido's new method definition idea

2008-12-06 Thread Antoine De Groote
Aaron Brady wrote: > On Dec 5, 8:21 pm, "Daniel Fetchinson" <[EMAIL PROTECTED]> > wrote: >> Hi folks, >> >> The story of the explicit self in method definitions has been >> discussed to death and we all know it will stay. However, Guido >> himself acknowledged that an alternative syntax makes per

Re: Guido's new method definition idea

2008-12-06 Thread Antoine De Groote
Russ P. wrote: > On Dec 6, 1:02 am, Antoine De Groote <[EMAIL PROTECTED]> wrote: >> Allowing "$" as a substitute for "self" wouldn't require this new syntax. >> >> class C: >> def method($, arg): >> $.value = arg >>

Re: Guido's new method definition idea

2008-12-07 Thread Antoine De Groote
Bruno Desthuilliers wrote: > Daniel Fetchinson a écrit : > (snip) >> It doesn't add anything but makes something that exists a bit clearer > > Err... I fail to see how magically transforming def self.foo(...) into > def foo(self, ...) makes anything clearer about what really happens and > how Py

Re: Guido's new method definition idea

2008-12-09 Thread Antoine De Groote
[EMAIL PROTECTED] wrote: > On Dec 6, 4:15 pm, Carl Banks <[EMAIL PROTECTED]> wrote: [...] > > This brings up another question, what would one use when referencing > method names inside the class definition?: > > class C: > def self.method(arg): > self.value = arg > def self.othe

primera

2008-12-09 Thread Antoine De Groote
zalli, du spills jo net mat am volley oder? mengs de du kinns dann mat mengem auto an den MCM an eventuell op sandweiler fueren? well méindes ass volley, densdes fussball, an mettwochs ass schon hellejen owend... nuecht antoine -- http://mail.python.org/mailman/listinfo/python-list

Re: primera

2008-12-09 Thread Antoine De Groote
Oops, sorry, this message was not intended for the group. Apologies Antoine De Groote wrote: > zalli, > > du spills jo net mat am volley oder? mengs de du kinns dann mat mengem > auto an den MCM an eventuell op sandweiler fueren? well méindes ass > volley, densdes fussball, a

Re: Removing None objects from a sequence

2008-12-12 Thread Vito De Tullio
Filip Gruszczyński wrote: > I checked itertools, but the only thing that > seemed ok, was ifilter - this requires seperate function though, so > doesn't seem too short. is this too much long? >>> from itertools import ifilter >>> for element in ifilter(lambda x: x is not None, [0,1,2,None,3,Non

pylab.ylabel: put label on the other side

2008-12-15 Thread Antoine De Groote
Hey everybody, I'm plotting graphs with 2 y-axes, which I created using ax_left = pylab.subplot(111) ax_right = pylab.twinx() Then I switch the sides of the ticks: ax_left.yaxis.tick_right() ax_right.yaxis.tick_left() This works, the ticks are on the opposite sides (left axis ticks are on the

Initializing GHC from Python

2008-12-27 Thread Ron de Bruijn
Hi, We have just published a small article on how one can initialize GHC from Python, with only optional use of C. You can read it at http://gamr7.com/blog/?p=65 . Best regards, Ron de Bruijn -- http://mail.python.org/mailman/listinfo/python-list

Cookielib in Jython

2008-10-06 Thread Felipe De Bene
Hi There, I'm trying to run an App I wrote in Python 2.5.2 in Jython 2.2.1 and everything works fine except when I try to import the Standard CPython's cookielib. I know this may sound stupid, I could use an advice here on what's wrong. Thanks in advance, Felipe. Output: Jython 2.2.1 on java1.6.0_

Re: Cookielib in Jython

2008-10-06 Thread Felipe De Bene
On Oct 6, 10:36 am, [EMAIL PROTECTED] wrote: > On 6 Ott, 13:19, Felipe De Bene <[EMAIL PROTECTED]> wrote: > > > > > Hi There, > > I'm trying to run an App I wrote in Python 2.5.2 in Jython 2.2.1 and > > everything works fine except when I try to import the

Re: Unit Testing: a couple of questions

2008-10-28 Thread Antoine De Groote
I'm wondering if don't want your class to look something like this: class myClass(): def __init__(self, data): self.__data = data def getData(self): return self.__data def setData(self, data): self.__data = data For the rest I'll let the experts argue, I don

HTML File Parsing

2008-10-28 Thread Felipe De Bene
I'm having problems parsing an HTML file with the following syntax : User ID NameDate and so on whenever I feed the parser with such file I get the error : Traceback (most recent call last): File "C:\Documents and Settings\Administrator\My Documents\workspace \thread\src\parser.py

Re: HTML File Parsing

2008-10-30 Thread Felipe De Bene
On Oct 28, 6:18 pm, Stefan Behnel <[EMAIL PROTECTED]> wrote: > Felipe De Bene wrote: > > I'm having problems parsing anHTMLfile with the following syntax : > > > > > User ID > > Name > BGCOLOR='#c0c0c0'>Date > > and so on

Re: Does Python mess with CRLFs?

2008-11-12 Thread Irmen de Jong
Gilles Ganault wrote: On Wed, 12 Nov 2008 12:04:07 +0100, Gilles Ganault <[EMAIL PROTECTED]> wrote: I wonder if Python rewrites CRLFs when reading a text file with open/read? For those seeing the same thing, the answer is yes: On Windows, the code above turns CRLF into LF. I tried "rb" instea

Re: Does Python mess with CRLFs?

2008-11-12 Thread Irmen de Jong
Gilles Ganault wrote: Hello I'm stuck at understanding why Python can't extract some bit from an HTML file using regexes, although I can find it just fine with UltraEdit. #BAD friends = re.compile('\r\n\r\n',re.IGNORECASE | re.MULTILINE | re.DOTALL) If you keep running into trouble and

Re: Single-instance daemons

2008-11-12 Thread Irmen de Jong
Jeffrey Barish wrote: Nice. One thing: how do I get the uid and gid for the target user? In general, I know the name of the target user, but the uid/gid assigned by the OS to that user could be different on different systems. pwd.getpwnam grp.getgrnam --irmen -- http://mail.python.org/mailm

Re: Python Image Library IOError - cannot find JPEG decoder?

2009-02-25 Thread Irmen de Jong
wongobongo wrote: On Feb 24, 9:34 am, Dario Traverso wrote: I've been trying to install the Python Image Library (PIL) on my Mac OSX Leopard laptop, but have been running into some difficulties. I've built the library, using the included setup.py script. The build summary checks out ok,

Re: Why is lambda allowed as a key in a dict?

2009-03-10 Thread Vito De Tullio
MRAB wrote: > >>> (lambda arg: arg) == (lambda arg: arg) > False curious... I somehow thinked that, whereas >>> (lambda: 0) is (lambda: 0) should be False (obviously) >>> (lambda: 0) == (lambda: 0) could be True... maybe because `{} == {} and {} is not {}` (also for []) -- By ZeD -- http://

Re: How print binary data on screen

2009-03-17 Thread Irmen de Jong
Ehsen Siraj wrote: I am trying to print binary data on screen but I got the following error. f = open('/home/ehsen/1.mp3','rb') g = f.read() print g [...] UnicodeDecodeError: 'utf8' codec can't decode byte 0xff in position 0: unexpected code byte please help me how i fix this thing. One wa

Re: How complex is complex?

2009-03-20 Thread Vito De Tullio
Tim Roberts wrote: > bearophileh...@lycos.com wrote: >> >>In Python 3 those lines become shorter: >> >>for k, v in a.items(): >>{k: v+1 for k, v in a.items()} > > That's a syntax I have not seen in the 2-to-3 difference docs, so I'm not > familiar with it. How does that cause "a" to be updated?

Re: Introducing Python to others

2009-03-26 Thread Irmen de Jong
Apart from the other suggestions that have been made already, it could be very wow-provoking if you have a nice example using ctypes to interface to existing c libraries. Python shines as a glue language too :-) --irmen -- http://mail.python.org/mailman/listinfo/python-list

Re: imported module scitools not recognized

2009-03-27 Thread martine de vos
Thanks for your help and explanation. I am now able to use modules from scitools. Martine On 26 mrt, 21:39, Terry Reedy wrote: > Robert Kern wrote: > > On 2009-03-26 10:42, mgdevos wrote: > >> Hi all, > > >> I have installed thescitoolsmodule but modules included inscitools, > >> for example nu

Re: Unladen-Swallow: A faster python

2009-03-28 Thread Irmen de Jong
Tim Roberts wrote: Luis M. González wrote: This is a new project started by two Google engineers to speed up python: http://code.google.com/p/unladen-swallow/ I read this with a skeptical eye, but they have some very interesting ideas here. IronPython has certainly shown that Python can be s

Re: Bullshit Generator

2009-03-29 Thread Irmen de Jong
Pierre Denis wrote: I have written a "Bullshit Generator" script in Python (see below). It generates English sentences at random, talking about leading-edge Web-based technologies. For example it can produce simple sentences like "The interface subscriber manages the web-based online ontology."

Re: Can't get a simple TCP program to work

2009-03-29 Thread Irmen de Jong
Zach wrote: The following *extremely* simple script complains that "Socket is not connected" when I try to call recv. Could anyone provide some quick guidance? http://pastebin.com/m64317b32 replace node2.recv() by new_socket.recv() - you need to get data from the client socket that you got fro

Re: Windows command line not displaying print commands

2009-03-30 Thread Irmen de Jong
JonathanB wrote: Ok, I'm sure this is really simple, but I cannot for the life of me get any print statements from any of my python scripts to actually print when I call them from the windows command line. What am I doing wrong? hello.py: print "Hello World!" command line: E:\Python\dev>python

Re: Creating huge data in very less time.

2009-03-31 Thread Irmen de Jong
venutaurus...@gmail.com wrote: On Mar 31, 1:15 pm, Steven D'Aprano wrote: On Mon, 30 Mar 2009 22:44:41 -0700, venutaurus...@gmail.com wrote: Hello all, I've a requirement where I need to create around 1000 files under a given folder with each file size of around 1GB. The constraint

Re: Writing to Console on mac OS X

2009-03-31 Thread Irmen de Jong
RGK wrote: I'm on mac os x 10.4.11 running python 2.5.2, and Django 1.0, but this is a python question. When doing django/mod_python stuff, I can write to the Apache error_log file with sys.stderr.write("SOMETHING I WANT TO KNOW") which had me wondering if there's not a means for a misc

Re: PIL Handbooks

2009-04-02 Thread Irmen de Jong
W. eWatson wrote: I'm very new to PIL, and don't see any handbooks for 1.1.6 or the forthcoming 1.1.7. In fact, this looks like the extent of them: * Python Imaging Library Handbook for 1.1.5 (online) * Python Imaging Library Handbook for 1.1.3 (PDF) Somewhere in my recent search I see

[ANN] Pyro 3.9 released

2009-04-04 Thread Irmen de Jong
://sourceforge.net/projects/pyro Enjoy, Irmen de Jong -- http://mail.python.org/mailman/listinfo/python-list

Re: Reading 3 objects at a time from list

2009-04-11 Thread Vito De Tullio
Matteo wrote: > it works and I like slices, but I was wondering if there was another > way of doing the same thing, maybe reading the numbers in groups of > arbitrary length n... from http://docs.python.org/library/itertools.html#recipes def grouper(n, iterable, fillvalue=None): "grouper(3,

Re: Man Bites Python

2009-04-17 Thread Vito De Tullio
Mikael Olofsson wrote: > I don't think the guy in question finds it that funny. I don't think the python in question finds it that funny. -- By ZeD -- http://mail.python.org/mailman/listinfo/python-list

problem with pylint + PyQt4

2009-05-29 Thread Vito De Tullio
I'm having probles using pylint on a PyQt4 application. $ cat TEST_pylint.py import PyQt4.QtCore from PyQt4.QtGui import QApplication $ python TEST_pylint.py # no import errors $ pylint --disable-msg=C0103 --disable-msg=C0111 --disable-msg=W0611 \ > TEST_pylint.py **

Re: Best technology for agent/web server architecture

2008-05-12 Thread Irmen de Jong
authentication/encryption/... Cheers Irmen de Jong -- http://mail.python.org/mailman/listinfo/python-list

Re: Import/Create module from buffer

2008-05-12 Thread Irmen de Jong
Gruik wrote: But before that 1 question: what if I'm in Python ? Following your solution, I did that in Python : def load_buffer(buffer) : compiled_buffer = compile(buffer, "module_name", "exec") exec(compiled_buffer) It works great except that I can't have a module object

Re: How do *you* use Python in non-GUI work?

2008-05-18 Thread Irmen de Jong
ten find myself opening a Python prompt to just execute simple tasks that I see other people needing big tools or even online services for: - base-64 encoding/decoding - md5/sha hashing - simple string or regular expression operations - simple math - unicode decoding/encoding - etc etc. --irmen

Re: TPCServer and xdrlib

2008-05-19 Thread Irmen de Jong
Laszlo Nagy wrote: It is possible to change the serialization used by Pyro http://pyro.sourceforge.net/manual/9-security.html#pickle to the the 'gnosis' XML Pickler. As I said earlier, I would not use XML. Just an example - I need to be able to transfer image files, word and excel docu

Re: Newbie: Keep TCP socket open

2008-05-19 Thread Irmen de Jong
Alan Wright wrote: while (num1<=10) : s = socket.socket(socket.AF_INET, socket.SOCK_STREAM) s.settimeout(10.0) s.connect(("10.1.1.69", 50008)) # SMTP print s.recv(1024) + '\n', num1=num1+1 #s.close() sys.exit(1) I think the following is happening: Reusing the 's' object for every ne

Problem pickling exceptions in Python 2.5/2.6

2008-06-08 Thread Irmen de Jong
I'm having troubles pickling classes that extend Exception. Given the following source: class Foo(object): def __init__(self, m): self.m=m class Bar(Exception): def __init__(self, m): self.m=m import pickle s=pickle.dumps(Foo("test")) pickle.loads(s) # normal object w

Re: why can i still able to reproduce the SimpleHTTPServer bug whichis said fixed 3 years ago?

2008-06-19 Thread Irmen de Jong
Terry Reedy wrote: "Gabriel Genellina" <[EMAIL PROTECTED]> wrote in message news:[EMAIL PROTECTED] En Fri, 13 Jun 2008 04:02:48 -0300, Leo Jay <[EMAIL PROTECTED]> escribió: http://bugs.python.org/issue1097597 in my python 2.5.2, i still find these code in SimpleHTTPServer.py, is that delibe

Re: pixel colour on screen

2008-06-29 Thread Irmen de Jong
Dennis Lee Bieber wrote: On Sat, 28 Jun 2008 11:47:46 -0700 (PDT), [EMAIL PROTECTED] declaimed the following in comp.lang.python: Could anyone help me, I'm a python noob and need some help. im trying to find some code that will, given a screen co-ordinate, will give me the colour of that pixel

Re: Pyro: ProtocolError('connection failed')

2008-07-02 Thread Irmen de Jong
Diez B. Roggisch wrote: THis is just a guess - but it seems that somehow you don't bind your pyro objects to the NIC's IP address, but to localhost (127.0.0.1) - which of course won't work. That never happened to me though, try and see the pyro docs on how to prevent/control to which IP a p

Re: PIL (etc etc etc) on OS X

2008-08-01 Thread Irmen de Jong
David C. Ullrich wrote: Decided to try to install PIL on my Mac (OS X.5). I know nothing about installing programs on Linux, nothing about building C programs, nothing about installing libraries, nothing about "fink", nothing about anything. Please insert question marks after every sentence:

module for generating captcha images

2008-08-03 Thread Irmen de Jong
Hi, I wanted to generate Captcha images(*) from Python and I couldn't find any module that suited my needs so I made one myself. It only needs PIL. (I used PIL 1.1.6) It can generate images with a provided background or it can make a random background for you. It needs a truetype font to dr

Re: PIL (etc etc etc) on OS X

2008-08-04 Thread Irmen de Jong
David C. Ullrich wrote: Just as well that the message sent earlier today seems to have been lost... Ok. Read your instructions on libjpeg. Read some of the install.doc. ./configure, fine. make, fine. "make test", fine. So I said "sudo make install" and this happened: 0-1d-4f-fc-28-d:jpeg-6b du

Re: datetime from uuid1 timestamp

2008-08-13 Thread Irmen de Jong
Kent Tenney wrote: Howdy, I have not found a routine to extract usable date/time information from the 60 bit uuid1 timestamp. Is there not a standard solution? I submitted an ASPN recipe to do it. http://code.activestate.com/recipes/576420/ I'm interested in the use case for this. Why wo

Re: Receive data from socket stream

2008-04-26 Thread Irmen de Jong
[EMAIL PROTECTED] wrote: Until now, I've been doing this little trick: data = client.recv(256) new = data while len(new) == 256: new = client.recv(256) data += new Are you aware that recv() will not always return the amount of bytes asked for? (send() is similar; it doesn't guarantee t

Re: Simple question

2008-05-10 Thread Irmen de Jong
Gandalf wrote: On May 10, 2:36 pm, Bjoern Schliessmann wrote: Gandalf wrote: how can i ran script with python It depends on your web server configuration. To get your web server execute Python code, there are several alternatives like * CGI * FastCGI * mod_python Regards, Björn -- BOFH ex

Re: what does int means for python ?

2008-05-11 Thread Irmen de Jong
alefajnie wrote: #!/usr/bin/env python arr = [[0 for c in range(0, 10)] for r in range(0, 10)] # 10x10 array arr[2,3] # throws TypeError: list indices must be integers arr[int(2), int(3)] # also throws TypeError: list indices must be integers ! -

Pyro 3.8 released

2008-08-23 Thread Irmen de Jong
us version. Please check the changes chapter in the manual for details: http://pyro.sourceforge.net/manual/12-changes.html#latest Have fun, and thanks for your interest, support, and feedback! --Irmen de Jong ** What is Pyro? Pyro is an acronym for PYthon Remote Objects. Pyro is an advanced an

Re: how can i check whether a variable is iterable in my code?

2008-09-20 Thread Vito De Tullio
satoru wrote: > hi, all > i want to check if a variable is iterable like a list, how can i > implement this? untested def is_iterable(param): try: iter(param) except TypeError: return False else: return True -- By ZeD -- http://mail.python.org/mailman/listinfo/python-list

String functions: what's the difference?

2006-03-09 Thread Harro de Jong
measuring mostly overhead. I'd expect the third option to be the fastest (involves looking up 3 values, where the others have to iterate through a-z), but am I right? And reasons to prefer one? a-z doesn't contain all lowercase letters (it omits acents and symbols), but other than

Re: String functions: what's the difference?

2006-03-09 Thread Harro de Jong
.. > Have fun with python! If the few days I've spent on it so far are any indication, I will. This is my first foray into programming since college; I like 'How to Think Like a Computer Scientist' much better than my impenetrable C textbook. -- Harro de Jong remove the extra Xs from xmsnet to mail me -- http://mail.python.org/mailman/listinfo/python-list

Re: python library for web discussions

2006-03-19 Thread Irmen de Jong
Amir Michail wrote: > Hi, > > I'm building something like digg/reddit and would like to allow people > to have discussions on various items. > > Is there a simple lightweight python library that I can use (as opposed > to a heavyweight web framework)? Although not necessary, some sort of > scori

Re: Is there such an idiom?

2006-03-19 Thread Irmen de Jong
Per wrote: > how to find the number of common items between two list in linear-time? > Not really sure about linear-time, but you could try the following: >>> a=[1,2,3,4] >>> b=[3,4,5,6] >>> set(a) & set(b) set([3, 4]) --Irmen -- http://mail.python.org/mailman/listinfo/python-list

Re: Can XML-RPC performance be improved?

2006-03-21 Thread Irmen de Jong
Sion Arrowsmith wrote: > I've got an established client-server application here where there > is now a need to shovel huge amounts of data (structured as lists of > lists) between the two, and the performance bottleneck has become > the amount of time spent parsing XML Any chance of replacing the

Re: Uploading files from IE

2006-03-22 Thread Irmen de Jong
AB wrote: > All right... I already hated IE. But, now I do even more. My scripts > upload function is working in Firefox, but not in IE. If I upload a file > from Internet Explorer I get a file on the system named for the full path > from the users computer... > > example... > They user uplo

Re: How do I handle #

2006-03-24 Thread Irmen de Jong
Michael Sperlle wrote: > I need to write out a file containing the # comment. When I try to specify > it as part of a literal, everything afterward turns into a comment. > > I finally created a file containing the #, read it in, and used the > resulting variable as part of the string I created. >

Re: "definitive" source on advanced python?

2006-04-03 Thread Gabriel de Dietrich
Maybe you're looking for something like this? http://jamesthornton.com/eckel/TIPython/html/Index.htm Haven't read it yet, but seems to be about design patterns. Not the "definitive" stuff, though... -- http://mail.python.org/mailman/listinfo/python-list

malloc'ed PyTypeObject

2006-04-06 Thread Gabriel de Dietrich
Is it enough to add Py_TPFLAGS_HEAPTYPE? Can I safely free tp_getset after calling PyType_Ready()? What will the weather be for the next week-end? Thank you for reading. -- Gabriel de Dietrich -- http://mail.python.org/mailman/listinfo/python-list

Exception classes don't follow pickle protocol, problems unpickling

2009-12-06 Thread Irmen de Jong
Hi, I am puzzled why Python's exception classes don't seem to follow the pickle protocol. To be more specific: an instance of a user defined exception, subclassed from Exception, cannot be pickled/unpickled correctly in the expected way. The pickle protocol says that: __getinitargs__ is used

Pyro 3.10 released

2009-12-08 Thread Irmen de Jong
://sourceforge.net/projects/pyroor from PyPI http://pypi.python.org/pypi/Pyro/ Enjoy, Irmen de Jong -- http://mail.python.org/mailman/listinfo/python-list

Re: Exception classes don't follow pickle protocol, problems unpickling

2009-12-08 Thread Irmen de Jong
On 7-12-2009 10:12, Peter Otten wrote: So there are 2 problems: the pickle protocol isn't used when exception objects (or instances of classes derived from Exception) are pickled, and during unpickling, it then crashes because it calls __init__ with the wrong amount of parameters. (why is it bo

Re: Question about 'remote objects'

2009-12-09 Thread Irmen de Jong
On 9-12-2009 13:56, Frank Millman wrote: My first thought was to look into Pyro. It seems quite nice. One concern I had was that it creates a separate thread for each object made available by the server. It doesn't. Pyro creates a thread for every active proxy connection. You can register thous

Re: Brent's variation of a factorization algorithm

2009-12-09 Thread Irmen de Jong
On 27-11-2009 16:36, n00m wrote: Maybe someone'll make use of it: def gcd(x, y): if y == 0: return x return gcd(y, x % y) def brent(n): [...] [D:\Projects]python brentfactor.py 9 == 27 * 37037037 What gives? Isn't this thing supposed to factor numbers into the pro

Re: Brent's variation of a factorization algorithm

2009-12-10 Thread Irmen de Jong
On 12/10/09 12:52 AM, n00m wrote: On Dec 10, 1:11 am, Irmen de Jong wrote: 9 == 27 * 37037037 What gives? Isn't this thing supposed to factor numbers into the product of two primes? -irmen Only if you yield to it a SEMIprime =) A 'semiprime' being a product of 2 p

Re: Recommendation for small, fast, Python based web server

2009-12-11 Thread Irmen de Jong
On 11-12-2009 14:52, Antoine Pitrou wrote: Hello, I've looked at the web servers that come bundled with the Python standard library[1] and they are too slow. Apparently you have debugged your speed issue so I suppose you don't have performance problems anymore. Do note, however, that Python

Re: console command to get the path of a function

2009-12-20 Thread Irmen de Jong
On 12/20/2009 1:45 PM, mattia wrote: Hi all, is there a way in the python shell to list the path of a library function (in order to look at the source code?). Thanks, Mattia something like this? >>> import inspect >>> import os >>> inspect.getsourcefile(os.path.split) 'C:\\Python26\\lib\\ntpa

Re: more efficient?

2009-12-22 Thread Irmen de Jong
On 12/22/09 7:13 AM, Zubin Mithra wrote: I have the following two implementation techniques in mind. def myfunc(mystring): check = "hello, there " + mystring + "!!!" print check OR structure = ["hello, there",,"!!!"] def myfunc(mystring): structure[2] = mystring output = ''

Re: dict initialization

2009-12-22 Thread Irmen de Jong
On 22-12-2009 22:33, mattia wrote: Is there a function to initialize a dictionary? Right now I'm using: d = {x+1:[] for x in range(50)} Is there any better solution? Maybe you can use: dict.fromkeys(xrange(1,51)) but this will initialize all values to None instead of an empty list... -

detect interactivity

2009-12-29 Thread Roald de Vries
Dear all, Is it possible for a Python script to detect whether it is running interactively? It can be useful for e.g. defining functions that are only useful in interactive mode. Kind regards, Roald -- http://mail.python.org/mailman/listinfo/python-list

Re: detect interactivity

2009-12-29 Thread Roald de Vries
On Dec 29, 2009, at 8:34 PM, Dave Angel wrote: Antoine Pitrou wrote: Le Tue, 29 Dec 2009 16:09:58 +0100, Roald de Vries a écrit : Dear all, Is it possible for a Python script to detect whether it is running interactively? It can be useful for e.g. defining functions that are only useful in

Re: I think I found a bug in Python 2.6.4 (in the inspect module)

2009-12-29 Thread Irmen de Jong
On 29-12-2009 23:22, inhahe wrote: On Tue, Dec 29, 2009 at 5:11 PM, inhahe wrote: On Tue, Dec 29, 2009 at 5:10 PM, inhahe wrote: So i'm guessing that the attribute has been changed from func_code to f_code but the inspect module wasn't updated to reflect that. er i mean from f_code to fun

Re: detect interactivity

2009-12-29 Thread Roald de Vries
On Dec 30, 2009, at 1:52 AM, Steven D'Aprano wrote: On Tue, 29 Dec 2009 16:09:58 +0100, Roald de Vries wrote: Dear all, Is it possible for a Python script to detect whether it is running interactively? It can be useful for e.g. defining functions that are only useful in interactive mode.

Re: detect interactivity

2009-12-29 Thread Roald de Vries
On Dec 30, 2009, at 2:28 AM, Dave Angel wrote: Roald de Vries wrote: On Dec 29, 2009, at 8:34 PM, Dave Angel wrote: Antoine Pitrou wrote: Le Tue, 29 Dec 2009 16:09:58 +0100, Roald de Vries a écrit : Dear all, Is it possible for a Python script to detect whether it is running

Re: detect interactivity

2009-12-30 Thread Roald de Vries
On Dec 30, 2009, at 4:10 AM, Steve Holden wrote: Roald de Vries wrote: On Dec 30, 2009, at 2:28 AM, Dave Angel wrote: Roald de Vries wrote: On Dec 29, 2009, at 8:34 PM, Dave Angel wrote: Antoine Pitrou wrote: Le Tue, 29 Dec 2009 16:09:58 +0100, Roald de Vries a écrit : Dear all, Is it

Re: 24 bit signed integer binary conversion help needed

2010-01-08 Thread Irmen de Jong
On 8-1-2010 22:12, Robert Somerville wrote: hi; I am trying to read 24bit signed WAV format (little endian) data from a WAV file and convert it to 32 bit little endian integer format ... can anybody please tell me how to do the conversion from 24 bit to 32 bit with a snippet of Python code ??? T

Re: 24 bit signed integer binary conversion help needed

2010-01-08 Thread Irmen de Jong
On 8-1-2010 22:37, Grant Edwards wrote: On 2010-01-08, Irmen de Jong wrote: Are you using the standard wave module? I guess that will produce a string of 3-byte audio frames with readframes(). Won't it work to chop this up in individual 3-byte frames, then appending a '\0' char

Re: lightweight encryption of text file

2010-01-08 Thread Irmen de Jong
On 8-1-2010 22:39, Daniel Fetchinson wrote: http://www.nightsong.com/phr/crypto/p3.py Thanks a lot, currently I'm having trouble using this code on python 2.6 but probably some small tweaking will fix it. If you keep having issues with this module, maybe you can try this: http://www.fre

Re: Milliseconds in logging format

2010-01-10 Thread Irmen de Jong
On 10-1-2010 20:04, Joan Miller wrote: How the logging '%(asctime)s' [1] specifier to gets the millisecond portion of the time if there is not a directive to get it from the time module [2] ? "The date format string follows the requirements of strftime()" [1] http://docs.python.org/library/logg

Re: Symbols as parameters?

2010-01-22 Thread Roald de Vries
Hi Martin, On Jan 21, 2010, at 8:43 AM, Martin Drautzburg wrote: Hello all, When passing parameters to a function, you sometimes need a paramter which can only assume certain values, e.g. def move (direction): ... If direction can only be "up", "down", "left" or "right",

Re: Symbols as parameters?

2010-01-22 Thread Roald de Vries
On Jan 22, 2010, at 1:06 PM, Martin Drautzburg wrote: On 22 Jan., 11:56, Roald de Vries wrote: Hi Martin, On Jan 21, 2010, at 8:43 AM, Martin Drautzburg wrote: Hello all, When passing parameters to a function, you sometimes need a paramter which can only assume certain values, e.g

enumerated while loop

2010-01-23 Thread Roald de Vries
Dear all, I sometimes want to use an infinite while loop with access to the loop index, like this: def naturals(): i = 0 while True: yield i y += 1 for i in naturals(): print(i) I assume a function like 'naturals' already exists, or a similar construction for the same

Re: enumerated while loop

2010-01-23 Thread Roald de Vries
On Jan 23, 2010, at 3:50 PM, Grant Edwards wrote: On 2010-01-23, Roald de Vries wrote: Dear all, I sometimes want to use an infinite while loop with access to the loop index, like this: def naturals(): i = 0 while True: yield i y += 1 for i in naturals(): print(i

Re: enumerated while loop

2010-01-23 Thread Roald de Vries
On Jan 23, 2010, at 3:49 PM, Diez B. Roggisch wrote: Am 23.01.10 15:44, schrieb Roald de Vries: Dear all, I sometimes want to use an infinite while loop with access to the loop index, like this: def naturals(): i = 0 while True: yield i y += 1 for i in naturals(): print(i) I assume a

Re: enumerated while loop

2010-01-23 Thread Roald de Vries
On Jan 23, 2010, at 3:58 PM, Mark Dickinson wrote: On Jan 23, 2:44 pm, Roald de Vries wrote: I assume a function like 'naturals' already exists, or a similar construction for the same purpose. But what is it called? itertools.count() On Jan 23, 2010, at 4:04 PM, Jan Kalisze

Re: Python and Ruby

2010-01-27 Thread Roald de Vries
On Jan 27, 2010, at 2:01 PM, Jean Guillaume Pyraksos wrote: What are the arguments for choosing Python against Ruby for introductory programming ? Python has no provisions for tail recursion, Ruby is going to... So what ? Thanks, I think the main difference is in culture, especially for *in

Re: Symbols as parameters?

2010-01-28 Thread Roald de Vries
On Jan 22, 2010, at 11:56 AM, Roald de Vries wrote: Hi Martin, On Jan 21, 2010, at 8:43 AM, Martin Drautzburg wrote: Hello all, When passing parameters to a function, you sometimes need a paramter which can only assume certain values, e.g. def move (direction): ... If

Re: Symbols as parameters?

2010-01-29 Thread Roald de Vries
On Jan 29, 2010, at 2:30 AM, Steven D'Aprano wrote: On Thu, 28 Jan 2010 17:01:38 +0100, Roald de Vries wrote: Question out of general interest in the language: If I would want to generate such functions in a for-loop, what would I have to do? This doesn't work: class Move(object):

Re: Enormous Input and Output Test

2009-10-07 Thread Irmen de Jong
n00m wrote: numerix's solution was excelled by Steve C's one (8.78s): http://www.spoj.pl/ranks/INOUTEST/lang=PYTH I don't understand nothing. I just got my solution accepted, it ran in 14 seconds though. I have no idea how to shave more seconds off, so I think 7.5 seconds for the fastest solu

Re: Enormous Input and Output Test

2009-10-10 Thread Irmen de Jong
John Yeung wrote: P.S. I hope people realize that the concise, intuitive, readable answers we all tried in our first couple of (failed) attempts are much more Pythonic than the beasts that were created just for SPOJ. Well, it is not often that we need to micro optimize stuff (or how would you

Re: MUD Game Programmming - Python Modules in C++

2009-10-13 Thread Irmen de Jong
Christopher Lloyd wrote: Hello all, I'm new to Python and new to this list, although I've done some digging in the archives and already read up on the problem I'm about to describe. I'm a relatively inexperienced programmer, and have been learning some basic C++ and working through the demos

Re: how can i use lxml with win32com?

2009-10-25 Thread Irmen de Jong
Michiel Overtoom wrote: elca wrote: im sorry ,also im not familiar with newsgroup. It's not a newsgroup, but a mailing list. And if you're new to a certain community you're not familiar with, it's best to lurk a few days to see how it is used. Pot. Kettle. Black. comp.lang.python really i

Re: disable image loading to speed up webpage load

2009-11-04 Thread Irmen de Jong
On 4-11-2009 8:32, elca wrote: Diez B. Roggisch-2 wrote: Use urllib2. you can show me some more specific sample or demo? It's not even more than 1 click away in the Python standard lib documentation... how hard can it be? http://docs.python.org/library/urllib2.html#examples -irmen --

Re: Your impression of for-novice writings on assertions

2010-02-02 Thread Irmen de Jong
On 2-2-2010 21:54, Alf P. Steinbach wrote: I've started on ch 3 of my beginner's intro to programming, now delving into the details of the Python language. Alf, I think it's a good read so far. I just don't like the smilies that occur in the text. It's a book (or article) that I'm reading, no

<    3   4   5   6   7   8   9   10   11   12   >