Re: Is there some Python function that searches "sys.path" for a module?

2008-01-14 Thread John Nagle
Shane Geiger wrote: > If I understand you correctly, you want this: > > module.__file__ No, this is for a module that isn't loaded, and I don't want to load it. What I needed was "imp.find_module()". I don't want to load the module in the current Python instance. I need its path so I can star

Re: Is there some Python function that searches "sys.path" for a module?

2008-01-14 Thread John Nagle
Miki wrote: > http://docs.python.org/lib/module-imp.html Ah. "imp.find_module". I was looking in "sys" and path-related places. Thanks. John Nagle -- http://mail.python.org/mailman/listinfo/python-list

Re: Python too slow?

2008-01-14 Thread Jaimy Azle
<[EMAIL PROTECTED]> wrote: >> > fact 1: CPython compiles source code to byte-code. >> > fact 2: CPython executes this byte-code. >> > fact 3: Sun's JDK compiles source code to byte-code. >> > fact 4: Sun's JDK executes this byte-code. >> >> Fact 4 is misleading because it is only one option availa

Re: Is there some Python function that searches "sys.path" for a module?

2008-01-14 Thread Shane Geiger
If I understand you correctly, you want this: module.__file__ John Nagle wrote: >Python's own loader searches "sys.path" for module names, but is there > some function that makes that search functionality accessible to > Python programs? I need the absolute pathname of a module, with the

Re: Is there some Python function that searches "sys.path" for a module?

2008-01-14 Thread Miki
Hello John, >    Python's own loader searches "sys.path" for module names, but is there > some function that makes that search functionality accessible to > Python programs?  I need the absolute pathname of a module, with the > search being done exactly the same way "import" does it.  The loader f

Is there some Python function that searches "sys.path" for a module?

2008-01-14 Thread John Nagle
Python's own loader searches "sys.path" for module names, but is there some function that makes that search functionality accessible to Python programs? I need the absolute pathname of a module, with the search being done exactly the same way "import" does it. The loader for "egg" files has th

Re: "env" parameter to "popen" won't accept Unicode on Windows - minor Unicode bug

2008-01-14 Thread John Nagle
Benjamin wrote: > On Jan 14, 6:26 pm, Bjoern Schliessmann [EMAIL PROTECTED]> wrote: >> John Nagle wrote: >>> It turns out that the strings in the "env" parameter have to be >>> ASCII, not Unicode, even though Windows fully supports Unicode in >>> CreateProcess. >> Are you sure it supports Unicode,

Re: A question about event handlers with wxPython

2008-01-14 Thread Miki
Hello Eric, > I'd appreciate any pointer on a simple way to tell within an event handler > where the event came from. def HandleSomething(self, event): generating_control = event.GetEventObject() print generating_control HTH, -- Miki Tebeka <[EMAIL PROTECTED]> http://pythonwise.blogspot.c

Re: paging in python shell

2008-01-14 Thread Alex K
Thanks it's good to know. iPyton looks really neat. On 15/01/2008, Ben Finney <[EMAIL PROTECTED]> wrote: > John Machin <[EMAIL PROTECTED]> writes: > > > C:\junk>python demomore.py | more > > Your example uses the OS shell to invoke a pager on the output of the > Python process. The OP was asking a

Re: LANG, locale, unicode, setup.py and Debian packaging

2008-01-14 Thread Martin v. Löwis
>Has it been decided how Python 3.0 will implement os.listdir on Unix? > Will there be only a single attempt to encode using the current locale > or will there be a backup technique? That's what it currently does. > I'd probably define an optional > encoding parameter so you can ask for os.li

Re: super, decorators and gettattribute

2008-01-14 Thread Michele Simionato
On Jan 14, 11:47 pm, Richard Szopa <[EMAIL PROTECTED]> wrote: > Could you tell me what are the pros and cons of the two approaches > (i.e. writing a decorator function and a decorator descriptor class)? I prefer to use a class for introspection sake, since there is no way to get information about

A question about event handlers with wxPython

2008-01-14 Thread Erik Lind
I'd appreciate any pointer on a simple way to tell within an event handler where the event came from. I want to have "while" condition in a handler to stop or change processing if an event occurs from some other button click. Trying to bind more than one event to the same handler still doesn't t

Re: __init__ explanation please

2008-01-14 Thread Ben Finney
Hrvoje Niksic <[EMAIL PROTECTED]> writes: > Ben Finney <[EMAIL PROTECTED]> writes: > > > Hrvoje Niksic <[EMAIL PROTECTED]> writes: > >> __init__ *is* the closest equivalent to what other languages > >> would call a constructor. > > > > No. That would be '__new__', which actually constructs the >

Re: NotImplimentedError

