Confused about logger config from within Python (3)

2012-12-28 Thread andrew cooke
When I use a config file things seem to work (in other projects), but for my current code I hoped to configure logging from Python. I distilled my problem down to the following test, which does not print anything. Please can someone explain why? I was expecting the module's logger to delegate

Re: Confused about logger config from within Python (3)

2012-12-28 Thread andrew cooke
similarly, if i run the following, i see only "done": from logging import DEBUG, root, getLogger if __name__ == '__main__': root.setLevel(DEBUG) getLogger(__name__).debug("hello world") print('done') -- http://mail.python.org/mailman/listinfo/python-list

Re: Confused about logger config from within Python (3)

2012-12-28 Thread andrew cooke
On Friday, 28 December 2012 21:56:46 UTC-3, Peter Otten wrote: > Other revolutionary ideas: read the docs > > ;) how do you think i knew about the root handler without reading the damn docs you condescending asshole? anywa

ordering with duck typing in 3.1

2012-04-07 Thread andrew cooke
hi, please, what am i doing wrong here? the docs say http://docs.python.org/release/3.1.3/library/stdtypes.html#comparisons "in general, __lt__() and __eq__() are sufficient, if you want the conventional meanings of the comparison operators" but i am seeing > assert 2 < three E T

python3.2m installed as (additional) binary

2011-02-27 Thread andrew cooke
Hi, I just downloaded, built and altinstalled Python3.2 on Linux x64. I noticed that in /usr/local/bin I have two identical (says diff) binaries called Python3.2 and Python3.2m. Is this expected? I can find very little reference to them apart from a short discussion in python-dev where some

Re: python3.2m installed as (additional) binary

2011-02-27 Thread andrew cooke
[Sorry I clicked the wrong button so I think my prev reply went only to Tom] Thanks. Yes, they're hard linked. And the bug report mentions PEP 3149 which says that "m" means --with-pymalloc was used http://www.python.org/dev/peps/pep-3149/ Cheers, Andrew -- http://mail.python.org/mailman/lis

Why is return type in getfullspec().annotations named as "return"?

2011-04-02 Thread andrew cooke
This conflicts with any parameter named "return". Wouldn't it have been better to use "->" as the key? Is there any way this can be changed? Andrew -- http://mail.python.org/mailman/listinfo/python-list

Re: Why is return type in getfullspec().annotations named as "return"?

2011-04-02 Thread andrew cooke
Sorry, ignore that. I just realised that "return" will be a reserved word, so that can't happen. Andrew -- http://mail.python.org/mailman/listinfo/python-list

Why is __root checked for in OrderedDict?

2011-04-07 Thread andrew cooke
If you look at the code in http://hg.python.org/cpython/file/6adbf5f3dafb/Lib/collections/__init__.py#l49 the attribute __root is checked for, and only created if missing. Why? I ask because, from what I understand, the __init__ method will only be called when the object is first being created

Re: Why is __root checked for in OrderedDict?

2011-04-07 Thread andrew cooke
Is that normal? I mean, OK, it's possible (and yes I forgot it could be called directly), but is there any usual reason to do so? I guess what I'm asking is: if I'm writing library code should I be this careful? (I've written quite a lot of Python code without this ever biting me, but maybe

Confused about __prepare__

2011-04-07 Thread andrew cooke
In the code below I use __prepare__ to change the class dictionary so that a tuple is stored in __setitem__(). Since __getitem__() removes the tuple I wasn't expecting any problems, but it seems that __init__ is being retrieved via some other mechanism. Why? Is a copy of the dict being made

Re: Confused about __prepare__

2011-04-07 Thread andrew cooke
Sorry I should probably have made clear that this is Python 3.2 -- http://mail.python.org/mailman/listinfo/python-list

Re: Confused about __prepare__

2011-04-07 Thread andrew cooke
Yes, I think you're right, thanks. Makes sense from an efficiency POV. Luckily, it turns out I don't need to do that anyway :o) Cheers, Andrew -- http://mail.python.org/mailman/listinfo/python-list

Replacing *instance* dict

