Re: debian apt somehow created python hell! - help

2009-05-01 Thread Ben Finney
John O'Hagan writes: > On Sat, 2 May 2009, watermod wrote: > > The current apt state is that python apps are failing install in: > > /usr/sbin/update-python-modules > > > [snip Debian package-management errors] > … you'll get better answerson, say, debian-users. John refers to the Debian user di

Re: debian apt somehow created python hell! - help

2009-05-01 Thread John O'Hagan
On Sat, 2 May 2009, watermod wrote: > I was doing one of those auto apt-get gui things with update manager in > Debian and not watching the error log so I don't know where it started. > > It involves only Python stuff. I don't know Python but apps use it. > > > The current apt state is that python

Re: object query assigned variable name?

2009-05-01 Thread John O'Hagan
On Fri, 1 May 2009, warpcat wrote: > I've passed this around some other groups, and I'm being told > "probably not possible". But I thought I'd try here as well :) I > *did* search first, and found several similar threads, but they > quickly tangented into other specifics of the language that we

Re: urllib2 and threading

2009-05-01 Thread Aahz
In article , robean wrote: > >Here's the problem: the script simply crashes after getting a a couple >of urls and takes a long time to run (slower that a non-threaded >version that I wrote and ran). Can anyone figure out what I am doing >wrong? I am new to both threading and urllib2, so its possi

Re: ctypes: reference of a struct member?

2009-05-01 Thread Gabriel Genellina
En Sat, 02 May 2009 00:51:29 -0300, Gabriel Genellina escribió: En Fri, 01 May 2009 14:39:39 -0300, ma escribió: If I have this struct in C: struct spam { int ham; char foo; }; if I have this declaration: struct spam s_; If I wanted to pass a reference to a function of s_'s foo ch

Re: ctypes: reference of a struct member?

2009-05-01 Thread Gabriel Genellina
En Fri, 01 May 2009 14:39:39 -0300, ma escribió: If I have this struct in C: struct spam { int ham; char foo; }; if I have this declaration: struct spam s_; If I wanted to pass a reference to a function of s_'s foo character, I can do something like this: somefunc(&s_.foo) How do I

Re: web access through vpn client

2009-05-01 Thread mark . seagoe
On May 1, 5:57 pm, "Martin P. Hellwig" wrote: > mark.sea...@gmail.com wrote: > > Hi; > > > I am trying to retrieve financial data off website for stock market > > analysis.  Just hobby not for pay.  I actually am impressed that > > urllib2 and BeautifulSoup work pretty well to do what I want, and

debian apt somehow created python hell! - help

2009-05-01 Thread watermod
I was doing one of those auto apt-get gui things with update manager in Debian and not watching the error log so I don't know where it started. It involves only Python stuff. I don't know Python but apps use it. The current apt state is that python apps are failing install in: /usr/sbin/update

Re: Question about the wording in the python documents.

2009-05-01 Thread Steven D'Aprano
On Fri, 01 May 2009 13:02:59 -0700, grocery_stocker wrote: > I don't get how urllib2.urlopen() can take a Request object. When I do > the following > > [cdal...@localhost ~]$ python > Python 2.4.3 (#1, Oct 1 2006, 18:00:19) [GCC 4.1.1 20060928 (Red Hat > 4.1.1-28)] on linux2 Type "help", "co

Re: Why bool( object )?

2009-05-01 Thread Steven D'Aprano
On Fri, 01 May 2009 15:03:30 -0700, Aaron Brady wrote: > On May 1, 4:30 am, Steven D'Aprano cybersource.com.au> wrote: >> On Fri, 01 May 2009 16:30:19 +1200, Lawrence D'Oliveiro wrote: >> > I have never written anything so unbelievable in my life. And I hope >> > I never will. >> >> I didn't say

Re: Profiling gives very different predictions of best algorithm

2009-05-01 Thread Terry Reedy
Rick wrote: [Rearrangee to put answer after question. Unless your name is Guido and you are making a short pronouncement that you want to be sure everyone sees, please do not toppost] >>> My question to the mailing list is what am I doing wrong with my >>> profiling that it shows such poor pr

Re: is it possible to traverse two lists simulatenously using python

2009-05-01 Thread Terry Reedy
mobiledream...@gmail.com wrote: Python for i,j in topgirls, richgirls: print i,j for i,y in zip(a,b): ... -- http://mail.python.org/mailman/listinfo/python-list