2008-01-14 Thread Ben Finney
George Sakkis <[EMAIL PROTECTED]> writes: > On Jan 14, 5:39 pm, Ben Finney <[EMAIL PROTECTED]> > wrote: > > > I think of NotImplemented as equivalent to None; it's useful as a > > sentinel value to set an attribute to in (e.g.) an abstract class. > > My guess would be that it is more of an imple

Re: module naming conventions

2008-01-14 Thread Ben Finney
grackle <[EMAIL PROTECTED]> writes: > On Jan 14, 6:28 pm, Ben Finney <[EMAIL PROTECTED]> > wrote: > > Release your package as free software on the Cheeseshop > > http://cheeseshop.python.org/>. If the name you want is > > already taken, pick one that will help users distinguish yours > > from the

reliable whois in python

2008-01-14 Thread eliss
Hi everyone, I'm trying to write a python script to whois a few domains twice a day so I get notified when they become available. I did it 2 ways, but neither way is very reliable, so I'm asking here. 1) I tried just calling "whois %s" using popen, but I found that once every few weeks, I get err

Re: __init__ explanation please

2008-01-14 Thread Steven D'Aprano
On Tue, 15 Jan 2008 00:00:45 +0100, Hrvoje Niksic wrote: > Ben Finney <[EMAIL PROTECTED]> writes: > >> Hrvoje Niksic <[EMAIL PROTECTED]> writes: >> >>> Wildemar Wildenburger <[EMAIL PROTECTED]> writes: >>> > __init__() /initializes/ an instance (automatically after creation). >>> > It is called,

Re: "env" parameter to "popen" won't accept Unicode on Windows - minor Unicode bug

2008-01-14 Thread Benjamin
On Jan 14, 6:26 pm, John Nagle <[EMAIL PROTECTED]> wrote: > I passed a dict for the "env" variable to Popen with Unicode strings > for the dictionary values. > > Got: > >File "D:\Python24\lib\subprocess.py", line 706, in _execute_child > TypeError: environment can only contain s

Re: "env" parameter to "popen" won't accept Unicode on Windows - minor Unicode bug

2008-01-14 Thread Benjamin
On Jan 14, 6:26 pm, Bjoern Schliessmann wrote: > John Nagle wrote: > > It turns out that the strings in the "env" parameter have to be > > ASCII, not Unicode, even though Windows fully supports Unicode in > > CreateProcess. > > Are you sure it supports Unicode, not UTF8 or UTF16? Probably using >

SimCity GPLed

2008-01-14 Thread Terry Reedy
http://weblogs.asp.net/bsimser/archive/2008/01/10/simcity-source-code-released-to-the-wild-let-the-ports-begin.aspx The release appears to include both a C/Tcl/TK version and a C++/Python version of at least part. "The code hopefully serves as a good example of how to use SWIG to integrate C++

Re: short path evaluation, why is f() called here: dict(a=1).get('a', f())

2008-01-14 Thread Steven D'Aprano
On Mon, 14 Jan 2008 15:15:28 -0800, Paul Rubin wrote: > Steven D'Aprano <[EMAIL PROTECTED]> writes: >> map = {'a': Aclass, 'b': Bclass, 'c': Cclass} class_ = map.get(astring, >> default=Zclass) >> >> The result I want is the class, not the result of calling the class >> (which would be an instanc

Restart crashing modules in windows

2008-01-14 Thread Astan Chee
Hi, I have a python module that keeps on crashing with various windows errors (not BSOD but the less lethal windows XP popup ones). Now these are intentional and rather sporadic so I cant really solve it by attempting to fix the crash; rather what Im trying to do is make another module outside

Re: jpype with JFreeChart, anyone interested to help?

2008-01-14 Thread oyster
Thanx However I knew Chaco and matplotlib, and I use matplotlib during my school days. And as I have pointed out, they are for "plot", but not "chart". If you don't know the difference between plot and chart, you can have a look at at http://www.jfree.org/jfreechart, http://www.rmchart.com Yes, it

Re: super, decorators and gettattribute

2008-01-14 Thread Basilisk96
On Jan 14, 7:53 am, Michele Simionato <[EMAIL PROTECTED]> wrote: > I really need to publish this one day or another, since these > questions > about super keeps coming out: > > http://www.phyast.pitt.edu/~micheles/python/super.html Please do. It is a very enlightening discussion, and I'm sure a bu

Re: NotImplimentedError

2008-01-14 Thread George Sakkis
On Jan 14, 5:39 pm, Ben Finney <[EMAIL PROTECTED]> wrote: > I think of NotImplemented as equivalent to None; it's useful as a > sentinel value to set an attribute to in (e.g.) an abstract class. My guess would be that it is more of an implementation performance decision than semantic. Checking 'i

Re: Dynamical scoping

