Re: Code for finding the 1000th prime

2009-11-15 Thread Diez B. Roggisch
mrholtsr schrieb: I am absolutely new to python and barely past beginner in programming. Also I am not a mathematician. Can some one give me pointers for finding the 1000th. prime for a course I am taking over the internet on Introduction to Computer Science and Programming. Thanks, Ray Do you

Re: IDE for python

2009-11-15 Thread Diez B. Roggisch
Peng Yu schrieb: There had been some discussion on IDE. But I'm not sure what pros and cons of each choice. Current, I'm using vim and ctags. Could somebody give some advices on choosing the best IDE for me? http://groups.google.com/group/comp.lang.python/browse_thread/thread/4b3300d10285ae2b/e

Re: IDE for python

2009-11-15 Thread Diez B. Roggisch
Peng Yu schrieb: On Nov 15, 11:15 am, "Diez B. Roggisch" wrote: Peng Yu schrieb: There had been some discussion on IDE. But I'm not sure what pros and cons of each choice. Current, I'm using vim and ctags. Could somebody give some advices on choosing the b

Re: How to get directory of Python C library

2009-11-15 Thread Diez B. Roggisch
[email protected] schrieb: Hi I need to link against Python, is there a way to get the path to the directory containing Python's C library (e.g., /libs on Windows)? Most probably from the registry somehow. In general, try & locate a python-executable, and make it execute python -c "im

Re: How to get directory of Python C library

2009-11-15 Thread Diez B. Roggisch
[email protected] schrieb: On 15 Nov, 20:05, "Diez B. Roggisch" wrote: [email protected] schrieb: Hi I need to link against Python, is there a way to get the path to the directory containing Python's C library (e.g., /libs on Windows)? Most probably from the regis

Re: How to get directory of Python C library

2009-11-15 Thread Diez B. Roggisch
[email protected] schrieb: On 15 Nov, 21:24, "Diez B. Roggisch" wrote: [email protected] schrieb: On 15 Nov, 20:05, "Diez B. Roggisch" wrote: [email protected] schrieb: Hi I need to link against Python, is there a way to get the path to the directory

Re: How to get directory of Python C library

2009-11-15 Thread Diez B. Roggisch
[email protected] schrieb: On 15 Nov, 22:11, "Diez B. Roggisch" wrote: [email protected] schrieb: On 15 Nov, 21:24, "Diez B. Roggisch" wrote: [email protected] schrieb: On 15 Nov, 20:05, "Diez B. Roggisch" wrote: [email protected]

Re: Newsgroup for beginners

2009-11-16 Thread Diez B. Roggisch
mrholtsr wrote: > Is there a Python newsgroup for those who are strictly beginners at > programming and python? Yes, the tutor-list. http://mail.python.org/mailman/listinfo/tutor Diez -- http://mail.python.org/mailman/listinfo/python-list

Re: directory wildcard

2009-11-16 Thread Diez B. Roggisch
hong zhang schrieb: List, I try to assign value to force_mcs sitting in a wildcard subdirectory /sys/kernel/debug/ieee80211/phy*, but python does not work for that such as: os.system("echo %i > /sys/kernel/debug/ieee80211/phy*/iwlagn/data/force_mcs" % mcs) Any right way to do it? Don't use

Re: Get attribute this way