Re: web access through vpn client

2009-05-01 Thread Martin P. Hellwig
mark.sea...@gmail.com wrote: Hi; I am trying to retrieve financial data off website for stock market analysis. Just hobby not for pay. I actually am impressed that urllib2 and BeautifulSoup work pretty well to do what I want, and the first little routine actually gets the data from the web pag

eval(WsgiApplication)

2009-05-01 Thread gert
I would like to read the following from a text file from json import loads from gert.db import Db def application(environ, response): v = loads(environ['wsgi.input'].read(int(environ ['CONTENT_LENGTH'])).decode('utf-8')) db = Db() db.execute('UPDATE votes SET count=count+1 WHERE vid=?'

Re: How to measure the memory cost in Python?

2009-05-01 Thread Jean
On May 1, 12:50 pm, Jean wrote: > On May 1, 10:56 am, CTO wrote: > > > > > > sys.getsizeof() [a suggested solution] isn't platform-specific. > > > So, to answer the OP's question, you'd just do something like > > > def get_totalsize(obj): > >         total_size = sys.getsizeof(obj) > >         fo

Re: web access through vpn client

2009-05-01 Thread Stephen Hansen
> > I am trying to retrieve financial data off website for stock market > analysis. Just hobby not for pay. I actually am impressed that > urllib2 and BeautifulSoup work pretty well to do what I want, and the > first little routine actually gets the data from the web page... > except if my VPN cl

Re: string processing question

2009-05-01 Thread norseman
Piet van Oostrum wrote: Kurt Mueller (KM) wrote: KM> But from the command line python interprets the code KM> as 'latin_1' I presume. That is why I have to convert KM> the "ä" with unicode(). KM> Am I right? There are a couple of stages: 1. Your terminal emulator interprets your keystrokes,

web access through vpn client

2009-05-01 Thread mark . seagoe
Hi; I am trying to retrieve financial data off website for stock market analysis. Just hobby not for pay. I actually am impressed that urllib2 and BeautifulSoup work pretty well to do what I want, and the first little routine actually gets the data from the web page... except if my VPN client is

Re: is it possible to traverse two lists simulatenously using python

2009-05-01 Thread Daniel Fetchinson
> Python > for i,j in topgirls, richgirls: > print i,j for i, j in zip( topgirls, richgirls ): print i,j HTH, Daniel > Cheetah > #for $i,$j in $topgirls, $richgirls$i, $j > #end for > This doesnt work -- Psss, psss, put it down! - http://www.cafepress.com/putitdown -- http://mail.pyt

Re: is it possible to traverse two lists simulatenously using python

2009-05-01 Thread Berkin Malkoc
You should be looking for "zip".. On Thu, Apr 30, 2009 at 9:31 AM, wrote: > Python > for i,j in topgirls, richgirls: > print i,j > > Cheetah > #for $i,$j in $topgirls, $richgirls > $i, $j > #end for > This doesnt work > > -- > Bidegg worlds best auction site > http://bidegg.com > > -- > http

Re: urllib2 and threading

2009-05-01 Thread Piet van Oostrum
> robean (R) wrote: >R> def get_info_from_url(url): >R> """ A dummy version of the function simply visits urls and prints >R> the url of the page. """ >R> try: >R> page = urllib2.urlopen(url) >R> except urllib2.URLError, e: >R> print " error ", e.reason >R> except urll

wxpython custom fonts

2009-05-01 Thread mateusz . kruszynski
Hi, I`m going to build a small wxpython-based application. The problem is that I need to use a custom (dedicated) font in my text controls with special characters (of course I`ll need to create a simple editor for inserting those characters into text controls, but that`s not the case). Documentatio

subprocess & shared environments

2009-05-01 Thread Robert Dailey
I'm currently calling subprocess.call() on a batch file (in Windows) that sets a few environment variables that are needed by further processes started via subprocess.call(). How can I persist the environment modifications by the first call() function? I've done my own searching on this and I came

dict is really slow for big truck

2009-05-01 Thread forrest yang
i try to load a big file into a dict, which is about 9,000,000 lines, something like 1 2 3 4 2 2 3 4 3 4 5 6 code for line in open(file) arr=line.strip().split('\t') dict[arr[0]]=arr but, the dict is really slow as i load more data into the memory, by the way the mac i use have 16G memory.

Re: mailbox.mbox.add() sets access time as well as modification time

2009-05-01 Thread Matthew Woodcraft
Chris Green wrote: > Currently I run mutt on a remote server where I have to use maildir > because their file systems are mounted noatime. I am moving to reading > mail on my own Linux box just because I want to get back to mbox, [...] For what it's worth, setting 'check_mbox_size = yes' is usuall

Re: dict is really slow for big truck

2009-05-01 Thread Thomas G. Willis
On Apr 28, 8:54 am, forrest yang wrote: > i try to load a big file into a dict, which is about 9,000,000 lines, > something like > 1 2 3 4 > 2 2 3 4 > 3 4 5 6 > > code > for line in open(file) >    arr=line.strip().split('\t') >    dict[arr[0]]=arr > > but, the dict is really slow as i load more d

Re: Why bool( object )?

2009-05-01 Thread Steven D'Aprano
On Fri, 01 May 2009 16:30:19 +1200, Lawrence D'Oliveiro wrote: > I have never written anything so unbelievable in my life. And I hope I > never will. I didn't say you did. If anyone thought I was quoting Lawrence's code, I'd be surprised. It was not my intention to put words into your mouth. Bu

Re: What do you think of ShowMeDo

2009-05-01 Thread Paul Hemans
I was fishing for a response, by posting multiple replies Inadvertantly, I have offended one of the Python rabbis For this misdemeanor I am most contrite But I still got a fish to bite. "Peter Pearson" wrote in message news:760gejf1af7r...@mid.individual.net... > On Fri, 1 May 2009 07:53:35 +100

Re: What do you think of ShowMeDo

2009-05-01 Thread Paul Hemans
I also am new to Python and found the site. The main barrier to me was the price. Pay as you use with credits might be less of a problem in an community environment where so much is available. The interface did not lead me to understand where I could find the free stuff, I also did not realize how

Re: What do you think of ShowMeDo

2009-05-01 Thread Paul Hemans
I also am new to Python and found the site. The main barrier to me was the price. Pay as you use with credits might be less of a problem in an community environment where so much is available. The interface did not lead me to understand where I could find the free stuff, I also did not realize

Re: What do you think of ShowMeDo

2009-05-01 Thread AK
Ben Finney wrote: Astley Le Jasper writes: I've just stumbled over this (http://showmedo.com/) and being the very visual person I am, it seems like it could be a good way to learn about python. However, before I smack down $60, I wondered if anyone had any opinions on it. My gut feel is that i

Re: What do you think of ShowMeDo

2009-05-01 Thread Ben Finney
Astley Le Jasper writes: > I've just stumbled over this (http://showmedo.com/) and being the very > visual person I am, it seems like it could be a good way to learn > about python. However, before I smack down $60, I wondered if anyone > had any opinions on it. My gut feel is that it could be pr

Re: Notebook Ariel

2009-05-01 Thread Piet van Oostrum
> Gabriel Genellina (GG) escribió: >GG> Hola >GG> La notebook de Ariel esta en el placard, atrás de Walter. ¿Quién es Walter y dónde esta? :=( -- Piet van Oostrum URL: http://pietvanoostrum.com [PGP 8DAE142BE17999C4] Private email: p...@vanoostrum.org -- http://mail.python.org/mailman/list

Re: May I ask about Sage here?

2009-05-01 Thread Michael Press
In article <899b6a05-942a-4229-b3aa-f9099e171...@g31g2000pra.googlegroups.com>, alex23 wrote: > On Apr 30, 11:06 am, Michael Press wrote: > > May I ask for help with Sage problems here?  I > > did not find a usenet Sage support group. > > http://www.sagemath.org/help-groups.html > http://grou

Memory problems - fixed!

2009-05-01 Thread Paul Hemans
Taking into account that I am very new to Python and so must be missing something important dumping xml.dom and going to lxml made a WORLD of difference to the performance of the application. -- http://mail.python.org/mailman/listinfo/python-list

Re: Tools for web applications

2009-05-01 Thread Pascal Chambon
Concerning Desktop applications, I would really suggestion PyQt. I don't know if it's "easyToLearn", but with its GUI designer you can very quickly get a cool looking application (and if you need to extend your app later, it offers, imo, much more possibilities that other toolkits I've tried).

Re: Why bool( object )?

2009-05-01 Thread Paul Rubin
Aaron Brady writes: > I think you are looking at an 'ireduce' function, which doesn't > exist in 'itertools' yet. Nothing is being done with the return value. sum(1 for x in imap(func, seq)) is enough to force evaluation of func on each element of seq. -- http://mail.python.org/mailman/listi

Re: ctypes: reference of a struct member?

2009-05-01 Thread Günther Dietrich
ma wrote: >If I have this struct in C: > >struct spam { > int ham; > char foo; >}; > > >if I have this declaration: >struct spam s_; > >If I wanted to pass a reference to a function of s_'s foo character, I >can do something like this: > >somefunc(&s_.foo) > >How do I do the same thing in ct

Re: Profiling gives very different predictions of best algorithm

2009-05-01 Thread Rick
Sorry, I'm running the function: def debugsuite(): import profile,pstats profile.run('runsuite()','prof') prof = pstats.Stats('prof') prof.strip_dirs().sort_stats('time').print_stats(15) where runsuite() runs the Hartree-Fock energy of a water molecule, and is given by: import u

Re: Multiprocessing Pool and functions with many arguments

2009-05-01 Thread Aaron Brady
On Apr 29, 1:01 pm, "psaff...@googlemail.com" wrote: > I'm trying to get to grips with the multiprocessing module, having > only used ParallelPython before. > > based on this example: > > http://docs.python.org/library/multiprocessing.html#using-a-pool-of-w... > > what happens if I want my "f" to

Re: Help! Can't get program to run.

2009-05-01 Thread Ned Deily
In article <7618rjf1a3t8...@mid.uni-berlin.de>, "Diez B. Roggisch" wrote: > seanm...@gmail.com schrieb: > > I think this is maybe the most basic problem possible, but I can't get > > even the most basic Python to run on OS X using Terminal or IDLE. I > > used the IDLE editor to create a file with

Re: string processing question

2009-05-01 Thread Piet van Oostrum
> Kurt Mueller (KM) wrote: >KM> But from the command line python interprets the code >KM> as 'latin_1' I presume. That is why I have to convert >KM> the "ä" with unicode(). >KM> Am I right? There are a couple of stages: 1. Your terminal emulator interprets your keystrokes, encodes them in a

Re: Multiprocessing.Queue - I want to end.

2009-05-01 Thread Roel Schroeven
Hendrik van Rooyen schreef: > I have always wondered why people do the one queue many getters thing. Because IMO it's the simplest and most elegant solution. > > Given that the stuff you pass is homogenous in that it will require a > similar amount of effort to process, is there not a case to be

Re: Why bool( object )?

2009-05-01 Thread Aaron Brady
On May 1, 4:30 am, Steven D'Aprano wrote: > On Fri, 01 May 2009 16:30:19 +1200, Lawrence D'Oliveiro wrote: > > I have never written anything so unbelievable in my life. And I hope I > > never will. > > I didn't say you did. If anyone thought I was quoting Lawrence's code, > I'd be surprised. It wa

Re: Multiprocessing.Queue - I want to end.

2009-05-01 Thread Aaron Brady
On Apr 30, 3:49 pm, Luis Zarrabeitia wrote: > Hi. I'm building a script that closely follows a producer-consumer model. In > this case, the producer is disk-bound and the consumer is cpu-bound, so I'm > using the multiprocessing module (python2.5 with the multiprocessing backport > from google.cod

Re: Profiling gives very different predictions of best algorithm

2009-05-01 Thread Terry Reedy
Rick Muller wrote: I'm the main programmer for the PyQuante package, a quantum chemistry package in Python. I'm trying to speed up one of my rate determining steps. Essentially, I have to decide between two algorithms: 1. Packed means that I compute N**4/8 integrals, and then do a bunch of index

Re: Help! Can't get program to run.

2009-05-01 Thread Diez B. Roggisch
seanm...@gmail.com schrieb: I think this is maybe the most basic problem possible, but I can't get even the most basic Python to run on OS X using Terminal or IDLE. I used the IDLE editor to create a file with one line of code print 'text string' and I saved the file as module1.py. When using t

Re: Importing modules

2009-05-01 Thread Terry Reedy
norseman wrote: OH - something you mentioned that didn't seem to be addressed. import - load a complete library from - obtain specific 'function'(s) from a library from can also be used to get a specific module from a package If you 'import pack.mod', then you have to write 'pack.mod.ob' to

Re: Question about the wording in the python documents.

2009-05-01 Thread Emile van Sebille
On 5/1/2009 1:02 PM grocery_stocker said... At the following url... http://docs.python.org/library/urllib2.html They have the following... "urllib2.urlopen(url[, data][, timeout]) Open the URL url, which can be either a string or a Request object" I don't get how urllib2.urlopen() can ta

Re: Passing a function as an argument from within the same class?

2009-05-01 Thread Terry Reedy
zealalot wrote: So, I'm trying to come up with a way to pass a method (from the same class) as the default argument for another method in the same class. Unfortunately though, I keep getting "self not defined" errors since the class hasn't been read completely before it references itself. Is the

Re: subprocess & shared environments

2009-05-01 Thread Aaron Brady
On May 1, 12:09 am, Robert Dailey wrote: > I'm currently calling subprocess.call() on a batch file (in Windows) > that sets a few environment variables that are needed by further > processes started via subprocess.call(). How can I persist the > environment modifications by the first call() functi

Help! Can't get program to run.

2009-05-01 Thread seanm . py
I think this is maybe the most basic problem possible, but I can't get even the most basic Python to run on OS X using Terminal or IDLE. I used the IDLE editor to create a file with one line of code print 'text string' and I saved the file as module1.py. When using terminal I entered "python" to

Re: wxPython having trouble with frame objects

2009-05-01 Thread Mike Driscoll
On May 1, 12:12 am, Soumen banerjee wrote: > Hello, > Im not adding any GUI elements from the changer thread. Im just > attempting to change the value of a preexisting widget made in thread > one. The point is that i need to display text generated in thread 2 in > a GUI generated in thread 1. > As

Re: wxPython having trouble with frame objects

2009-05-01 Thread Mike Driscoll
On Apr 30, 11:52 pm, Dave Angel wrote: > Soumen banerjee wrote: > > Hello, > > you say that  frame_1 is an attribute of the main class. The main > > class here is guithread right? so any instance of guithread should > > also have an attribute called frame_1 isnt it? Excuse me if im getting > > thi

Re: Profiling gives very different predictions of best algorithm

2009-05-01 Thread Brian
quantum chemistry sounds complicated. that means any advice i can give you makes me a genius! just kidding. i've heard through the grapevine that reentrant functions mess up profilers. On Fri, May 1, 2009 at 2:54 PM, Rick Muller wrote: > I'm the main programmer for the PyQuante package, a quantu

Profiling gives very different predictions of best algorithm

2009-05-01 Thread Rick Muller
I'm the main programmer for the PyQuante package, a quantum chemistry package in Python. I'm trying to speed up one of my rate determining steps. Essentially, I have to decide between two algorithms: 1. Packed means that I compute N**4/8 integrals, and then do a bunch of indexing operations to unp

[ANN] Python testing client for Second Life virtual world

2009-05-01 Thread Lawson English
If anyone is curious, I'm working on a GUI shell for the python second life client, pyogp. Temp home for pyogp intro: https://wiki.secondlife.com/wiki/Pyogp/Client_Lib Basically the [first] plan is to have a GUI wrapper around the sample code with a batch file option, and to allow multiple ava

Question about the wording in the python documents.

2009-05-01 Thread grocery_stocker
At the following url... http://docs.python.org/library/urllib2.html They have the following... "urllib2.urlopen(url[, data][, timeout]) Open the URL url, which can be either a string or a Request object" I don't get how urllib2.urlopen() can take a Request object. When I do the following..

Re: How to measure the memory cost in Python?

2009-05-01 Thread Jean
On May 1, 10:56 am, CTO wrote: > > sys.getsizeof() [a suggested solution] isn't platform-specific. > > So, to answer the OP's question, you'd just do something like > > def get_totalsize(obj): >         total_size = sys.getsizeof(obj) >         for value in vars(obj).values(): >                 tr

Re: wxPython having trouble with frame objects

2009-05-01 Thread Dave Angel
Soumen banerjee wrote: Hello, The code works almost perfectly. I was able to correct some small things, and get it to work brilliantly. I would like to thank you for your dedicated help. My understanding of the matter here has improved by a lot due to your kind help. I will further work on your s

Re: [Python-Dev] .pth files are evil

2009-05-01 Thread Tim Golden
Chris Withers wrote: I'll say! I think .pth files are absolute evil and I wish they could just be banned. +1 on anything that makes them closer to going away or reduces the possibility of yet another similar feature from hurting the comprehensibility of a python setup. I've seen this view e

Re: Passing a function as an argument from within the same class?

2009-05-01 Thread Scott David Daniels
Steven D'Aprano wrote: On Fri, 01 May 2009 07:35:40 -0700, zealalot wrote: So, I'm trying to come up with a way to pass a method (from the same class) as the default argument for another method in the same class My first instinct is to say "Don't do that!", but let's see if there's a way

Re: fcntl and siginfo_t in python

2009-05-01 Thread ma
According to man signal, "The default action for an unhandled real-time signal is to terminate the receiving process." This means that my registered callback and sigaction does not work. I think the only solution would be to try this with a C-extension. Has anyone had any experience with this befo

Re: don't understand namespaces...

2009-05-01 Thread norseman
Simon Forman wrote: On Apr 30, 10:11 am, Lawrence Hanser wrote: Dear Pythoners, I think I do not yet have a good understanding of namespaces. Here is what I have in broad outline form: import Tkinter Class App(Frame) define two frames, buttons in o

Re: list comprehension question

2009-05-01 Thread Scott David Daniels
John Posner wrote: Shane Geiger wrote: if type(el) == list or type(el) is tuple: A tiny improvement: if type(el) in (list, tuple): or (even better) if isinstance(el, (list, tuple)) However, it is my contention that you shouldn't be flattening by type -- you should know where,

Re: ctypes: reference of a struct member?

2009-05-01 Thread ma
ctypes.byref() does not work for struct members. Try it out. class s(ctypes.Structure): _fields_ = [('x',ctypes.c_int)] a = s() ctypes.byref(a.x) //this won't work. On Fri, May 1, 2009 at 2:28 PM, CTO wrote: > ctypes.byref() > > -- > http://mail.python.org/mailman/listinfo/python-list > --

Re: Passing a function as an argument from within the same class?

2009-05-01 Thread Dave Angel
zealalot wrote: On May 1, 10:50 am, CTO wrote: Make doNothing a classmethod. class SomeClass: @classmethod def doNothing(cls): pass def function1(self): print "Running function 1" def function2(self, passedFunction=meClass.doNothing): print "Runnin

Re: object query assigned variable name?

2009-05-01 Thread Nick Craig-Wood
warpcat wrote: > I've passed this around some other groups, and I'm being told > "probably not possible". But I thought I'd try here as well :) I > *did* search first, and found several similar threads, but they > quickly tangented into other specifics of the language that were a bit > ove

Re: ctypes: reference of a struct member?

2009-05-01 Thread CTO
ctypes.byref() -- http://mail.python.org/mailman/listinfo/python-list

Re: urllib2 and threading

2009-05-01 Thread shailen . tuli
For better performance, lxml easily outperforms Beautiful Soup. For what its worth, the code runs fine if you switch from urllib2 to urllib (different exceptions are raised, obviously). I have no experience using urllib2 in a threaded environment, so I'm not sure why it breaks; urllib does OK, tho

Re: How to measure the memory cost in Python?

2009-05-01 Thread CTO
> sys.getsizeof() [a suggested solution] isn't platform-specific. So, to answer the OP's question, you'd just do something like def get_totalsize(obj): total_size = sys.getsizeof(obj) for value in vars(obj).values(): try: total_size += get_total_size(value)

Re: list comprehension question

2009-05-01 Thread Arnaud Delobelle
Emile van Sebille writes: > On 5/1/2009 9:19 AM Arnaud Delobelle said... >> Emile van Sebille writes: >>> On 5/1/2009 7:31 AM J Kenneth King said... I love comprehensions, but abusing them can lead to really dense and difficult to read code. >>> I disagree on dense and difficult, altho

ctypes: reference of a struct member?

2009-05-01 Thread ma
If I have this struct in C: struct spam { int ham; char foo; }; if I have this declaration: struct spam s_; If I wanted to pass a reference to a function of s_'s foo character, I can do something like this: somefunc(&s_.foo) How do I do the same thing in ctypes? ctypes.addressof(s_) +

Re: [Python-Dev] PEP 382: little help for stupid people?

2009-05-01 Thread Martin v. Löwis
>>> In either of the proposals on the table, what code would I write and >>> where to have a base package with a set of add-on packages? >> >> I don't quite understand the question. Why would you want to write code >> (except for the code that actually is in the packages)? >> >> PEP 382 is complete

Re: list comprehension question

2009-05-01 Thread Emile van Sebille
On 5/1/2009 9:19 AM Arnaud Delobelle said... Emile van Sebille writes: On 5/1/2009 7:31 AM J Kenneth King said... I love comprehensions, but abusing them can lead to really dense and difficult to read code. I disagree on dense and difficult, although I'll leave open the question of abuse. b

Re: object query assigned variable name?

2009-05-01 Thread Steven D'Aprano
On Fri, 01 May 2009 13:03:56 -0400, David Robinow wrote: > Others have explained to you that this is not possible. I'll just point > out that your method for learning the language is not optimal. If you > had gotten a recipe to do what you asked, how would it help you write > better programs? Exa

Re: Passing a function as an argument from within the same class?

2009-05-01 Thread CTO
> Careful, bearophiles' answer remains the best one. > > The only reason your example worked is that you had already had > SomeClass defined (probably from a previous experiment). Scott is correct, and if bearophile and I ever give you conflicting advice, take bearophile's. A (corrected) bit of c

Re: object query assigned variable name?

2009-05-01 Thread AKEric
On May 1, 10:03 am, David Robinow wrote: > On Fri, May 1, 2009 at 12:24 PM, warpcat wrote: > > I've passed this around some other groups, and I'm being told > > "probably not possible".  But I thought I'd try here as well :)   I > > *did* search first, and found several similar threads, but they

Re: Importing modules

2009-05-01 Thread norseman
Gabriel Genellina wrote: En Thu, 30 Apr 2009 14:33:38 -0300, Jim Carlock escribió: I'm messing around with a program right at the moment. It ends up as two applications, one runs as a server and one as a client which presents a Window. It almost works, so I need to work through it to work out i

Re: Passing a function as an argument from within the same class?

2009-05-01 Thread Steven D'Aprano
On Fri, 01 May 2009 07:35:40 -0700, zealalot wrote: > So, I'm trying to come up with a way to pass a method (from the same > class) as the default argument for another method in the same class. > Unfortunately though, I keep getting "self not defined" errors since the > class hasn't been read comp

Re: object query assigned variable name?

2009-05-01 Thread AKEric
On May 1, 9:48 am, Steven D'Aprano wrote: > On Fri, 01 May 2009 09:24:10 -0700, warpcat wrote: > > I'd like it to print, when instanced, something like this: > > s = Spam() > > I’m assigned to s! > > > But it seems prohibitively hard (based on my web and forum searches) for > > an object to k

Re: Passing a function as an argument from within the same class?

2009-05-01 Thread Steven D'Aprano
On Fri, 01 May 2009 08:11:01 -0700, zealalot wrote: > On May 1, 10:50 am, CTO wrote: >> Make doNothing a classmethod. >> >> class SomeClass: >> >>     @classmethod >>     def doNothing(cls): >>         pass >> >>     def function1(self): >>         print "Running function 1" >> >>     def functio

Re: object query assigned variable name?

2009-05-01 Thread David Robinow
On Fri, May 1, 2009 at 12:24 PM, warpcat wrote: > I've passed this around some other groups, and I'm being told > "probably not possible".  But I thought I'd try here as well :)   I > *did* search first, and found several similar threads, but they > quickly tangented into other specifics of the la

Re: Re: list comprehension question

2009-05-01 Thread John Posner
Shane Geiger wrote: if type(el) == list or type(el) is tuple: A tiny improvement: if type(el) in (list, tuple): -- http://mail.python.org/mailman/listinfo/python-list

Re: [Python-Dev] PEP 382: little help for stupid people?

2009-05-01 Thread Chris Withers
Martin v. Löwis wrote: In either of the proposals on the table, what code would I write and where to have a base package with a set of add-on packages? I don't quite understand the question. Why would you want to write code (except for the code that actually is in the packages)? PEP 382 is com

Re: object query assigned variable name?

2009-05-01 Thread Steven D'Aprano
On Fri, 01 May 2009 09:24:10 -0700, warpcat wrote: > I'd like it to print, when instanced, something like this: > s = Spam() > I’m assigned to s! > > But it seems prohibitively hard (based on my web and forum searches) for > an object to know what variable name is has been assigned to when

Re: Multiprocessing Pool and functions with many arguments

2009-05-01 Thread Piet van Oostrum
> "psaff...@googlemail.com" (P) wrote: >P> I'm trying to get to grips with the multiprocessing module, having >P> only used ParallelPython before. >P> based on this example: >P> http://docs.python.org/library/multiprocessing.html#using-a-pool-of-workers >P> what happens if I want my "f" to

Re: [Python-Dev] .pth files are evil

2009-05-01 Thread Scott David Daniels
Chris Withers wrote: M.-A. Lemburg wrote: """ If the package really requires adding one or more directories on sys.path (e.g. because it has not yet been structured to support dotted-name import), a "path configuration file" named package.pth can be placed in either the site-python or site-pac

Re: [Python-Dev] PEP 382: little help for stupid people?

2009-05-01 Thread Martin v. Löwis
> In either of the proposals on the table, what code would I write and > where to have a base package with a set of add-on packages? I don't quite understand the question. Why would you want to write code (except for the code that actually is in the packages)? PEP 382 is completely declarative -

Re: How to measure the memory cost in Python?

2009-05-01 Thread Jean
On May 1, 7:54 am, CTO wrote: > Not OP, but I'd actually like to know if there's an answer to this one > that doesn't involve platform-specific tools. Depending on what you need and the O/S you are using, this recipe may help That recipe also appe

Re: object query assigned variable name?

2009-05-01 Thread Scott David Daniels
warpcat wrote: I've passed this around some other groups, and I'm being told "probably not possible". But I thought I'd try here as well :) ... Given an object: class Spam(object): def __init__(self): # stuff I'd like it to print, when instanced, something like this:

Re: list comprehension question

2009-05-01 Thread Shane Geiger
from goopy.functional import flatten # http://sourceforge.net/projects/goog-goopy/ b = [(1,2), (3,4), (5,6)] print flatten(b) #from goopy.functional import flatten # http://sourceforge.net/projects/goog-goopy/ def flatten(seq): """ Returns a list of the contents of seq with sublists and

Re: urllib2 and threading

2009-05-01 Thread Stefan Behnel
robean wrote: > I am writing a program that involves visiting several hundred webpages > and extracting specific information from the contents. I've written a > modest 'test' example here that uses a multi-threaded approach to > reach the urls with urllib2. The actual program will involve fairly >

Re: Passing a function as an argument from within the same class?

2009-05-01 Thread Scott David Daniels
zealalot wrote: On May 1, 10:50 am, CTO wrote: Make doNothing a classmethod. class SomeClass: @classmethod def doNothing(cls): ... def function2(self, passedFunction=SomeClass.doNothing): print "Running passed function" passedFunction() ... It's not surprising,

Re: [Python-Dev] PEP 382: Namespace Packages

2009-05-01 Thread Chris Withers
P.J. Eby wrote: At 06:15 PM 4/15/2009 +0200, M.-A. Lemburg wrote: The much more common use case is that of wanting to have a base package installation which optional add-ons that live in the same logical package namespace. Please see the large number of Zope and PEAK distributions on PyPI as

Re: [Python-Dev] PEP 382: little help for stupid people?

2009-05-01 Thread Chris Withers
M.-A. Lemburg wrote: The much more common use case is that of wanting to have a base package installation which optional add-ons that live in the same logical package namespace. The PEP provides a way to solve this use case by giving both developers and users a standard at hand which they can fo

object query assigned variable name?

2009-05-01 Thread warpcat
I've passed this around some other groups, and I'm being told "probably not possible". But I thought I'd try here as well :) I *did* search first, and found several similar threads, but they quickly tangented into other specifics of the language that were a bit over my head :) At any rate, here

Re: [Python-Dev] .pth files are evil

2009-05-01 Thread Chris Withers
M.-A. Lemburg wrote: """ If the package really requires adding one or more directories on sys.path (e.g. because it has not yet been structured to support dotted-name import), a "path configuration file" named package.pth can be placed in either the site-python or site-packages directory. ... A t

Re: list comprehension question

2009-05-01 Thread Arnaud Delobelle
Emile van Sebille writes: > On 5/1/2009 7:31 AM J Kenneth King said... >> Chris Rebert writes: >>> b = [] >>> for pair in a: >>> for item in pair: >>> b.append(item) >> >> This is much more clear than a nested comprehension. >> >> I love comprehensions, but abusing them can lead to r

Re: string processing question

2009-05-01 Thread Scott David Daniels
Kurt Mueller wrote: Scott David Daniels schrieb: To discover what is happening, try something like: python -c 'for a in "ä", unicode("ä"): print len(a), a' I suspect that in your encoding, "ä" is two bytes long, and in unicode it is converted to to a single character. :> python -c 'for a

  1   2   >