2008-01-14 Thread Paul Rubin
George Sakkis <[EMAIL PROTECTED]> writes: > What's the best way to simulate dynamically scoped variables ala Lisp ? Ugh check the docs for the python 2.5 "with" statement, which gives you sort of a programmable unwind-protect (more powerful than try/except). You'd have an environment diction

Re: module naming conventions

2008-01-14 Thread grackle
On Jan 14, 6:28 pm, Ben Finney <[EMAIL PROTECTED]> wrote: > grackle <[EMAIL PROTECTED]> writes: > What do you mean by "top-level module", and "the same top-level name"? > Do you mean "the same fully-qualified name"? If two modules are in > separate places in the hierarchy, they will have different

Data mapper - need to map an dictionary of values to a model

2008-01-14 Thread Luke
I am writing an order management console. I need to create an import system that is easy to extend. For now, I want to accept an dictionary of values and map them to my data model. The thing is, I need to do things to certain columns: - I need to filter some of the values (data comes in as -MM

Re: module naming conventions

2008-01-14 Thread Carl Banks
On Jan 14, 11:44 am, grackle <[EMAIL PROTECTED]> wrote: > Obviously Java-style naming is a mistake in Python, since top-level > names have to be unique. Is there a standard naming convention to > facilitate mixing code from different sources, such as > mygroupname_modulename? Is there a best prac

Re: module naming conventions

2008-01-14 Thread Ben Finney
grackle <[EMAIL PROTECTED]> writes: > I do use packages. I mentioned the Java naming conventions because > they were my first thought for solving the problem of name clashes, > and they work well in some non-Java languages. They don't apply well > to Python, since every top-level module has a uniq

Re: "env" parameter to "popen" won't accept Unicode on Windows - minor Unicode bug

2008-01-14 Thread Bjoern Schliessmann
John Nagle wrote: > It turns out that the strings in the "env" parameter have to be > ASCII, not Unicode, even though Windows fully supports Unicode in > CreateProcess. Are you sure it supports Unicode, not UTF8 or UTF16? Probably using something like u"thestring".encode("utf16") will help. Rega

"env" parameter to "popen" won't accept Unicode on Windows - minor Unicode bug

2008-01-14 Thread John Nagle
I passed a dict for the "env" variable to Popen with Unicode strings for the dictionary values. Got: File "D:\Python24\lib\subprocess.py", line 706, in _execute_child TypeError: environment can only contain strings It turns out that the strings in the "env" parameter have to b

Re: LANG, locale, unicode, setup.py and Debian packaging

2008-01-14 Thread Neil Hodgson
Martin v. Löwis: > That's not true. Try open("\xff","w"), then try interpreting the file > name as UTF-8. Some byte strings are not meaningful UTF-8, hence that > approach cannot work. Has it been decided how Python 3.0 will implement os.listdir on Unix? Will there be only a single attempt t

Re: module naming conventions

2008-01-14 Thread grackle
On Jan 14, 4:47 pm, Ben Finney <[EMAIL PROTECTED]> wrote: > I'm not sure, but it sounds as though you have yet to discover Python > module packages http://www.python.org/doc/essays/packages.html>. > They allow a hierarchy of modules in directories. I do use packages. I mentioned the Java naming c

Re: super, decorators and gettattribute

2008-01-14 Thread Richard Szopa
On Jan 14, 11:05 pm, thebjorn <[EMAIL PROTECTED]> wrote: > I don't remember if CLOS was changed to use C3 Linearization also, but > the concept came from Dylan (http://www.webcom.com/haahr/dylan/ > linearization-oopsla96.html) and that's what is implemented in Python. The Common Lisp ANSI standar

Re: SyntaxError: 'import *' not allowed with 'from .'

2008-01-14 Thread Carl Banks
On Jan 14, 2:37 pm, George Sakkis <[EMAIL PROTECTED]> wrote: > Unless I missed it, PEP 328 doesn't mention anything about this. > What's the reason for not allowing "from .relative.module import *' ? I'm just guessing: it could accidentally create infinite recursion. Or, perhaps something more sub

Re: NotImplimentedError

2008-01-14 Thread Ben Finney
Ben Finney <[EMAIL PROTECTED]> writes: > I think of NotImplemented as equivalent to None Not "equivalent"; rather "comparable in usage". -- \ "[W]e are still the first generation of users, and for all that | `\ we may have invented the net, we still don't really get it." | _o__)

Re: import from question

2008-01-14 Thread George Sakkis
On Jan 14, 4:22 pm, iu2 <[EMAIL PROTECTED]> wrote: > Hi all > > I've got three files: > > file a1.py: > > the_number = None > > file a2.py: > > import a1 > > def init(): > a1.the_number = 100 > > file a3.py: > > from a1 import the_number > import a2 > > a2.init() > pr