2009-11-17 Thread Diez B. Roggisch
King schrieb: "eval" can solve this problem right away but I am concerned about security issues. If not "eval" could you suggest something more efficient way. It won't be a big deal to change the format as application is still at development stage? If you don't want to use eval (which is a good

Re: ZipFile - file adding API incomplete?

2009-11-17 Thread Diez B. Roggisch
Glenn Maynard schrieb: I want to do something fairly simple: read files from one ZIP and add them to another, so I can remove and replace files. This led me to a couple things that seem to be missing from the API. The simple approach would be to open each file in the source ZIP, and hand it off

Re: SCGIServer and unusal termination

2009-11-17 Thread Diez B. Roggisch
Eden Kirin wrote: > Hi there, > > I'm playing with SCGIServer > (http://vmlinux.org/cgi-bin/dwww/usr/share/doc/python-scgi/guide.html), > everything works just fine, but one thing bothers me. All prints after > try-except block are executed twice after the Ctrl+C is pressed! > > test.py: > #

Re: Code for finding the 1000th prime

2009-11-17 Thread Diez B. Roggisch
Stefan Behnel wrote: > Robert P. J. Day, 15.11.2009 15:44: >> On Sun, 15 Nov 2009, mrholtsr wrote: >> >>> I am absolutely new to python and barely past beginner in programming. >>> Also I am not a mathematician. Can some one give me pointers for >>> finding the 1000th. prime for a course I am tak

Re: SCGIServer and unusal termination

2009-11-17 Thread Diez B. Roggisch
Eden Kirin wrote: > Diez B. Roggisch wrote: > >>> Is there some reasonable explanation for this behaviour? Thanks in >>> advance. >> >> I can only guess that SCGIServer does something to stdout. Your code >> isn't executed twice, so the doubling s

Re: IOError: [Errno 28] No space left on device

2009-11-18 Thread Diez B. Roggisch
Lie Ryan schrieb: hong zhang wrote: --- On Tue, 11/17/09, Tim Chase wrote: From: Tim Chase Subject: Re: IOError: [Errno 28] No space left on device To: "Lie Ryan" Cc: [email protected] Date: Tuesday, November 17, 2009, 7:47 PM for i in glob.glob('/sys/kernel/debug/ieee80211/phy*/iwl

Re: Inserting Unicode text with MySQLdb in Python 2.4-2.5?

2009-11-18 Thread Diez B. Roggisch
Keith Hughitt wrote: > Hi all, > > I ran into a problem recently when trying to add support for earlier > versions of Python (2.4 and 2.5) to some database related code which > uses MySQLdb, and was wondering if anyone has any suggestions. > > With later versions of Python (2.6), inserting Unico

Re: IOError: [Errno 28] No space left on device

2009-11-18 Thread Diez B. Roggisch
hong zhang wrote: > > > --- On Wed, 11/18/09, Grant Edwards wrote: > >> From: Grant Edwards >> Subject: Re: IOError: [Errno 28] No space left on device >> To: [email protected] >> Date: Wednesday, November 18, 2009, 9:22 AM >> On 2009-11-18, hong zhang >> wrote: >> >> >> Apparently the

Re: python and web pages

2009-11-20 Thread Diez B. Roggisch
Daniel Dalton schrieb: Hi, Here is my situation: I'm using the command line, as in, I'm not starting gnome or kde (I'm on linux.) I have a string of text attached to a variable,. So I need to use one of the browsers on linux, that run under the command line, eg. lynx, elinks, links, links2 and d

Re: convert a string to a regex?

2009-11-20 Thread Diez B. Roggisch
Peng Yu schrieb: On Wed, Nov 18, 2009 at 9:12 PM, Tim Chase wrote: There are many special characters listed on http://docs.python.org/library/re.html I'm wondering if there is a convenient function that can readily convert a string with the special characters to its corresponding regex. For ex

Re: hex

2009-11-20 Thread Diez B. Roggisch
hong zhang schrieb: List, I want to input hex number instead of int number. in type="int" in following, parser.add_option("-F", "--forcemcs", dest="force_mcs", type="int", default=0, help="index of 11n mcs table. Default: 0.") How can I do it? You can't. You can get a string, and convert th

Re: Is there something similar to list comprehension in dict?

2009-11-20 Thread Diez B. Roggisch
DreiJane schrieb: NB: I wondered about about dict(one=1, two=2) - why not d = {one:1, two:2} ? Since you do not write L=list((1, 2)) either. These composed because it's not working. >>> {one : 1} Traceback (most recent call last): File "", line 1, in NameError: name 'one' is not defined Y

Re: semantics of [:]

2009-11-20 Thread Diez B. Roggisch
Esmail schrieb: Could someone help confirm/clarify the semantics of the [:] operator in Python? a = range(51,55) # 1 ## b = a[:] # b receives a copy of a, but they are independent > # The following two are equivalent # 2 ## c = [

Re: Split class across multiple files

2009-11-20 Thread Diez B. Roggisch
eric.frederich schrieb: I have a class which holds a connection to a server and a bunch of services. In this class I have methods that need to work with that connection and services. Right now there are about 50 methods some of which can be quite long. From an organizational standpoint, I'd like

Re: No duplicate variable

2009-11-20 Thread Diez B. Roggisch
King schrieb: class A(object): def __init__(self, value=0.): self.value = value class B(A): def __init__(self, value=None): A.__init__(self) self.value = value obj = B() When "B" initializes, it overwrite "value" variable of "A&quo

Re: semantics of [:]

2009-11-20 Thread Diez B. Roggisch
Esmail schrieb: Diez B. Roggisch wrote: Esmail schrieb: Could someone help confirm/clarify the semantics of the [:] operator in Python? a = range(51,55) # 1 ## b = a[:] # b receives a copy of a, but they are independent > # The following two are equival

Re: parallel class structures for AST-based objects

2009-11-22 Thread Diez B. Roggisch
Steve Howell schrieb: On Nov 21, 4:07 pm, MRAB wrote: I don't see the point of EvalNode and PrettyPrintNode. Why don't you just give Integer, Sum and Product 'eval' and 'pprint' methods? That's a good question, and it's the crux of my design dilemma. If ALL I ever wanted to to with Integer/S

Re: Sorting: too different times. Why?

2009-11-22 Thread Diez B. Roggisch
randint(0, 50))] Better use .append here, looks nicer and should also be a bit faster. b = a[:] c = a[:] print 'Sorting...' t = time() b.sort(cmp=v_cmp) print time() - t t = time() c.sort() print time() - t print b == c = RESTART ==

Re: xmlrpc idea for getting around the GIL

2009-11-22 Thread Diez B. Roggisch
Daniel Fetchinson schrieb: Has anyone every tried wrapping the CPython lib into a daemon with an RPC mechanism in order to move the GIL out of the process? I have multiple audio threads, each of which use the python interpreter but don't have to interact with each other and can might as well use

Re: problem manipulating a list belonging to a class

2009-11-22 Thread Diez B. Roggisch
Marc Leconte schrieb: Dear all, I have a problem with the following code (ubuntu 8.04, Python 2.5.2): class Toto(object): def __init__(self, number, mylist=[]): self.number=number self.mylist=mylist pass pass listA=Toto(number=1)

Re: python and Postgresq

2009-11-23 Thread Diez B. Roggisch
Andy dixon wrote: > Hi, > > Does anyone have a link to, or can provide an example script for using > python-pgsql (http://pypi.python.org/pypi/python-pgsql/) or if someone can > recommend an alternative, that would be fantastic. I'd recommend psycopg2. This is an introduction: http://www.dev

Re: python and Postgresq

2009-11-23 Thread Diez B. Roggisch
Krishnakant wrote: > On Mon, 2009-11-23 at 11:22 +0100, Diez B. Roggisch wrote: >> Andy dixon wrote: >> >> > Hi, >> > >> > Does anyone have a link to, or can provide an example script for using >> > python-pgsql (http://pypi.python.org/pypi

Re: print function in python3.1

2009-11-23 Thread Diez B. Roggisch
Anjanesh Lekshminarayanan wrote: > Python 3.1.1 > > sql = "INSERT INTO `tbl` VALUES (NULL, '%s', '%s', '%s', '%s', '%s');" > for row in fp: > print (sql, (row[0],row[1],row[2],row[3],row[4])) > . > INSERT INTO `tbl` VALUES (NULL, '%s', '%s', '%s', '%s', '%s'); ('142', > 'abc', '2006-04-09 02:

Re: print function in python3.1

2009-11-23 Thread Diez B. Roggisch
Anjanesh Lekshminarayanan wrote: >> Depending on your DB-adapter, you are out of luck here. Either connect to >> a db even if you don't need it, or try & see if you can locate the >> implementation in the module somehow. > > ImportError: No module named MySQLdb > MySQLdb only available in Python2

Re: print function in python3.1

2009-11-23 Thread Diez B. Roggisch
Anjanesh Lekshminarayanan wrote: >> Maybe it would help if you explained what you are actually trying to >> accomplish. > > import csv > f = csv.reader(open('data.txt'), delimiter='\t') # 2GB text file > sql = "INSERT INTO `data` VALUES (NULL,%s,%s,%s,%s,%s);" > for row in f: > print (sql, (r

Re: [repost please help me] python setup.py build for 32-bits on x86_64 machine

2009-11-23 Thread Diez B. Roggisch
Sérgio Monteiro Basto wrote: > Hi, > I am in x86_64 arch , but I need > compile things on 32 bits with > python setup.py build > > Can't change the fact that distutils creates x86_64 > directories: > build/temp.linux-x86_64-2.3/ > > Also if I try with a python compile in 32bits and installed > i

Re: Beginning Question about Python functions, parameters...

2009-11-23 Thread Diez B. Roggisch
x27; > 103 for label, name in zip(labels, names): The zip-function takes n iterables, and produces a list with n-tuples out of it. Type this into the python-prompt: >>> zip([1, 2, 3], ["a", "b", "c"]) The other thing here is tuple-unpacking. If you kn

Re: xmlrpc idea for getting around the GIL

2009-11-23 Thread Diez B. Roggisch
Patrick Stinson schrieb: On Mon, Nov 23, 2009 at 1:01 AM, Carl Banks wrote: On Nov 22, 10:58 pm, Patrick Stinson wrote: On Sun, Nov 22, 2009 at 3:15 PM, Diez B. Roggisch wrote: icating) the multiprocessing module would be ideal. The problem is that the OP has a embedded application

Re: [repost please help me] python setup.py build for 32-bits on x86_64 machine

2009-11-23 Thread Diez B. Roggisch
Sérgio Monteiro Basto schrieb: Diez B. Roggisch wrote: Hi, Thanks, Sérgio Monteiro Basto wrote: Hi, I am in x86_64 arch , but I need compile things on 32 bits with python setup.py build Can't change the fact that distutils creates x86_64 directories: build/temp.linux-x86_64-2.3/ Also

Re: sys.stdout is not flushed

2009-11-23 Thread Diez B. Roggisch
Jankins schrieb: I am trying to use sys.stdout to print out "process-bar" like: -->1% Here is my program ‘test.py’: from sys import stdout for v in range(10): stdout.write('-->%d' % v) stdout.flush() else: stdout.write('done!') #end for Then, I use 'python -u test.py' to run this s

Re: Need help to understand a getattr syntax.

2009-11-24 Thread Diez B. Roggisch
NMarcu wrote: > Hello all, > I need some help to understand a getattr syntax. The syntax is: > > try: > getattr(self, command)(cursor, row) > except Exception, e: > print "Action failed : '%s'" % command > raise e > > I don't understand why is not like this: a = getattr(), and wh

Re: confused with os.fork()

2009-11-25 Thread Diez B. Roggisch
Sandy schrieb: Hi all, I am a little bit confused about os.fork(). Say I have the following code. import os a = ['a','b','c','d','e'] for i in xrange(len(a)): pid = os.fork() if not pid: print a[i] os._exit(0) From mo

Re: How to set default encoding for print?

2010-01-31 Thread Diez B. Roggisch
Am 31.01.10 16:38, schrieb kj: It gets tedious to have to append .encode('utf-8') to all my unicode strings when I print them, as in: print foobar.encode('utf-8') I want to tell python to apply this encoding automatically to anything argument passed to print. How can I do this? TIA! K

Re: How to pass Chinese characters as command-line arguments?

2010-01-31 Thread Diez B. Roggisch
Am 31.01.10 16:52, schrieb kj: I want to pass Chinese characters as command-line arguments to a Python script. My terminal has no problem displaying these characters, and passing them to the script, but I can't get Python to understand them properly. E.g. if I pass one such character to the sim

Re: Iterating over a function call

2010-02-01 Thread Diez B. Roggisch
So.I'm wondering if there is any interest in an apply() built-in function that would work like map() does in 2.x (calls the function with each value returned by the iterator) but return nothing. Maybe "apply" isn't the best name; it's just the first one that occurred to me. Or is this just s

Re: Passing parameters in URL

2010-02-03 Thread Diez B. Roggisch
m with the values, and submit that - of course you need javascript for this. But this doesn't increase security a bit. Using an extension to FF such as HTTP live headers, it's easy enough to figure out what parameters are passed, and simply forge a request. b) without the user bein

Re: PyChecker under python's virtualenv

2010-02-03 Thread Diez B. Roggisch
Am 03.02.10 22:46, schrieb soltys: Hi Everybody, I've been doing some test on pythons' virtualenv and recently I've decided to run PyChecker. But I'm having some difficulties with importing modules available only on virtualenv by pychecker. As if it was trying to use systemwide python. I've googl

Re: Passing parameters in URL

2010-02-03 Thread Diez B. Roggisch
Am 03.02.10 23:35, schrieb Paul Rubin: "Diez B. Roggisch" writes: If somebody happens to have access to a proxy& it's logs, he can as well log the request body. I'm not talking about a malicious server operator. In this situation, I was the server operator and I did

Re: PyChecker under python's virtualenv

2010-02-04 Thread Diez B. Roggisch
Am 04.02.10 01:52, schrieb Steve Holden: Diez B. Roggisch wrote: Am 03.02.10 22:46, schrieb soltys: Hi Everybody, I've been doing some test on pythons' virtualenv and recently I've decided to run PyChecker. But I'm having some difficulties with importing modules available o

Re: Passing parameters in URL

2010-02-04 Thread Diez B. Roggisch
ime: data sent over the wire can be recorded. From the user's POV, your nitpicking of who's the actual culprit - the IT-guys, or the programmers - is fruitless. You have a nice anecdote where switching from GET to POST allowed you to trick whoever wasn't acting to your wishes.

Re: Passing parameters in URL

2010-02-04 Thread Diez B. Roggisch
Am 03.02.10 19:11, schrieb John Bokma: Alan Harris-Reid writes: I have a web-page where each row in a grid has edit/delete buttons to enable the user to maintain a selected record on another page. The buttons are in the form of a link with href='/item_edit?id=123', but this string appears in

Re: Passing parameters in URL

2010-02-04 Thread Diez B. Roggisch
Am 03.02.10 23:09, schrieb Paul Rubin: "Diez B. Roggisch" writes: Also, your claim of it being more risky is simply nonsense. GET is a tiny bit more prone to tinkering by the average user. But calling this less risky is promoting security by obscurity, at most. GET parameters al

Re: Passing parameters in URL

2010-02-04 Thread Diez B. Roggisch
Am 04.02.10 00:39, schrieb Paul Rubin: "Diez B. Roggisch" writes: Of course only information not gathered is really safe information. But every operation that has side-effects is reproducable anyway, and if e.g. your chat-app has a history, you can as well log the parameters.

Re: Passing parameters in URL

2010-02-04 Thread Diez B. Roggisch
Am 04.02.10 03:52, schrieb Nobody: On Wed, 03 Feb 2010 14:09:07 -0800, Paul Rubin wrote: Also, your claim of it being more risky is simply nonsense. GET is a tiny bit more prone to tinkering by the average user. But calling this less risky is promoting security by obscurity, at most. GET para

Re: Passing parameters in URL

2010-02-04 Thread Diez B. Roggisch
Am 04.02.10 18:22, schrieb John Bokma: "Diez B. Roggisch" writes: Am 04.02.10 01:42, schrieb John Bokma: [..] Maybe you should think about what happens if someone posts: http://example.com/item_delete?id=123";> to a popular forum... And the difference to posting f

Re: Passing parameters in URL

2010-02-06 Thread Diez B. Roggisch
Am 04.02.10 01:42, schrieb John Bokma: "Diez B. Roggisch" writes: Am 03.02.10 19:11, schrieb John Bokma: Alan Harris-Reid writes: I have a web-page where each row in a grid has edit/delete buttons to enable the user to maintain a selected record on another page. The buttons

Re: Modifying Class Object

2010-02-08 Thread Diez B. Roggisch
Am 08.02.10 02:51, schrieb Alf P. Steinbach: * Chris Rebert: On Sun, Feb 7, 2010 at 5:05 PM, T wrote: Ok, just looking for a sanity check here, or maybe something I'm missing. I have a class Test, for example: class Test: def __init__(self, param1, param2, param3): self.param1 = param1 self.p

Re: Doctests and decorated methods don't get along

2010-02-09 Thread Diez B. Roggisch
Am 06.02.10 12:48, schrieb Steven D'Aprano: It seems that doctest doesn't discover or execute doctests in methods which have been decorated. Here is my test file: # == class MyStaticMethod(object): """Emulate built-in staticmethod descriptor.""" def __init__(self, f): se

Re: use strings to call functions

2010-02-09 Thread Diez B. Roggisch
Am 09.02.10 07:00, schrieb OdarR: On 9 fév, 02:50, Jean-Michel Pichavant wrote: Aahz wrote: In article<0efe23a6-b16d-4f92-8bc0-12d056bf5...@z26g2000yqm.googlegroups.com>, OdarR wrote: and with eval(), did you try ? WARNING: eval() is almost always the wrong answer to any question Some

Re: python crash on windows but not on linux

2010-02-13 Thread Diez B. Roggisch
Am 13.02.10 11:50, schrieb hjebbers: On Feb 13, 10:25 am, Dennis Lee Bieber wrote: On Fri, 12 Feb 2010 09:21:07 -0800 (PST), hjebbers declaimed the following in gmane.comp.python.general: What strikes me is: 1. the crash on windows, but linux works OK (same test sets) 2. the linux box has 750

Re: how do I write a scliceable class?

2010-02-13 Thread Diez B. Roggisch
Am 13.02.10 13:51, schrieb Ernest Adrogué: Hello everybody, I'm designing a container class that supports slicing. The problem is that I don't really know how to do it. class MyClass(object): def __init__(self, input_data): self._data = transform_input(input_data)

Re: Py3: Terminal or browser output?

2010-02-13 Thread Diez B. Roggisch
Am 13.02.10 20:46, schrieb Gnarlodious: Hello, searched all over but no success. I want to have a script output HTML if run in a browser and plain text if run in a Terminal. In Python 2, I just said this: if len(sys.argv)==True: and it seemed to work. Py3 must have broken that by sending a list

Re: MemoryError, can I use more?

2010-02-13 Thread Diez B. Roggisch
Am 13.02.10 17:18, schrieb Anssi Saari: Nobody writes: A single process can't use much more than 2GiB of RAM without a 64-bit CPU and OS. That's not really true. Even Windows XP has the /3GB boot option to allow 3 GiB per process. On PCs, free operating systems and server Windows can use PAE

Re: plugin / intra process communication system

2010-02-14 Thread Diez B. Roggisch
Am 14.02.10 13:05, schrieb Florian Ludwig: On Sun, 2010-02-14 at 10:16 +0100, Paul Kölle wrote: Am 13.02.2010 10:50, schrieb Florian Ludwig: Hi, I'm looking for a module/plugin/intra-process-communication/hook system for python. Maybe someone here could point me to some project I missed or mig

Re: MemoryError, can I use more?

2010-02-14 Thread Diez B. Roggisch
Am 14.02.10 12:28, schrieb Laszlo Nagy: 2010.02.13. 17:40 keltezéssel, Diez B. Roggisch írta: Am 13.02.10 17:18, schrieb Anssi Saari: Nobody writes: A single process can't use much more than 2GiB of RAM without a 64-bit CPU and OS. That's not really true. Even Windows XP has the

Re: plugin / intra process communication system

2010-02-16 Thread Diez B. Roggisch
Am 15.02.10 23:12, schrieb Florian Ludwig: On Sun, 2010-02-14 at 18:47 +0100, Diez B. Roggisch wrote: Here there problem with the trac (and other plugin systems I've seen) approach: You need to define something like: | | class IAuthPlugin(Interface): [...] | in your blog software. Why

Re: plugin / intra process communication system

2010-02-17 Thread Diez B. Roggisch
IMHO the ones using interfaces usually immediatly implement them for some cases - so you actually get the interface for you authentication framework, and also implement an OpenID plugin for it. And this forms one package. Then you can add new packages that implement other things. So if I want to

Re: Attributes in privates methods

2010-02-19 Thread Diez B. Roggisch
Am 19.02.10 16:08, schrieb Yasser Almeida Hernández: Hi all. I have a class with the attribute 'log_file', opened out of the class: class ProteinCluster: def __init__(self,cluster_name,log_file): ... self.log_file = log_file ... Then i have a private method which write in the log_file: def _read

Re: Pure virtual functions in Python?

2010-02-20 Thread Diez B. Roggisch
Am 20.02.10 17:12, schrieb lallous: Hello How can I do something similar to pure virtual functions in C++ ? Let us consider this: class C1: # Pure virtual def cb(self, param1, param2): """ This is a callback @param param1: ... @param param2: ...

Re: Pure virtual functions in Python?

2010-02-20 Thread Diez B. Roggisch
Sorry, I totally mis-read the OP, too tired. You are right of course. Diez -- http://mail.python.org/mailman/listinfo/python-list

Re: Efficiently building ordered dict

2010-02-22 Thread Diez B. Roggisch
Am 22.02.10 22:29, schrieb Bryan: On Feb 22, 10:57 am, "Alf P. Steinbach" wrote: * Bryan: I am looping through a list and creating a regular dictionary. From that dict, I create an ordered dict. I can't think of a way to build the ordered dict while going through the original loop. Is th

Re: Efficiently building ordered dict

2010-02-22 Thread Diez B. Roggisch
Am 22.02.10 23:48, schrieb Bryan: On Feb 22, 2:16 pm, "Diez B. Roggisch" wrote: Am 22.02.10 22:29, schrieb Bryan: On Feb 22, 10:57 am, "Alf P. Steinbach"wrote: * Bryan: I am looping through a list and creating a regular dictionary. From that dict, I create

Re: parametrizing a sqlite query

2010-02-24 Thread Diez B. Roggisch
Am 24.02.10 18:07, schrieb Sebastian Bassi: c.execute("SELECT bin FROM bins WHERE qtl LIKE '%:keys%'",{'keys':keywords}) This query returns empty. When it is executed, keywords = 'harvest'. To check it, I do it on the command line and it works as expected: sqlite> SELECT bin FROM bins WHERE qt

Re: python dowload

2010-02-24 Thread Diez B. Roggisch
Am 24.02.10 00:08, schrieb monkeys paw: On 2/23/2010 3:17 PM, Tim Chase wrote: monkeys paw wrote: I used the following code to download a PDF file, but the file was invalid after running the code, is there problem with the write operation? import urllib2 url = 'http://www.whirlpoolwaterheaters

Re: compiling python question

2010-02-24 Thread Diez B. Roggisch
Am 24.02.10 03:00, schrieb Mag Gam: I am trying to compile python with Tk bindings. Do I need to do anything special for python to detect and enable Tk? What OS? What does the configure/build process say? Diez -- http://mail.python.org/mailman/listinfo/python-list

Re: How to monitor memory usage within Python? (Linux)

2010-02-24 Thread Diez B. Roggisch
Am 24.02.10 23:35, schrieb kj: Is there some standard module for getting info about the process's memory usage, in a Linux/Unix system? (I want to avoid hacks that involve, e.g., scraping ps's output.) http://code.google.com/p/pympler/ Diez -- http://mail.python.org/mailman/listinfo/python-li

Re: Signature-based Function Overloading in Python

2010-02-24 Thread Diez B. Roggisch
Am 24.02.10 12:42, schrieb Michael Rudolf: First: Thanks for all the replies so far, they really helped me. Am 24.02.2010 11:28, schrieb Jean-Michel Pichavant: >>> def a(x=None): if x is None: pass else: pass This is the way to do it python, and it has its advantages: 1 docstring, 1 way do do

Re: pydoc errors

2010-02-25 Thread Diez B. Roggisch
Am 25.02.10 08:54, schrieb john maclean: python version is 2.6.2 does any one else have this issue? Seen a few closed tickets for various Linux Distros but it is obvoiusly still my problem. help> modules Please wait a moment while I gather a list of all available modules... dm.c: 1640: not r

Re: Pedantic pickling error after reload?

2010-02-25 Thread Diez B. Roggisch
Am 25.02.10 18:08, schrieb Robert: After (intended/controlled) reload or similar action on a module/class the pickle/cPickle.dump raises errors like pickle.PicklingError: Can't pickle : it's not the same object as somemodule.SomeClass Cause in pickle.py (and cPickle) is a line "if klass is not

Re: Renaming identifiers & debugging

2010-02-25 Thread Diez B. Roggisch
Am 25.02.10 20:27, schrieb Luca: Chris Rebert wrote: On Thu, Feb 25, 2010 at 7:26 AM, Luca wrote: Hello, i am trying to develop an application to teach programming to young kids in a similar way as Logo did in the past. I would like to use an embedded Python as underlying language but this rai

Re: compiling python question

2010-02-25 Thread Diez B. Roggisch
Am 25.02.10 01:55, schrieb Mag Gam: sorry for the vague answer. Its Linux. The configure build does not say anything actually. This is for SAGE. I managed to have it pick it up by compiling/installing tcl and tk and then recompile python Then most probably installing the tk-dev packages would

Re: Renaming identifiers & debugging

2010-02-25 Thread Diez B. Roggisch
And also I don't think that your concerns are valid in general. Keywords are like brandnames or other things - the stand for a concept, and people immediatly accept them when they want them. Maybe you are right, but being italian myself i can remember when i was a middle schooler (no computer be

Re: Renaming identifiers & debugging

2010-02-25 Thread Diez B. Roggisch
On a related note, did you investigate SUGAR of the OLPC? I'd say these guys certainly tried to create something that appealed to children, and AFAIK it comes with a Python interpreter. I'm don't know anything about that, nor if it comes with learning material. Might be worth checking out. Die

Re: taking python enterprise level?...

2010-02-25 Thread Diez B. Roggisch
That better way turned out to asynchronous update transactions. All we did was keep feeding updates to the remote site and forget about ACKS. We then had a second process which handled ACKS and tracked which packets had been properly transferred. The system had IDs on each update and retries hap

Re: Get dosctring without import

2010-02-26 Thread Diez B. Roggisch
Am 26.02.10 09:55, schrieb Joan Miller: When a package is imported, it gets the dosctring to store it in *__doc__*. Does that funcion is built in python? because I would want use it to get the docstring without import a package You'd need to write your own parser for that. All standard tools s

Re: staticmethod and namespaces

2010-02-26 Thread Diez B. Roggisch
Am 26.02.10 06:07, schrieb darnzen: Having an odd problem that I solved, but wondering if its the best solution (seems like a bit of a hack). First off, I'm using an external DLL that requires static callbacks, but because of this, I'm losing instance info. It could be import related? It will ma

Re: taking python enterprise level?...

2010-02-26 Thread Diez B. Roggisch
Am 26.02.10 05:01, schrieb D'Arcy J.M. Cain: On Fri, 26 Feb 2010 01:12:00 +0100 "Diez B. Roggisch" wrote: That better way turned out to asynchronous update transactions. All we did was keep feeding updates to the remote site and forget about ACKS. We then had a second proces

Re: (and about tests) Re: Pedantic pickling error after reload?

2010-02-26 Thread Diez B. Roggisch
at that point of comparison the module is already identical ("klass = getattr(mod, name)") Ah, didn't know that context. even more corner-cases. Python's import-mechanism can sometimes be rather foot-shoot-prone. still don't see a real reason against the mere module+name comparison. same iss

Re: staticmethod and namespaces

2010-02-26 Thread Diez B. Roggisch
Am 26.02.10 16:32, schrieb darnzen: On Feb 26, 3:15 am, "Diez B. Roggisch" wrote: Am 26.02.10 06:07, schrieb darnzen: Having an odd problem that I solved, but wondering if its the best solution (seems like a bit of a hack). First off, I'm using an external DLL that

Re: staticmethod and namespaces

2010-02-26 Thread Diez B. Roggisch
Am 26.02.10 16:57, schrieb darnzen: On Feb 26, 9:41 am, "Diez B. Roggisch" wrote: Am 26.02.10 16:32, schrieb darnzen: On Feb 26, 3:15 am, "Diez B. Roggisch"wrote: Am 26.02.10 06:07, schrieb darnzen: Having an odd problem that I solved, but wondering if i

Re: staticmethod and namespaces

2010-02-26 Thread Diez B. Roggisch
Am 26.02.10 17:08, schrieb Diez B. Roggisch: Am 26.02.10 16:57, schrieb darnzen: On Feb 26, 9:41 am, "Diez B. Roggisch" wrote: Am 26.02.10 16:32, schrieb darnzen: On Feb 26, 3:15 am, "Diez B. Roggisch" wrote: Am 26.02.10 06:07, schrieb darnzen: Having an odd p

Re: conditional import into global namespace

2010-03-03 Thread Diez B. Roggisch
Am 02.03.10 21:41, schrieb mk: Jerry Hill wrote: Just import subprocess at the top of your module. If subprocess hasn't been imported yet, it will be imported when your module is loaded. If it's already been imported, your module will use the cached version that's already been imported. In othe

Re: python SUDS library

2010-03-04 Thread Diez B. Roggisch
Am 04.03.10 06:23, schrieb yamamoto: Hi, I tried to make a simple script with SUD library for caching torrent files. it doenst work! [versions] suds: 0.4, python: 2.6.4 [code] from suds.client import Client import base64 path = 'sample.torrent' doc = open(path, 'rb').read() encoded_doc = base6

Re: running a program on many processors

2010-03-07 Thread Diez B. Roggisch
Am 08.03.10 01:18, schrieb Paweł Banyś: Hello, I have already read about Python and multiprocessing which allows using many processors. The idea is to split a program into separate tasks and run each of them on a separate processor. However I want to run a Python program doing a single simple ta

Re: How to automate accessor definition?

2010-03-21 Thread Diez B . Roggisch
kj wrote: > > > > > > > I need to create a class solely for the purpose of encapsulating > a large number of disparate data items. At the moment I have no > plans for any methods for this class other than the bazillion > accessors required to access these various instance variables. > (In c

Re: Getting references to objects without incrementing reference counters

2010-11-14 Thread Diez B. Roggisch
Artur Siekielski writes: > Hi. > I'm using CPython 2.7 and Linux. In order to make parallel > computations on a large list of objects I want to use multiple > processes (by using multiprocessing module). In the first step I fill > the list with objects and then I fork() my worker processes that d

Re: Getting references to objects without incrementing reference counters

2010-11-15 Thread Diez B. Roggisch
Artur Siekielski writes: > On Nov 15, 1:03 am, [email protected] (Diez B. Roggisch) wrote: >> You don't say what data you share, and if all of it is needed for each >> child. So it's hard to suggest optimizations. > > Here is an example of such a problem I'm de

Re: QT window closes immediately

2010-11-16 Thread Diez B. Roggisch
Martin Caum writes: > I am attempting to open a window on mouse activity which works, but > the window fails to stay open. > I set it to terminate when the escape key is pressed even when the > program is not currently selected. This works fine. Originally I had > it create the window only with a

Re: How to correctly pass “pointer-to-pointer ” into DLL via ctypes?

2010-11-19 Thread Diez B. Roggisch
Grigory Petrov writes: > Hello. > > I have a DLL that allocates memory and returns it. Function in DLL is like > this: > > void Foo( unsigned char** ppMem, int* pSize ) > { >   * pSize = 4; >   * ppMem = malloc( * pSize ); >   for( int i = 0; i < * pSize; i ++ ) (* pMem)[ i ] = i; > } > > Also,

Re: Round Trip: C to Python to C Module

2010-11-19 Thread Diez B. Roggisch
Eric Frederich writes: > I have a proprietary software PropSoft that I need to extend. > They support extensions written in C that can link against PropLib to > interact with the system. > > I have a Python C module that wraps a couple PropLib functions that I > call PyProp. >>From an interactive

Re: pyqt4: multi-threaded database access

2010-11-24 Thread Diez B. Roggisch
Adrian Casey writes: > I have a PyQt4 multi-threaded application which accesses many hosts > concurrently via ssh. I would like each thread to have access to a > database so that it can look up details about the particular system it > is connected to. > > The easy way is to have each thread crea

<    36   37   38   39   40   41   42   43   44   45   >