2011-04-07 Thread andrew cooke
x27;three' assert d.a == 'three' print('woop') On Thursday, April 7, 2011 7:31:16 PM UTC-3, andrew cooke wrote: > > class TupleDict(dict): > '''Stores additional info, but removes it on __getitem__().''' > >

My stupidity / strange inconsistency overriding class methods

2011-04-19 Thread andrew cooke
Hi, I've been staring at this problem, in various forms, all day. Am I missing something obvious, or is there some strange hardwiring of isinstance? This is with Python 3.2. class A(metaclass=ABCMeta): @classmethod def __instancecheck__(cls, instance): return F

Re: My stupidity / strange inconsistency overriding class methods

2011-04-19 Thread andrew cooke
Also, there's something strange about the number of arguments (they're not consistent between the two examples - the "A" to __instancecheck__ should not be needed). Yet it compiles and runs like that. Very confused :o( -- http://mail.python.org/mailman/listinfo/python-list

Re: My stupidity / strange inconsistency overriding class methods

2011-04-19 Thread andrew cooke
OK, sorry, I see the mistake. I'm confusing __class__ on the instance and on te class (the latter being the metaclass). Sorry again, Andrew -- http://mail.python.org/mailman/listinfo/python-list

Re: My stupidity / strange inconsistency overriding class methods

2011-04-20 Thread andrew cooke
Thanks for finding that reference in the data model docs! I was about to post a bug report because in PEP 3119 it says otherwise: > The primary mechanism proposed here is to allow overloading the built-in > functions isinstance() and issubclass(). The overloading works as follows: > The call i

Re: My stupidity / strange inconsistency overriding class methods

2011-04-20 Thread andrew cooke
I didn't phrase that very well. I do see the point about this being "an instance lookup on a class"... -- http://mail.python.org/mailman/listinfo/python-list

Re: meteclasses 2.x/3.x compatibility

2011-04-20 Thread andrew cooke
What I do in Lepl is use two stages. The first calls the type/metaclass directly and the second subclasses that. This avoids using the "sugar" that changes between 2 and 3. So, for example, in http://code.google.com/p/lepl/source/browse/src/lepl/matchers/matcher.py#40 I have _Matcher = AB

Re: Language & lib reference in man format ?

2011-04-20 Thread andrew cooke
(1) Python's docs use Sphinx, which uses restructured text as a markup. You can generate man pages from restructured text using rst2man (which is installed on my computer, probably as part of python/docutils). HOWEVER I imagine it's not going to work very well, if at all, because Sphinx uses l

ABC-registered Exceptions are not caught as subclasses

2011-05-07 Thread andrew cooke
This isn't hugely surprising, but doesn't seem to be documented. Is it a bug, or worth raising as one, or have I misunderstood? Python 3.2 (r32:88445, Feb 27 2011, 13:00:05) [GCC 4.5.0 20100604 [gcc-4_5-branch revision 160292]] on linux2 Type "help", "copyright", "credits" or "license" for mo

Re: ABC-registered Exceptions are not caught as subclasses

2011-05-08 Thread andrew cooke
http://bugs.python.org/issue12029 -- http://mail.python.org/mailman/listinfo/python-list

Basic misunderstanding on object creation

2015-05-13 Thread andrew cooke
Hi, The following code worked on Python 3.2, but no longer works in 3.4. Did something change, or have I always been doing something dumb? (I realise the code is pointless as is - it's the simplest example I can give of a problem I am seeing with more complex code). >>> class Foo: ... de

Re: Basic misunderstanding on object creation

2015-05-13 Thread andrew cooke
On Wednesday, 13 May 2015 11:36:12 UTC-3, Thomas Rachel wrote: > Am 13.05.2015 um 15:25 schrieb andrew cooke: > > >>>> class Foo: > > ... def __new__(cls, *args, **kargs): > > ... print('new', args, kargs) > > ... s

Re: Basic misunderstanding on object creation

2015-05-13 Thread andrew cooke
> But then nothing will be passed to __init__ on the subclass. > > Andrew >>> class Foo: ... def __new__(cls, *args, **kargs): ... print('new', args, kargs) ... super().__new__(cls) ... >>> class Bar(Foo): ... def __init__(self, a): ... print('init', a) ... >>> B

Re: Basic misunderstanding on object creation

2015-05-13 Thread andrew cooke
On Wednesday, 13 May 2015 11:56:21 UTC-3, Ian wrote: > On Wed, May 13, 2015 at 8:45 AM, andrew cooke wrote: > >>>> class Foo: > > ... def __new__(cls, *args, **kargs): > > ... print('new', args, kargs) > > ... sup

Re: Basic misunderstanding on object creation

2015-05-13 Thread andrew cooke
On Wednesday, 13 May 2015 13:37:23 UTC-3, Terry Reedy wrote: > On 5/13/2015 9:25 AM, andrew cooke wrote: > > > The following code worked on Python 3.2, but no longer works in 3.4. > > Bugfixes break code that depends on buggy behavior. See > https://bugs.python.org/issue168

ABCs, functions, and __call__ (Python3)

2009-01-16 Thread andrew cooke
I think I'm missing something obvious here, so apologies in advance. I'd like to be able to test whether something is a function or implements __call__. Now obviously I can do that as two separate tests, but I though this was what ABCs were for. However, for the life of me I cannot find what the

Re: *Advanced* Python book?

2009-01-16 Thread andrew cooke
not direct answers, but reading through the recipes can be interesting - http://code.activestate.com/recipes/langs/python/ also, reading any good computing book and then wondering how you can do that in python can help shed a new light on things. andrew -- http://mail.python.org/mailman/lis

Re: ABCs, functions, and __call__ (Python3)

2009-01-16 Thread andrew cooke
On Jan 16, 10:13 pm, Christian Heimes wrote: > Any callable in Python 3.0 has a "__call__" attribute. Aha! Thanks! Andrew -- http://mail.python.org/mailman/listinfo/python-list

Re: Pythonic way to handle coordinates

2009-01-17 Thread andrew cooke
although james's idea is quite neat (especially the idea of heritable classes), my initial reaction was that it's too over-engineered. so here's a different approach. there are two "tricks" that can help make using tuples easier: (1) unpacking the return value. (x, y) = returns_a_point() x +

Relax Syntax for Augmented Arithmetic?

2009-01-18 Thread andrew cooke
Context - http://docs.python.org/3.0/reference/datamodel.html?highlight=data model#object.__iadd__ Just a suggestion I thought I'd throw out... There's a restriction in the language implementation on exactly what can go the left of an augmented arithmetic expression. For example: >>> a = 3 >>> a

Re: Relax Syntax for Augmented Arithmetic?

2009-01-18 Thread andrew cooke
> Therefore, Python requires you to rewrite the code in some other way > that makes your intentions more clear. For instance, why not use the > << operator instead? Right, but you're guessing what the context is. Within a DSL it often makes a lot of sense to use operators for reasons that weren't

Re: what's the point of rpython?

2009-01-18 Thread andrew cooke
Since this is a PyPy bashing thread, maybe it's an appropriate place to suggest that the project has got a little bit waylaid by exploring cool things instead of releasing a useful final result? I am not questioning rpython directly - the case for something like that is obvious. But there's a que

Re: Relax Syntax for Augmented Arithmetic?

2009-01-18 Thread andrew cooke
Not sure if you were saying this, but the underlying technical reason for this issue is that they are treated as assignment rather than operators in the language spec - http://docs.python.org/3.0/reference/simple_stmts.html#augmented-assignment-statements I think this explains why they are not li

Re: Relax Syntax for Augmented Arithmetic?

2009-01-18 Thread andrew cooke
On Jan 18, 9:01 am, Chris Rebert wrote: > Indeed. Python happens to in this case draw the line at using the > augmented assignment operators for non-assignment. I personally see > this as reasonable because the = symbol has a consistent meaning in > Python (assignment) whereas the other plain oper

Re: Relax Syntax for Augmented Arithmetic?

2009-01-18 Thread andrew cooke
On Jan 18, 9:40 am, Marc 'BlackJack' Rintsch wrote: > On Sun, 18 Jan 2009 04:24:04 -0800, andrew cooke wrote: > > my argument was that *= is not treated as = and *, but as a completely > > new operator (the docs even say that the implementation need not return > >

Re: Relax Syntax for Augmented Arithmetic?

2009-01-18 Thread andrew cooke
On Jan 18, 9:56 am, andrew cooke wrote: > either i have misundertstood you ah, i see your point. sorry, andrew -- http://mail.python.org/mailman/listinfo/python-list

Re: Relax Syntax for Augmented Arithmetic?

2009-01-18 Thread andrew cooke
http://bugs.python.org/issue4986 Sorry for the noise, Andrew -- http://mail.python.org/mailman/listinfo/python-list

Re: Relax Syntax for Augmented Arithmetic?

2009-01-18 Thread andrew cooke
Improved link - http://docs.python.org/3.0/reference/datamodel.html#object.__iadd__ -- http://mail.python.org/mailman/listinfo/python-list

Re: function argument dependent on another function argument?

2009-01-18 Thread andrew cooke
>     sentinel = object() >     ... > >     def foo(x, y=sentinel): >       if y is sentinel: >           y = self.a it just struck me you could also do: def foo(self, x, *y_args) y = y_args[0] if y_args self.a which more directly checks whether an argument was passed, but has the do

Porting 3.0 to 2.6 - from __future__ import super missing?

2009-01-24 Thread andrew cooke
Hi, I have some 3.0 code, which I would like to make work with 2.6. However, there does not seem to be support for the new super() (no args) via __future__. Is that correct? If so, what's the best way to handle this? Thanks, Andrew -- http://mail.python.org/mailman/listinfo/python-list

Re: Porting 3.0 to 2.6 - from __future__ import super missing?

2009-01-24 Thread andrew cooke
On Jan 24, 10:39 am, Benjamin Peterson wrote: > andrew cooke acooke.org> writes: > > > > > Hi, > > > I have some 3.0 code, which I would like to make work with 2.6. > > However, there does not seem to be support for the new super() (no > > args) via __

Re: Porting 3.0 to 2.6 - from __future__ import super missing?

2009-01-24 Thread andrew cooke
On Jan 24, 2:32 pm, Benjamin Peterson wrote: > I would suggest that you use the 2.6 syntax, and run "2to3 -f metaclass" on > your > code. (ABCs have been backported to 2.6.) Thanks - with that hint I found this - http://mikewatkins.ca/2008/11/29/python-2-and-3-metaclasses/#using-the-metaclass-in

Re: SimpleXMLRPCServer question

2009-01-31 Thread andrew cooke
On Jan 30, 11:59 pm, flagg wrote: > I am working on a very basic xmlrpc server, which will expose certain > functions for administering BIND zone files.  The big problem I am > having is parsing the incoming xmlrpc request.  Basically part of the [...] at the risk of repeating what the other guy

Where to host a (Python) project?

2009-01-31 Thread andrew cooke
Hi, I have a new project, that I just released in beta (http:// www.acooke.org/lepl - a recursive decent parser with full backtracking). At the moment I am using pypi and setuptools for distribution (it's a pure python package) and I am happy with hosting static web pages (the manual and api doc

Re: Why do operators and methods of built-in types differ

2009-01-31 Thread andrew cooke
On Jan 31, 8:51 am, Csaba Hoch wrote: > What is the reason behind this difference between the __add__ operator > and int.__add__? this is quite common in python. the special methods like __add__ are used to implement some functionality (like '+' in this case), but they are not all of it. for ex

Re: Why do operators and methods of built-in types differ

2009-01-31 Thread andrew cooke
> Just a correction: according to the doc, NotImplemented is not an > error, but a returned value. curious, so it is. i wonder why there is both a special return value (NotIMplemented) and a related exception (NotImplementedError). seems very odd to have a value... andrew -- http://mail.python

Re: Where to host a (Python) project?

2009-01-31 Thread andrew cooke
On Jan 31, 9:59 am, Martin wrote: > There's tigris.org, savannah (savannah.gnu.org, nongnu.org), > launchpad. All of them are fine to some extent, you might want to read > up on PyMotW about how Doug Hellmann decided where to host his stuff. all i can find is that he is writing his own! http://bl

Re: Where to host a (Python) project?

2009-01-31 Thread andrew cooke
On Jan 31, 11:22 am, eliben wrote: > code.google.com provides all of these in a free and convenient manner. > Recommended. unfortunately google don't seem that reliable ;o) (have you tried a google search today?) -- http://mail.python.org/mailman/listinfo/python-list

Re: Where to host a (Python) project?

2009-01-31 Thread andrew cooke
On Jan 31, 4:50 pm, "Giampaolo Rodola'" wrote: > Google Code. > > --- Giampaolohttp://code.google.com/p/pyftpdlib thanks - that's a nice example. i'm a bit concerned about the whole google corporation thing, but reading through the ideological check- sheet at savannah convinced me i wasn't worth

Re: help me python

2009-01-31 Thread andrew cooke
On Jan 31, 5:36 pm, aolsu...@gmail.com wrote: > C:\Python26>vnc.py > Traceback (most recent call last): >   File "C:\Python26\vnc.py", line 4, in >     import PyD3DES > ImportError: DLL load failed: The specified module could not be found. i'm surprised no-one has replied here. what is happening

Re: database wrapper ?

2009-02-01 Thread andrew cooke
> Is SQLalchemy the best / most popular database wrapper ? SQLAlchemy is the best SQL library I have ever used. But it may depend on who you ask. For me, what makes SQLAlchemy so good is the way it allows you to use SQL from within Python. I have used the ORM side, and that's fine, but it's the

Re: Where to host a (Python) project?

2009-02-01 Thread andrew cooke
On Feb 1, 8:45 pm, a...@pythoncraft.com (Aahz) wrote: > Note that it's fairly easy to get a new list hosted at python.org, just > ask postmaster.  I for one won't participate in any list hosted on > Google because of the need for a Google login. ah well - i guess you can use pyparsing ;o) http://

Re: database wrapper ?

2009-02-01 Thread andrew cooke
> I wish all DB solutions were like this - my hope is that EmpireDB will > do the same for Java, but it's too early to tell... Hmmm - I should correct the above. I had assumed EmpireDB was new, because it's an Apache Incubator project, but now I look at their site I see it's actually been around

Re: Where to host a (Python) project?

2009-02-02 Thread andrew cooke
On Feb 1, 8:45 pm, a...@pythoncraft.com (Aahz) wrote: > [...] I for one won't participate in any list hosted on > Google because of the need for a Google login. hi, just fyi, i investigated this and you can join any publicly readable group by sending an email to the "-subscribe" address. you do

Re: what IDE is the best to write python?

2009-02-02 Thread andrew cooke
> Just to register a contrary opinion: I *hate* syntax highlighting you can use it in surprising ways, if the implementation is good enough. when i used intellij with java i had the "syntax" highlighting set so that everything was simple black+white, but mutable state (i can't remember the exact

Re: Locating python

2009-02-03 Thread andrew cooke
sorry, you are using easy_install, so sudo easy_install instead of what i said a moment ago. the important thing is to use "sudo". andrew On Feb 3, 7:30 pm, andrew cooke wrote: > the exact details of what you are reporting seem a bit odd, but i have > seen a similar

Re: Locating python

2009-02-03 Thread andrew cooke
the exact details of what you are reporting seem a bit odd, but i have seen a similar error because i have tried to use my own account to install the package, instead of using root. what i believe happens is that easy_install first tries to create the "test" file, and then checks it is there. if

Re: parse date/time from a log entry with only strftime (and no regexen)

2009-02-03 Thread andrew cooke
> > ValueError: unconverted data remains:  this is the remainder of the log   > > line > > that I do not care about you could catch the ValueError and split at the ':' in the .args attribute to find the extra data. you could then find the extra data in the original string, use the index to remove

Re: Locating python

2009-02-04 Thread andrew cooke
On Feb 3, 7:35 pm, David Sevilla wrote: > I am quite new to Linux, and thought that by using yast2 there would > be no user problems (I am asked for the root password). I will sudo it > to see if it solves the problem. yast asked you for the password so that easy_install could be installed correc

Re: Locating python

2009-02-04 Thread andrew cooke
On Feb 4, 9:16 am, andrew cooke wrote: > > actually "su" needs the root (or the target users') password > > and sudo needs _your_ (the current users) password. > > argh, sorry for the confusion. actually, no. sudo requires the root password. at least on open

Re: Locating python

2009-02-04 Thread andrew cooke
> actually "su" needs the root (or the target users') password > and sudo needs _your_ (the current users) password. argh, sorry for the confusion. -- http://mail.python.org/mailman/listinfo/python-list

Structuring Modules with a Ubiquitous Base Class (Circular Dependencies)

2009-02-04 Thread andrew cooke
Is there a good solution to the following problem? I have a library whose components I would like to separate into distinct modules. These components inherit from a common base class that provides common functionality (the inheritance is important only for implementation; there's a separate ABC m

Re: Structuring Modules with a Ubiquitous Base Class (Circular Dependencies)

2009-02-04 Thread andrew cooke
On Feb 4, 7:49 pm, andrew cooke wrote: > This leads to a circular dependency - the base class wants to import > the components, which in turn want to import the base class. > > Is there any standard solution to this? well, to partially answer my own question, this is certainly possi

Re: How to find wxPython method documentation??

2009-02-04 Thread andrew cooke
On Feb 4, 8:06 pm, len wrote: > How does one find the methods that are available in the classes. heh. welcome to the wonderful world of wxpython :o( if you use eclipse to edit your code, then (providing the wind is in the right direction and the file you are editing doesn't have any syntax erro

Re: Comparing two book chapters (text files)

2009-02-05 Thread andrew cooke
On Feb 4, 10:20 pm, Nick Matzke wrote: > So I have an interesting challenge.  I want to compare two book > chapters, which I have in plain text format, and find out (a) percentage > similarity and (b) what has changed. no idea if it will help, but i found this yesterday - http://www.nltk.org/ it

Re: Ordered dict by default

2009-02-05 Thread andrew cooke
so what is happening with pep 372? http://www.python.org/dev/peps/pep-0372/ -- http://mail.python.org/mailman/listinfo/python-list

Re: "Weird" Indentation? (Or: is there a for...else construct?)

2009-02-07 Thread andrew cooke
there's a justification for this awful mess here - http://mail.python.org/pipermail/python-3000/2006-March/000104.html i didn't know about this, and even after reading steven's broken (i assume) example, managed to get it backwards. the else is if there *isn't* a break and is for search loops (s

Re: Python3.0 has more duplication in source code than Python2.5

2009-02-07 Thread andrew cooke
Steve Holden wrote: >> You'd best hope the copied section was thoroughly reviewed otherwise >> you're >> duplicating a flaw across X other sections. And then you also best hope >> that >> whoever finds said flaw and fixes it is also smart enough to check for >> similar constructs around the code ba

Re: generator object or 'send' method?

2009-02-09 Thread andrew cooke
If I were experimenting with Python to see just how far I could push coroutines at the moment, I would use .send() and look at how I could factor things into a small library (containing, for example, your trap-and-response secondary generator). But if this was paid work, I would write a class wit

Re: generator object or 'send' method?

2009-02-10 Thread andrew cooke
steven probably knows this, but to flag the issue for people who are looking at generators/coroutines for the first time: there's a little "gotcha" about exactly how the two sides of the conversation are synchronized. in simple terms: send also receives. unfortunately the example steven gave doe

Re: Convert date/time to unix timestamp?

2009-02-10 Thread andrew cooke
the python routines are a bit basic - you really have to think quite hard about what you are doing to get the right answer. in your case, you need to be clear what the timezone is for the datetime you are using. timezone info is optional (see the datetime documentation, where it talks about "nai

Re: Functional schmunctional...

2009-02-10 Thread andrew cooke
r0g wrote: > def ip2inet(a): > li = a.split('.') > assert len(li) == 4 or len(li) == 6 > return reduce(add,[int(li[e])*(256**((len(li)-1)-e)) for e in > xrange(0,len(li))]) what a mess. i don't use this extreme a functional style in python (it's not really how the language is intended to be

Re: Avoiding argument checking in recursive calls

2009-02-11 Thread andrew cooke
Terry Reedy wrote: > Reverse the test order > > def fact(n): > if n > 0: return fact(n-1)*n > if n == 0: return 1 > raise ValueError sweet! but is this generally possible? ie: did you think this up for this question or is it an idiom that you find yourself using often? andrew --

Re: Another optimization request :-)

2009-02-11 Thread andrew cooke
why are you dong this point by point? surely you can express the physics as a set of equations and invert the matrix? wouldn't that be a lot faster? you'd replace the iteration over all combinations of points with a faster matrix inversion. see for example http://www.medwelljournals.com/fullte

Re: Another optimization request :-)

2009-02-11 Thread andrew cooke
sorry, that was stupid. there is no inversion (apart from 1/m), just the integration. still, improving the integration would allow larger steps. andrew andrew cooke wrote: > > why are you dong this point by point? surely you can express the physics > as a set of equations and i

Re: Another optimization request :-)

2009-02-12 Thread andrew cooke
jeffg wrote: > To be honest, this is not my code and I'm new to python. It's part of > the open source project NetworkX, but I'm using this one call > extensively. I'm also not that familiar with the math behind the > physics. I'll read the documents and see if I can figure it > out. :-) Thank

Re: Spam

2009-02-12 Thread andrew cooke
A quick search on "imap nntp" turned up this list that might be useful - http://deflexion.com/messaging/ although I wonder when it was written because I remember using Aaron's RSS to email aggregator when RSS was new(!). It mentions gmane, though, which certainly still exists (I assume it carries

Re: how to distribute python extensions independently of python

2009-02-12 Thread andrew cooke
You might want to read https://www.dfwpython.org/repo/Presentations/2008-10-04-PyArkansas-PythonEggsIntro/eggs-introduction.pdf It covers a lot of ground; I used it to work out how to distribute a pure Python package, but I am sure it mentions compiled packages too. In my case I ended up using s

Re: Spam

2009-02-12 Thread andrew cooke
Grant Edwards wrote: >> I should be working; I will try that this evening. What was the name of >> the client that threaded messages with a cute ascii tree?! > > slrn? i think i was remembering trn, which is now apparently dead. will try slrn... thanks, andrew -- http://mail.python.org/mailma

Re: Problem with objects copying each other in memory

2009-02-12 Thread andrew cooke
you're setting the new knight's "sl" to the value self.sl and then adding values to it. that's the same list - so you are adding values to the self.sl list when you add them to the knight's sl. this is easier to understand just by seeing the fix, which is to use: temp = Knight(self.x, self.y, s

Re: Problem with objects copying each other in memory

2009-02-12 Thread andrew cooke
he list? > > > On Feb 12, 2009, at 5:15 PM, andrew cooke wrote: > >> >> you're setting the new knight's "sl" to the value self.sl and then >> adding >> values to it. that's the same list - so you are adding values to the >> self.sl list

Re: sgmllib parser keeps old tag data?

2009-02-13 Thread andrew cooke
you are declaring class variables, not instance variables. you need to declare these in an __init__ method. RTFM. http://docs.python.org/tutorial/classes.html#a-first-look-at-classes Berend van Berkum wrote: > class MyParser(sgmllib.SGMLParser): > > content = '' > markup = [] > span_stack = [

Re: sgmllib parser keeps old tag data?

2009-02-13 Thread andrew cooke
Sorry, this reply was delayed (trying to use usenet...) and so now seems (even more) bad tempered than needed. Andrew andrew cooke wrote: > you are declaring class variables, not instance variables. you need to > declare these in an __init__ method. RTFM. > http://docs.python.org

Re: confusion about variable scope in a class

2009-02-14 Thread andrew cooke
it's not a scope issue. you are confusing variables and objects. a variable is a box that can hold an object so x = 2 puts the object '2' in the box 'x'. following that with x = '3' changes the box 'x' to hold the object '3'. but lists are also boxes, different from variables. so x = [1,2,3]

Re: Will multithreading make python less popular?

2009-02-16 Thread andrew cooke
rushen...@gmail.com wrote: > Hi everybody, > I am an engineer. I am trying to improve my software development > abilities. I have started programming with ruby. I like it very much > but i want to add something more. According to my previous research i > have designed a learning path for myself. It

Re: Will multithreading make python less popular?

2009-02-16 Thread andrew cooke
andrew cooke wrote: > something like Haskell or OCaml. Or, if you want to get hands-on > experience of concurrency now, Erlang. I think for once I said something useful there. I think you would probably enjoy Erlang, and it would be very useful for understanding concurrency. Also, Erl

Re: Will multithreading make python less popular?

2009-02-17 Thread andrew cooke
why do you think that current work is ignorant of occam? occam itself was based on hoare's "communicating sequential processes" which is a classic of the field. the ideas behind occam are not unknown and it hasn't been forgotten (there are many libraries based on synchronous message passing; one

Re: Will multithreading make python less popular?

2009-02-17 Thread andrew cooke
Bruno Desthuilliers wrote: > rushen...@gmail.com a écrit : > (snip) >> And the story begins here. As i search on the net, I have found that >> because of the natural characteristics of python such as GIL, we are >> not able to write multi threaded programs. > > I'm surprised no one here corrected

Re: Is there something easier than ORM?

2009-02-17 Thread andrew cooke
Philip Semanchuk wrote: > In short, I gather that others on this list are a lot more fond of > SqlAlchemy and ORMs in general than I am. Granted, my experience is > very limited. I tried to integrate SqlAlchemy in one project, > struggled for a long time to express how I wanted my tables joined, >

Re: number theory libraries / project euler

2009-02-18 Thread andrew cooke
eliben wrote: > Hello, > > What are some good & recommended number theory libs for Python (or > accessible interfaces to C libs), for things like primes, > factorization, etc. Naturally, speed is of utmost importance here. i just read the project site and one of the things they say on their front

Re: SVN/CVS and Branching

2009-02-18 Thread andrew cooke
maybe this is just me, but i don't have a clue what your problem is. what does "starting imports all over the place" mean? what do you mean by "retired"? i use svn with python in exactly the same way as with java (and, i thought, in the same way as anyone uses svn with any language; java uses t

Re: SVN/CVS and Branching

2009-02-19 Thread andrew cooke
ant to work on the branch and remove the link > when i want to work on the head. This actually works fine, but > thought there may be a better way. > > Jeff > > On Wed, Feb 18, 2009 at 7:40 PM, andrew cooke wrote: >> >> maybe this is just me, but i don't have a cl

Re: Porting to new Python version

2009-02-19 Thread andrew cooke
i don't know what the context is, so it's hard for me to comment on the decision (i assume there are commerical pressures like customers not wanting to install old versions). however,if you go ahead, you need to think about exactly what you want to target. the latest version is really 3.0.1. mo

Re: Porting to new Python version

2009-02-19 Thread andrew cooke
ot;latest"; (3) moving from 2.4 to 2.6 is probably best done before branching for 3; (4) moving from 2.4 to 2.6 is probably easier than moving from 2 to 3. andrew andrew cooke wrote: > > i don't know what the context is, so it's hard for me to comment on the > decision (i ass

Re: Regular expression bug?

2009-02-19 Thread andrew cooke
i wonder what fraction of people posting with "bug?" in their titles here actually find bugs? anyway, how about: re.findall('[A-Z]?[a-z]*', 'fooBarBaz') or re.findall('([A-Z][a-z]*|[a-z]+)', 'fooBarBaz') (you have to specify what you're matching and lookahead/back doesn't do that). andrew

Re: code challenge: generate minimal expressions using only digits 1,2,3

2009-02-20 Thread andrew cooke
this is a neat problem. here is what i would do: use generators that extend an input. a stream approach. the initial input would be the numbers themselves. [('1', 1),('2', 2),('3', 3)] those are (expression, value) pairs then an initial attempt at the next function would be to extend that li

Re: code challenge: generate minimal expressions using only digits 1,2,3

2009-02-20 Thread andrew cooke
lues to below 1000 makes things much faster # note 200,000 below, 20,000 above! summarise(compose(take(20), repeat(compose(ints, small, all_operators)))(START)) # get to larger values faster by sorting in the repeat #s

  1   2   3   4   >