Re: LANG, locale, unicode, setup.py and Debian packaging

2008-01-14 Thread Martin v. Löwis
> Ah. Can one call it after the full call has been done: > locale.setlocale(locale.LC_ALL,'') > locale.setlocale(locale.LC_ALL) > Without any issues? If you pass LC_ALL, then some systems will give you funny results (semicolon-separated enumerations of all the categoryies). Instead, pick a specifi

Re: short path evaluation, why is f() called here: dict(a=1).get('a', f())

2008-01-14 Thread Paul Rubin
Steven D'Aprano <[EMAIL PROTECTED]> writes: > map = {'a': Aclass, 'b': Bclass, 'c': Cclass} > class_ = map.get(astring, default=Zclass) > > The result I want is the class, not the result of calling the class > (which would be an instance). If I wanted the other semantics, I'd be > using defaultd

Re: __init__ explanation please

2008-01-14 Thread Hrvoje Niksic
Ben Finney <[EMAIL PROTECTED]> writes: > Hrvoje Niksic <[EMAIL PROTECTED]> writes: > >> Wildemar Wildenburger <[EMAIL PROTECTED]> writes: >> > __init__() /initializes/ an instance (automatically after >> > creation). It is called, /after/ the instance has been constructed >> >> I don't understand

Re: SyntaxError: 'import *' not allowed with 'from .'

2008-01-14 Thread George Sakkis
On Jan 14, 6:01 pm, Ben Finney <[EMAIL PROTECTED]> wrote: > George Sakkis <[EMAIL PROTECTED]> writes: > > Unless I missed it, PEP 328 doesn't mention anything about this. > > What's the reason for not allowing "from .relative.module import *' > > ? > > It makes the code much harder to follow visua

Re: paging in python shell

2008-01-14 Thread Ben Finney
John Machin <[EMAIL PROTECTED]> writes: > C:\junk>python demomore.py | more Your example uses the OS shell to invoke a pager on the output of the Python process. The OP was asking about paging *within* the Python shell. To my knowledge there's nothing in the default Python shell that enables wha

Re: Append zip files together, just get the binary data (in memory)

2008-01-14 Thread BerlinBrown
On Jan 14, 5:58 pm, "Diez B. Roggisch" <[EMAIL PROTECTED]> wrote: > BerlinBrown schrieb: > > > Is it possible to just build the binary content of a zip file. I want > > to create the content in memory (e.g. return binary data) and then get > > those byte strings representing the zip file? Is that

Re: SyntaxError: 'import *' not allowed with 'from .'

2008-01-14 Thread Ben Finney
George Sakkis <[EMAIL PROTECTED]> writes: > Unless I missed it, PEP 328 doesn't mention anything about this. > What's the reason for not allowing "from .relative.module import *' > ? It makes the code much harder to follow visually and inspect with static analysis tools, since there's no way to s

Perl Template Toolkit: Now in spicy new Python flavor

2008-01-14 Thread [EMAIL PROTECTED]
I'd like to inform the Python community that the powerful and popular Template Toolkit system, previously available only in its original Perl implementation, is now also available in a beta Python implementation: http://tt2.org/python/index.html I created this port both as a fun programming proje

Re: Append zip files together, just get the binary data (in memory)

2008-01-14 Thread Diez B. Roggisch
BerlinBrown schrieb: > Is it possible to just build the binary content of a zip file. I want > to create the content in memory (e.g. return binary data) and then get > those byte strings representing the zip file? Is that possible? > > Or could I possibly override functions in the zip class. >

Re: super, decorators and gettattribute

2008-01-14 Thread Richard Szopa
On Jan 14, 1:53 pm, Michele Simionato <[EMAIL PROTECTED]> wrote: > I really need to publish this one day or another, since these > questions > about super keeps coming out: > > http://www.phyast.pitt.edu/~micheles/python/super.html Thanks, Michele! Your essay was enlightening [2]. Specially if yo

Re: module naming conventions

2008-01-14 Thread Ben Finney
grackle <[EMAIL PROTECTED]> writes: > Obviously Java-style naming is a mistake in Python, since top-level > names have to be unique. Is there a standard naming convention to > facilitate mixing code from different sources, such as > mygroupname_modulename? Is there a best practices guide for mod

Re: LANG, locale, unicode, setup.py and Debian packaging

2008-01-14 Thread Donn
> You get the full locale name with locale.setlocale(category) (i.e. > without the second argument) Ah. Can one call it after the full call has been done: locale.setlocale(locale.LC_ALL,'') locale.setlocale(locale.LC_ALL) Without any issues? > > I need that two-letter code that's hidden in a > > t

Re: NotImplimentedError

2008-01-14 Thread Ben Finney
George Sakkis <[EMAIL PROTECTED]> writes: > By the way, why do we need both NotImplementedError and the > NotImplemented singleton object ? Couldn't we have just one of them ? One of them is an exception class, the other is not. They have rather different semantics. I think of NotImplemented as

Re: [ANN] pylint 0.14 / logilab-astng 0.17.2

2008-01-14 Thread Ben Finney
Sylvain Thénault <[EMAIL PROTECTED]> writes: > I'm pleased to announce a new release of pylint [1] and logilab-astng > [2]. I haven't personally found a lot of time to work on those projects > since the latest releases but others contributors have and so I decided > to publish releases including v

Re: super, decorators and gettattribute

2008-01-14 Thread Ben Finney
Michele Simionato <[EMAIL PROTECTED]> writes: > I really need to publish this one day or another, since these > questions about super keeps coming out: > > http://www.phyast.pitt.edu/~micheles/python/super.html Yes, please. Your article has improved my understanding just from skimming the main h

Re: encrypting python modules

2008-01-14 Thread Ben Finney
Robert Latest <[EMAIL PROTECTED]> writes: > And, contrary to the advice I gave elsethread, unfortunately it's > impossible to just drop uncooperative customers when you develop GPL > software ;-) On the contrary. The GPL includes a big fat "NO WARRANTY" clause. If you're not selling warranties to

Re: __init__ explanation please

2008-01-14 Thread Ben Finney
Hrvoje Niksic <[EMAIL PROTECTED]> writes: > Wildemar Wildenburger <[EMAIL PROTECTED]> writes: > > __init__() /initializes/ an instance (automatically after > > creation). It is called, /after/ the instance has been constructed > > I don't understand the purpose of this "correction". After all, >

Append zip files together, just get the binary data (in memory)

2008-01-14 Thread BerlinBrown
Is it possible to just build the binary content of a zip file. I want to create the content in memory (e.g. return binary data) and then get those byte strings representing the zip file? Is that possible? Or could I possibly override functions in the zip class. 1. Create a zip file object (e.g.

Re: super, decorators and gettattribute

2008-01-14 Thread thebjorn
On Jan 14, 1:41 pm, Richard Szopa <[EMAIL PROTECTED]> wrote: > On Jan 13, 3:31 pm, thebjorn <[EMAIL PROTECTED]> > wrote: > > > They do, except for when it comes to what super(..) returns. It isn't > > really an object in the sense that they're presented in the tutorial, > > but rather a sort of pro

Re: short path evaluation, why is f() called here: dict(a=1).get('a', f())

2008-01-14 Thread Tim Chase
> But how can Python determine when you want the result to be *the > callable* and when you want it to be *the result of calling the > callable*? > > Functions and other callables are first-class objects, and it is quite > reasonable to have something like this: > > map = {'a': Aclass, 'b': B

Re: split parameter line with quotes

2008-01-14 Thread Ricardo Aráoz
teddyber wrote: > here's the solution i have for the moment : > > t = shlex.shlex(data) > t.wordchars = t.wordchars + "/+.-" > r='' > while 1: > token = t.get_token() > if not token: > break > if not token==',': r = r+token >

Re: hide object property from dir() function?

2008-01-14 Thread Matimus
On Jan 14, 1:20 pm, jerryji <[EMAIL PROTECTED]> wrote: > Hi, > > Sorry for this newbie question, I was puzzled why the existing > property of an object is not shown in the dir() function output. > > "v" is an lxml Element object variable -- > > In [44]: v > Out[44]: > > In [45]: dir(v) > Out[45]:

Re: LANG, locale, unicode, setup.py and Debian packaging

2008-01-14 Thread Martin v. Löwis
> Given that getlocale() is not to be used, what's the best way to get the > locale later in the app? You get the full locale name with locale.setlocale(category) (i.e. without the second argument) > I need that two-letter code that's hidden in a > typical locale like en_ZA.utf8 -- I want that

Re: X/Linux mouse_event (like in win32api)

2008-01-14 Thread Atila Olah
Thank you Jorgen. Your answer helped me a lot. -- http://mail.python.org/mailman/listinfo/python-list

Re: short path evaluation, why is f() called here: dict(a=1).get('a', f())

2008-01-14 Thread Steven D'Aprano
On Mon, 14 Jan 2008 12:08:52 -0800, Paul Rubin wrote: > aspineux <[EMAIL PROTECTED]> writes: >> Yes, I missed 'get' and 'setdefault' are functions :-) Then why not >> some new semantic >> >> d.get('a', f()) --> d['a', f()] >> d.setdefault('a', f()) --> d['a'=f()] >> >> Is is a good idea enou

Re: problem with logging exceptions with non-ASCII __str__ result

2008-01-14 Thread Vinay Sajip
On Jan 14, 5:46 pm, Karsten Hilbert <[EMAIL PROTECTED]> wrote: > Dear all, > > I have a problem withloggingan exception. > > environment: > > Python 2.4, Debian testing > > ${LANGUAGE} not set > ${LC_ALL} not set > ${LC_CTYPE} not set > ${LANG}=de_DE.UTF-8 >

Re: encrypting python modules

2008-01-14 Thread Steven D'Aprano
On Mon, 14 Jan 2008 12:46:48 +, Robert Latest wrote: > And, contrary to the advice I gave elsethread, unfortunately it's > impossible to just drop uncooperative customers when you develop GPL > software ;-) Just because you are writing GPLed code doesn't mean you are permanently linked to an

import from question

2008-01-14 Thread iu2
Hi all I've got three files: file a1.py: the_number = None file a2.py: import a1 def init(): a1.the_number = 100 file a3.py: from a1 import the_number import a2 a2.init() print the_number, type(the_number) Runninr a3.py I get: None Changing a3.py to: import a

Re: __init__ explanation please

2008-01-14 Thread Steven D'Aprano
On Mon, 14 Jan 2008 22:18:44 +1100, Ben Finney wrote: > What one is "in reality" calling is the '__new__' method of the Person > class. That function, in turn, is creating a new Person instance, and > calling the '__init__' method of the newly-created instance. Finally, > the '__new__' method retu

hide object property from dir() function?

2008-01-14 Thread jerryji
Hi, Sorry for this newbie question, I was puzzled why the existing property of an object is not shown in the dir() function output. "v" is an lxml Element object variable -- In [44]: v Out[44]: In [45]: dir(v) Out[45]: ['__copy__', '__deepcopy__', '__reduce__', 'append', 'clear', 'find',

Re: Simple List division problem

2008-01-14 Thread Pierre Quentel
On 12 jan, 19:37, marcstuart <[EMAIL PROTECTED]> wrote: > How do I divide a list into a set group of sublist's- if the list is > not evenly dividable ? > consider this example: > > x = [1,2,3,4,5,6,7,8,9,10] > y = 3 # number of lists I want to break x into > z = y/x > > what I would like to ge

Re: paging in python shell

2008-01-14 Thread Alex K
Thanks John, but would it be possible to remain in the python interpreter? On 14/01/2008, John Machin <[EMAIL PROTECTED]> wrote: > On Jan 15, 7:35 am, "Alex K" <[EMAIL PROTECTED]> wrote: > > Hi Tim, > > > > Yes I mean piping the output into "more" for example. > > > > Why don't you "suck it and se

Re: paging in python shell

2008-01-14 Thread John Machin
On Jan 15, 7:35 am, "Alex K" <[EMAIL PROTECTED]> wrote: > Hi Tim, > > Yes I mean piping the output into "more" for example. > Why don't you "suck it and see"??? E.g. C:\junk>copy con demomore.py for i in range(100): print 'line', i ^Z 1 file(s) copied. C:\junk>python demomore.py | m

Re: time.time or time.clock

2008-01-14 Thread John Machin
On Jan 15, 4:50 am, [EMAIL PROTECTED] wrote: > """ > > time.clock() isn't high enough resolution for Ubuntu, and time.time() > isn't > high enough resolution on windows. > > Take a look at datetime. It is good to the micro-second on Linux and > milli-second on Windows. > """ On Windows, time.clo

Re: paging in python shell

2008-01-14 Thread Alex K
Hi Tim, Yes I mean piping the output into "more" for example. Alex On 14/01/2008, Tim Roberts <[EMAIL PROTECTED]> wrote: > "Alex K" <[EMAIL PROTECTED]> wrote: > > > >Does anyone know if the python shell supports paging or if I should > >look into iPython? Thank you so much. > > "Paging" is an ov

Dynamical scoping

2008-01-14 Thread George Sakkis
What's the best way to simulate dynamically scoped variables ala Lisp ? The use case is an open-ended set of objects that need to access the same piece of information (e.g. a dict, a ConfigParser object, a logger etc.). I know that the "proper" OO and functional way is to pass the information expl

Re: How to get user home directory on Windows

2008-01-14 Thread Giampaolo Rodola'
Thanks to Tim Golden suggestions I solved my problem. ...In case it would help someone: import _winreg import win32security username = 'Administrator' sid = win32security.ConvertSidToStringSid( win32security.LookupAccountName(None, username)[0] ) key = _winreg.OpenKey( _win

Re: short path evaluation, why is f() called here: dict(a=1).get('a', f())

2008-01-14 Thread Paul Rubin
aspineux <[EMAIL PROTECTED]> writes: > Yes, I missed 'get' and 'setdefault' are functions :-) > Then why not some new semantic > > d.get('a', f()) --> d['a', f()] > d.setdefault('a', f()) --> d['a'=f()] > > Is is a good idea enough to change the python semantic ? > Or simply is it a good idea

Re: [Kamaelia] TCPClient: How to sense connection failure?

2008-01-14 Thread Bjoern Schliessmann
Michael Sparks wrote: > It is sufficient, and running with Kamaelia from /trunk, your > listener does indeed shutdown correctly Great, thanks for validating. :) > My suggestion for the moment would be to use the code on /trunk > since this is stable at present (development happens on branches >

Re: bags? 2.5.x?

2008-01-14 Thread Wildemar Wildenburger
Dan Stromberg wrote: > Is there a particular reason why bags didn't go into 2.5.x or 3000? > > I keep wanting something like them - especially bags with something akin > to set union, intersection and difference. > How about this recepie http://www.ubookcase.com/book/Oreilly/Python.Cookbook.2nd

SyntaxError: 'import *' not allowed with 'from .'

2008-01-14 Thread George Sakkis
Unless I missed it, PEP 328 doesn't mention anything about this. What's the reason for not allowing "from .relative.module import *' ? George -- http://mail.python.org/mailman/listinfo/python-list

Re: help with slicing/replacing matrix sections.

2008-01-14 Thread Robert Kern
Erik Lind wrote: > I see a more complicated thread on a similar sounding question, but my > question is simpler, I hope. numpy questions are usually answered better on the numpy mailing list. http://www.scipy.org/Mailing_Lists > I have a large numpy matrix, initially created as: > > Mat = z

Re: time.time or time.clock

2008-01-14 Thread Fredrik Lundh
[EMAIL PROTECTED] wrote: > """ > > time.clock() isn't high enough resolution for Ubuntu, and time.time() > isn't > high enough resolution on windows. > > Take a look at datetime. It is good to the micro-second on Linux and > milli-second on Windows. datetime.datetime.now() does the same thing

help with slicing/replacing matrix sections.

2008-01-14 Thread Erik Lind
I see a more complicated thread on a similar sounding question, but my question is simpler, I hope. I have a large numpy matrix, initially created as: Mat = zeros((a,b), int) and a smaller array with other data Sub = [1,2,3,4,5],[6,7,8,9,0] I want to replace a section of Mat matrix with Sub m

Re: short path evaluation, why is f() called here: dict(a=1).get('a', f())

2008-01-14 Thread aspineux
On Jan 14, 7:49 pm, "Chris Mellon" <[EMAIL PROTECTED]> wrote: > On Jan 14, 2008 12:39 PM, aspineux <[EMAIL PROTECTED]> wrote: > > > > > This append in both case > > > dict(a=1).get('a', f()) > > dict(a=1).setdefault('a', f()) > > > This should be nice if f() was called only if required. > > Think a

Re: How to get user home directory on Windows

2008-01-14 Thread Lie
On Jan 14, 8:21 am, "Martin P. Hellwig" <[EMAIL PROTECTED]> wrote: > Giampaolo Rodola' wrote: > > Hi all, > > I'm trying to use the pywin32 extension to find out the user's home > > directory but currently I didn't find a solution yet. > > What I'd need to do is not getting the home directory of th

Re: __init__ explanation please

2008-01-14 Thread Hrvoje Niksic
"Reedick, Andrew" <[EMAIL PROTECTED]> writes: >> Only if by "construct" you mean "allocate". __init__ starts out >> with an empty object and brings it to a valid state, therefore >> "constructing" the object you end up with. That operation is >> exactly what other languages call a constructor. >

Re: short path evaluation, why is f() called here: dict(a=1).get('a', f())

2008-01-14 Thread Neil Cerutti
On Jan 14, 2008 1:39 PM, aspineux <[EMAIL PROTECTED]> wrote: > > This append in both case > > dict(a=1).get('a', f()) > dict(a=1).setdefault('a', f()) > > This should be nice if f() was called only if required. Shortcomings of those methods is probably why collections.defaultdict is so popular. >

Re: Magic function

2008-01-14 Thread dg . google . groups
Hi Rüdiger, Thanks for your message. I liked your approach and I've been trying something along exactly these sorts of lines, but I have a few problems and queries. The first problem is that the id of the frame object can be re-used, so for example this code (where I haven't defined InstanceTrac

Re: Exceptions - How do you make it work like built-in exceptions?

2008-01-14 Thread Lie
On Jan 14, 1:51 am, "Mark Tolonen" <[EMAIL PROTECTED]> wrote: > "Lie" <[EMAIL PROTECTED]> wrote in message > > news:[EMAIL PROTECTED] > > > > >A built-in exceptions, when raised, would print traceback that points > > out the offending code, like this: > > > Traceback (most recent call last): > >  F

Re: short path evaluation, why is f() called here: dict(a=1).get('a', f())

2008-01-14 Thread Chris Mellon
On Jan 14, 2008 12:39 PM, aspineux <[EMAIL PROTECTED]> wrote: > > This append in both case > > dict(a=1).get('a', f()) > dict(a=1).setdefault('a', f()) > > This should be nice if f() was called only if required. > Think about the change to Python semantics that would be required for this to be tru

Re: __init__ explanation please

2008-01-14 Thread Neil Cerutti
On Jan 14, 2008 12:08 PM, Reedick, Andrew <[EMAIL PROTECTED]> wrote: > > -Original Message- > > From: [EMAIL PROTECTED] [mailto:python- > > [EMAIL PROTECTED] On Behalf Of Hrvoje Niksic > > Sent: Monday, January 14, 2008 11:29 AM > > Only if by "construct" you mean "allocate". __init__ star

short path evaluation, why is f() called here: dict(a=1).get('a', f())

2008-01-14 Thread aspineux
This append in both case dict(a=1).get('a', f()) dict(a=1).setdefault('a', f()) This should be nice if f() was called only if required. Regards. -- http://mail.python.org/mailman/listinfo/python-list

Re: wxpython-wx.CheckListBox: changing item bacgkground color

2008-01-14 Thread Mike
On Jan 13, 9:22 am, Massi <[EMAIL PROTECTED]> wrote: > Hi everyone! In my application (under windows) I'm using a > wx.checklistbox. I would like the background color of an item to > become red whenever an EVT_LISTBOX_DCLICK occurs. Is there any simple > way to achieve it? > Thanks in advance. Did

Re: Basic inheritance question

2008-01-14 Thread Lie
On Jan 7, 2:46 am, Bruno Desthuilliers <[EMAIL PROTECTED]> wrote: > Lie a écrit : > > > On Jan 5, 5:40 pm, [EMAIL PROTECTED] wrote: > > >>Jeroen Ruigrok van der Werven wrote: > > >>>Shouldn't this be: > > >>>self.startLoc = start > >>>self.stopLoc = stop > > >>Thanks! Of course it should. Old Java

Parsing links within a html file.

2008-01-14 Thread Shriphani
Hello, I have a html file over here by the name guide_ind.html and it contains links to other html files like guides.html#outline . How do I point BeautifulSoup (I want to use this module) to guides.html#outline ? Thanks Shriphani P. -- http://mail.python.org/mailman/listinfo/python-list

Re: time.time or time.clock

2008-01-14 Thread dwblas
""" time.clock() isn't high enough resolution for Ubuntu, and time.time() isn't high enough resolution on windows. Take a look at datetime. It is good to the micro-second on Linux and milli-second on Windows. """ import datetime begin_time=datetime.datetime.now() for j in range(10): x =

problem with logging exceptions with non-ASCII __str__ result

2008-01-14 Thread Karsten Hilbert
Dear all, I have a problem with logging an exception. environment: Python 2.4, Debian testing ${LANGUAGE} not set ${LC_ALL} not set ${LC_CTYPE} not set ${LANG}=de_DE.UTF-8 activating user-default locale with returns: [de_DE.UTF-8] local

bags? 2.5.x?

2008-01-14 Thread Dan Stromberg
Is there a particular reason why bags didn't go into 2.5.x or 3000? I keep wanting something like them - especially bags with something akin to set union, intersection and difference. -- http://mail.python.org/mailman/listinfo/python-list

Re: super, decorators and gettattribute

2008-01-14 Thread George Sakkis
On Jan 12, 6:56 pm, Steven D'Aprano <[EMAIL PROTECTED] cybersource.com.au> wrote: > On Sat, 12 Jan 2008 15:47:05 -0500, Mike Meyer wrote: > > There's an apparently common bug here: you don't want to pass super > > self.__class__, but the class that the method is bound to. > > Given an instance met

Re: IDLE won't start in Python 2.5 for Windows

2008-01-14 Thread mikez302
I was able to start IDLE from the command line, and reset my keyboard shortcuts. It works fine now. In case this happens again, where would I find the config file? -- http://mail.python.org/mailman/listinfo/python-list

RE: __init__ explanation please

2008-01-14 Thread Reedick, Andrew
> -Original Message- > From: [EMAIL PROTECTED] [mailto:python- > [EMAIL PROTECTED] On Behalf Of Hrvoje Niksic > Sent: Monday, January 14, 2008 11:29 AM > To: python-list@python.org > Subject: Re: __init__ explanation please > > Mel <[EMAIL PROTECTED]> writes: > > >> I don't understand the

  1   2   >