Re: How to avoid certain directories when using os.walk?

2009-10-29 Thread Chris Rebert
On Thu, Oct 29, 2009 at 9:53 PM, Peng Yu wrote: > I don't see a way to avoid walking over directories of certain names > with os.walk. For example, I don't want os.walk return files whose > path include '/backup/'. Is there a way to do so? Otherwise, maybe I > will have to make my own program. Tha

Re: self.__dict__ tricks

2009-10-29 Thread Ben Finney
Ben Finney writes: > Steven D'Aprano writes: > > > On Thu, 29 Oct 2009 21:16:37 -0500, Tim Johnson wrote: > > > class formLoader(): > > > > Idiomatic Python is to use CamelCase for classes. > > Or rather: Instead of camelCase names, idiomatic Python is to use > TitleCase names. Blah, my attempt

Re: OT: DARPA red balloon challenge

2009-10-29 Thread Mensanator
On Oct 29, 10:27 pm, Adam N wrote: > All, > > In case people hadn't heard, DARPA just announced what I think is the > coolest competition ever: > > http://networkchallenge.darpa.mil/ > > On December 5, DARPA will raise 10 red weather balloons somewhere in > the US.  The first person to get the loc

How to avoid certain directories when using os.walk?

2009-10-29 Thread Peng Yu
I don't see a way to avoid walking over directories of certain names with os.walk. For example, I don't want os.walk return files whose path include '/backup/'. Is there a way to do so? Otherwise, maybe I will have to make my own program. Thank you! -- http://mail.python.org/mailman/listinfo/pytho

Re: list comprehension problem

2009-10-29 Thread Terry Reedy
alex23 wrote: On Oct 30, 1:10 pm, Nick Stinemates wrote: Some objects are singletons, ie there's only ever one of them. The most common singleton is None. In virtually every other case you should be using "==" and "!=". Please correct me if I am wrong, but I believe you meant to say some objec

Re: Python 2.6 Global Variables

2009-10-29 Thread Gabriel Genellina
En Fri, 30 Oct 2009 00:29:27 -0300, Steven D'Aprano escribió: On Thu, 29 Oct 2009 10:31:03 -0700, AK Eric wrote: 2/ in Python, "global" really means "module-level" - there's nothing like a "true" global namespace. Isn't that __main__? Well there you go, I just learned something new. I w

Re: How to get a unique function name for methods

2009-10-29 Thread Terry Reedy
Christian Heimes wrote: Philip Guo wrote: Does anyone know how to get this information either from a code object or from a related object? I am hacking the interpreter, so I have full access to everything. Does this help? class A(object): ... def method(self): ... pass ... A.m

Re: list comprehension problem

2009-10-29 Thread Steven D'Aprano
On Thu, 29 Oct 2009 23:10:39 -0400, Nick Stinemates wrote: >> Some objects are singletons, ie there's only ever one of them. The most >> common singleton is None. In virtually every other case you should be >> using "==" and "!=". > > Please correct me if I am wrong, but I believe you meant to sa

Re: self.__dict__ tricks

2009-10-29 Thread Steven D'Aprano
On Thu, 29 Oct 2009 21:16:37 -0500, Tim Johnson wrote: > This is not a request for help but a request for comments: Consider the > following code and note that 1)The initializer uses the dictionary style > of arguments 2)The check loop executes before all of the class variables > are declared C

Re: Problem embedding Python.

2009-10-29 Thread Brandon Keown
O...K... -- http://mail.python.org/mailman/listinfo/python-list

Re: Modify dict/set during iteration?

2009-10-29 Thread metal
On 10月30日, 上午11时59分, Steven D'Aprano wrote: > On Thu, 29 Oct 2009 19:02:01 -0700, metal wrote: > > I used this quickndirty way, any good idea to solve this problem? > > It's not a problem that wants solving, it's a feature that wants paying > attention to. > > As a general rule, you shouldn't modi

Re: Are *.pyd's universal?

2009-10-29 Thread Lawrence D'Oliveiro
In message , Christian Heimes wrote: > Lawrence D'Oliveiro schrieb: > >> In message , >> Christian Heimes wrote: >> >>> On Linux and several other Unices the suffix is .so and not .pyd. >> >> Why is that? Or conversely, why isn't it .dll under Windows? > > On Windows it used to be .dll, too. >

Re: list comprehension problem

2009-10-29 Thread alex23
On Oct 30, 1:10 pm, Nick Stinemates wrote: > > Some objects are singletons, ie there's only ever one of them. The most > > common singleton is None. In virtually every other case you should be > > using "==" and "!=". > > Please correct me if I am wrong, but I believe you meant to say some > objec

Re: Feedback wanted on programming introduction (Python in Windows)

2009-10-29 Thread Alf P. Steinbach
* alex23: "Alf P. Steinbach" wrote: However, given what I've now learned about the current situation wrt. versions of Python, where Python 3.x is effectively a new language, and where apparently ActiveState has no installer for that, I'm rewriting to use the "official" distribution. I hope th

Re: Modify dict/set during iteration?

2009-10-29 Thread Steven D'Aprano
On Thu, 29 Oct 2009 19:02:01 -0700, metal wrote: > I used this quickndirty way, any good idea to solve this problem? It's not a problem that wants solving, it's a feature that wants paying attention to. As a general rule, you shouldn't modify data structures while you're iterating over them, u

Re: Feedback wanted on programming introduction (Python in Windows)

2009-10-29 Thread alex23
"Alf P. Steinbach" wrote: > However, given what I've now learned about the current situation wrt. versions > of Python, where Python 3.x is effectively a new language, and where > apparently > ActiveState has no installer for that, I'm rewriting to use the "official" > distribution. I hope the r

Re: Feedback wanted on programming introduction (Python in Windows)

2009-10-29 Thread Alf P. Steinbach
* Ethan Furman: Alf P. Steinbach wrote: * Ethan Furman: Alf P. Steinbach wrote: * James Harris: You get way too deep into Python in places (for a beginner's course in programming). For example, "from now on I’ll always use from __future__ in any program that uses print." Sorry, but I thi

Re: Feedback wanted on programming introduction (Python in Windows)

2009-10-29 Thread Steven D'Aprano
On Thu, 29 Oct 2009 11:05:11 -0700, Ethan Furman wrote: > Alf P. Steinbach wrote: >> * James Harris: >> >>> You get way too deep into Python in places (for a beginner's course in >>> programming). For example, "from now on I’ll always use from >>> __future__ in any program that uses print." >> >

Re: __eq__() inconvenience when subclassing set

2009-10-29 Thread Gabriel Genellina
En Wed, 28 Oct 2009 23:12:53 -0300, Jess Austin escribió: class mySet(set): ... def __eq__(self, other): ... print "called mySet.__eq__()!" ... if isinstance(other, (set, frozenset)): ... return True ... return set.__eq__(self, other) ... Now I want t

Re: Python 2.6 Global Variables

2009-10-29 Thread Steven D'Aprano
On Thu, 29 Oct 2009 10:31:03 -0700, AK Eric wrote: >> 2/ in Python, "global" really means "module-level" - there's nothing >> like a "true" global namespace. > > Isn't that __main__? Well there you go, I just learned something new. I was going to say "No, every module has its own __main__", and

OT: DARPA red balloon challenge

2009-10-29 Thread Adam N
All, In case people hadn't heard, DARPA just announced what I think is the coolest competition ever: http://networkchallenge.darpa.mil/ On December 5, DARPA will raise 10 red weather balloons somewhere in the US. The first person to get the location of all 10 balloons and submit them will be gi

Re: Feedback wanted on programming introduction (Python in Windows)

2009-10-29 Thread Alf P. Steinbach
* Rhodri James: On Thu, 29 Oct 2009 16:53:05 -, Alf P. Steinbach wrote: There's rather a lot to know about the environment that a program executes in if one is going to create robust, dependable, generally usable programs, not just toy examples. I'd say this was at best an extremely mi

Re: Aaaargh! "global name 'eggz' is not defined"

2009-10-29 Thread alex23
kj wrote: > As my Python apps grow in complexity and execution, I'm finding it > more often the situation in which a program dies after a lengthy > (i.e. expensive) run because the execution reaches, say, a typo. This is a good reason for breaking your program down into testable units and verifyi

Re: Feedback wanted on programming introduction (Python in Windows)

2009-10-29 Thread Alf P. Steinbach
* bartc: "Alf P. Steinbach" wrote in message news:hc8pn3$dd...@news.eternal-september.org... [Cross-posted comp.programming and comp.lang.python] I may finally have found the perfect language for a practically oriented introductory book on programming, namely Python. C++ was way too comp

Re: list comprehension problem

2009-10-29 Thread Nick Stinemates
> Some objects are singletons, ie there's only ever one of them. The most > common singleton is None. In virtually every other case you should be > using "==" and "!=". Please correct me if I am wrong, but I believe you meant to say some objects are immutable, in which case you would be correct.

self.__dict__ tricks

2009-10-29 Thread Tim Johnson
This is not a request for help but a request for comments: Consider the following code and note that 1)The initializer uses the dictionary style of arguments 2)The check loop executes before all of the class variables are declared ## ---

Re: Modify dict/set during iteration?

2009-10-29 Thread Paul Rubin
metal writes: > I used this quickndirty way, any good idea to solve this problem? That's really ugly. Why would you want to do a thing like that? -- http://mail.python.org/mailman/listinfo/python-list

Modify dict/set during iteration?

2009-10-29 Thread metal
I used this quickndirty way, any good idea to solve this problem? def miter(iterable): cache = set() while True: try: for x in iterable: if x not in cache: cache.add(x) yield x break except Runt

Re: Are *.pyd's universal?

2009-10-29 Thread Robert Kern
Philip Semanchuk wrote: On Oct 29, 2009, at 8:41 PM, Christian Heimes wrote: Lawrence D'Oliveiro schrieb: In message , Christian Heimes wrote: On Linux and several other Unices the suffix is .so and not .pyd. Why is that? Or conversely, why isn't it .dll under Windows? .so is the commo

Re: ftpilb.FTP.stor...() freeze mystery

2009-10-29 Thread Gabriel Genellina
En Thu, 29 Oct 2009 13:18:30 -0300, Anthra Norell escribió: Gabriel Genellina wrote: En Wed, 28 Oct 2009 08:05:22 -0300, Anthra Norell escribió: Gabriel Genellina wrote: En Tue, 27 Oct 2009 07:53:36 -0300, Anthra Norell escribió: I am trying to upload a bunch of web pages to a hosting

Re: Checking if a function invocation will throw a TypeError?

2009-10-29 Thread Andrey Fedorov
Will do, thanks. Doing it to make a @curry decorator, which only executes a function once enough arguments have been passed in. - Andrey On Thu, Oct 29, 2009 at 6:53 PM, Chris Rebert wrote: > On Thu, Oct 29, 2009 at 11:43 AM, Andrey Fedorov > wrote: > > Is there a standard function that will c

Re: '11' + '1' is '111'?

2009-10-29 Thread MRAB
Benjamin Peterson wrote: metal gmail.com> writes: '11' + '1' == '111' is well known. but it suprises me '11'+'1' IS '111'. Why? Obviously they are two differnt object. Is this special feature of imutable object? As other posters have pointed out, CPython does cache some small strings. In

Re: '11' + '1' is '111'?

2009-10-29 Thread metal
On 10月30日, 上午9时03分, Benjamin Peterson wrote: > metal gmail.com> writes: > > > > > '11' + '1' == '111' is well known. > > > but it suprises me '11'+'1' IS '111'. > > > Why? Obviously they are two differnt object. > > > Is this special feature of imutable object? > > As other posters have pointed o

Re: '11' + '1' is '111'?

2009-10-29 Thread John Machin
On Oct 30, 11:52 am, Benjamin Kaplan wrote: > On Thu, Oct 29, 2009 at 8:43 PM, metal wrote: > > '11' + '1' == '111' is well known. > > > but it suprises me '11'+'1' IS '111'. > > > Why? Obviously they are two differnt object. > > > Is this special feature of imutable object? > > It's an implement

Re: Feedback wanted on programming introduction (Python in Windows)

2009-10-29 Thread Rhodri James
On Thu, 29 Oct 2009 16:53:05 -, Alf P. Steinbach wrote: There's rather a lot to know about the environment that a program executes in if one is going to create robust, dependable, generally usable programs, not just toy examples. I'd say this was at best an extremely misleading state

Re: '11' + '1' is '111'?

2009-10-29 Thread Benjamin Peterson
metal gmail.com> writes: > > '11' + '1' == '111' is well known. > > but it suprises me '11'+'1' IS '111'. > > Why? Obviously they are two differnt object. > > Is this special feature of imutable object? As other posters have pointed out, CPython does cache some small strings. In this case, h

Re: '11' + '1' is '111'?

2009-10-29 Thread metal
On 10月30日, 上午8时49分, Chris Rebert wrote: > On Thu, Oct 29, 2009 at 5:43 PM, metal wrote: > > '11' + '1' == '111' is well known. > > > but it suprises me '11'+'1' IS '111'. > > > Why? Obviously they are two differnt object. > > > Is this special feature of imutable object? > > It's an implementatio

Re: Python2.6 + win32com crashes with unicode bug

2009-10-29 Thread John Machin
On Oct 30, 11:11 am, Terry Reedy wrote: > GerritM wrote: [snip] > >   File "C:\Python26\lib\site-packages\win32com\client\build.py", line > > 542, in > >     return filter( lambda char: char in valid_identifier_chars, className) > > UnicodeDecodeError: 'ascii' codec can't decode byte 0x83 in posi

Re: '11' + '1' is '111'?

2009-10-29 Thread Benjamin Kaplan
On Thu, Oct 29, 2009 at 8:43 PM, metal wrote: > '11' + '1' == '111' is well known. > > but it suprises me '11'+'1' IS '111'. > > Why? Obviously they are two differnt object. > > Is this special feature of imutable object? It's an implementation detail of small strings without spaces and small num

Re: Are *.pyd's universal?

2009-10-29 Thread Philip Semanchuk
On Oct 29, 2009, at 8:41 PM, Christian Heimes wrote: Lawrence D'Oliveiro schrieb: In message , Christian Heimes wrote: On Linux and several other Unices the suffix is .so and not .pyd. Why is that? Or conversely, why isn't it .dll under Windows? .so is the common suffix of shared libra

Re: '11' + '1' is '111'?

2009-10-29 Thread Chris Rebert
On Thu, Oct 29, 2009 at 5:43 PM, metal wrote: > '11' + '1' == '111' is well known. > > but it suprises me '11'+'1' IS '111'. > > Why? Obviously they are two differnt object. > > Is this special feature of imutable object? It's an implementation detail used to optimize performance. CPython caches

'11' + '1' is '111'?

2009-10-29 Thread metal
'11' + '1' == '111' is well known. but it suprises me '11'+'1' IS '111'. Why? Obviously they are two differnt object. Is this special feature of imutable object? -- http://mail.python.org/mailman/listinfo/python-list

Re: Are *.pyd's universal?

2009-10-29 Thread Christian Heimes
Lawrence D'Oliveiro schrieb: > In message , Christian > Heimes wrote: > >> On Linux and several other Unices the suffix is .so and not .pyd. > > Why is that? Or conversely, why isn't it .dll under Windows? .so is the common suffix of shared libraries on Linux. IIRC Python extensions have .pyd o

Re: How to get a unique function name for methods

2009-10-29 Thread Terry Reedy
Philip Guo wrote: Hi all, This is my first post, so sorry for the n00bish question. Let's say I have 2 classes with the same __init__ method defined in a file foo.py: class A: def __init__(self): pass class B: def __init__(self): pass For the purpose of a code analysis, I need

Re: Are *.pyd's universal?

2009-10-29 Thread Lawrence D'Oliveiro
In message , Christian Heimes wrote: > On Linux and several other Unices the suffix is .so and not .pyd. Why is that? Or conversely, why isn't it .dll under Windows? -- http://mail.python.org/mailman/listinfo/python-list

Re: Aaaargh! "global name 'eggz' is not defined"

2009-10-29 Thread Ben Finney
Albert Hopkins writes: > On Thu, 2009-10-29 at 17:27 -0500, Robert Kern wrote: > > I consider "import *" the first error to be fixed, so it doesn't > > bother me much. :-) > > But does pyflakes at least *warn* about the use of "import *" (I've > never used it so just asking)? That's easy enough

Re: Python2.6 + win32com crashes with unicode bug

2009-10-29 Thread Terry Reedy
GerritM wrote: I have automated image generation with Python, win32com and Visio5.0. This works well upto Python2.5 but fails with Python 2.6. Short term solution is to return to 2.5 :-(. I have reproduced the bug below with a minimum of Python lines. Below the problem the working example from

Re: Aaaargh! "global name 'eggz' is not defined"

2009-10-29 Thread Albert Hopkins
On Thu, 2009-10-29 at 17:27 -0500, Robert Kern wrote: > I consider "import *" the first error to be fixed, so it doesn't > bother me much. :-) But does pyflakes at least *warn* about the use of "import *" (I've never used it so just asking)? -- http://mail.python.org/mailman/listinfo/python-li

Re: If a class Child inherits from Parent, how to implement Child.some_method if Parent.some_method() returns Parent instance ?

2009-10-29 Thread metal
The actual situation is I'm coding with a immuable set-like datatype XSet which supports XSet(['al']) & XSet(['ah'] = XSet(['ax'] if I declare ax is consists of al and ah "That" means I can't explian it very well 'cause my english... Now I try to make some mess like this...I know it's not good to

Re: Win XP: How to hide command window for sub processes?

2009-10-29 Thread klausfpga
On Oct 29, 11:25 am, Rüdiger Ranft <_r...@web.de> wrote: > klausfpga schrieb: > > > Hi, > > > I have a Python script which wants to start a subprocess and wait for > > it to finish. > > > However I would like to have NO command window popping up during > > execution. > > You need to specify the hid

Re: Python 2.6 Global Variables

2009-10-29 Thread Benjamin Kaplan
On Thu, Oct 29, 2009 at 7:11 PM, AK Eric wrote: >> Good that you're not advocating it, because IMHO it's bad practice to >> have circular import dependencies.  By using the __main__ alias, you >> avoid the worst problems, but that just means the others are more subtle. > > I figured I'd get that k

Re: If a class Child inherits from Parent, how to implement Child.some_method if Parent.some_method() returns Parent instance ?

2009-10-29 Thread Dave Angel
metal wrote: Consider the following: class Parent: def some_method(self): return Parent(...) class Child: def some_method(self): ... return Parent.some_method(self) ##

Re: Newbie advice

2009-10-29 Thread CSharpner
On Oct 29, 1:08 pm, Bryan wrote: > On Oct 28, 9:53 pm,CSharpner wrote: > > > > > Alright, I'm not new to programming, but I'm diving in head first into > > Python for the first time.  I'm running on Windows 7, just installed > > "Eclipse Java EE IDE for Web Developers" and installed PyDev in it an

Re: : yappi v0.2 beta

2009-10-29 Thread Aahz
In article <90507058-c366-4650-9e81-381cbbdaa...@k19g2000yqc.googlegroups.com>, Oktaka Com wrote: > >Forgot to give the project web page:) Here it is: > >http://code.google.com/p/yappi/ Looks interesting, but I think I'll wait until the docs are a bit more mature. -- Aahz (a...@pythoncraft.com)

Re: If a class Child inherits from Parent, how to implement Child.some_method if Parent.some_method() returns Parent instance ?

2009-10-29 Thread Rhodri James
On Thu, 29 Oct 2009 22:45:45 -, metal wrote: Consider the following: [fixed to actually inherit...] class Parent: def some_method(self): return Parent(...) class Child(Parent): pass

Re: Aaaargh! "global name 'eggz' is not defined"

2009-10-29 Thread Ben Finney
a...@pythoncraft.com (Aahz) writes: > Coincidentally, I tried PyFlakes yesterday and was unimpressed with > the way it doesn't work with "import *". That's pretty much the reason to avoid ‘from foo import *’: it makes the namespace indeterminate without actually running the code. Just as much a p

Re: Recommended number of threads? (in CPython)

2009-10-29 Thread Dave Angel
Paul Rubin wrote: Neil Hodgson writes: If you are running on a 32-bit environment, it is common to run out of address space with many threads. Each thread allocates a stack and this allocation may be as large as 10 Megabytes on Linux. I'm sure it's smaller than that under most cir

Re: If a class Child inherits from Parent, how to implement Child.some_method if Parent.some_method() returns Parent instance ?

2009-10-29 Thread Chris Rebert
On Thu, Oct 29, 2009 at 3:45 PM, metal wrote: > Consider the following: > class Parent: >        def some_method(self): >                return Parent(...) > class Child: >        pass > > > Child().some_method() returns a Parent instance. > > We can rewri

Re: Python 2.6 Global Variables

2009-10-29 Thread AK Eric
> Good that you're not advocating it, because IMHO it's bad practice to > have circular import dependencies.  By using the __main__ alias, you > avoid the worst problems, but that just means the others are more subtle. I figured I'd get that kind of response, not that it's incorrect ;) Great power

Re: If a class Child inherits from Parent, how to implement Child.some_method if Parent.some_method() returns Parent instance ?

2009-10-29 Thread Christian Heimes
metal wrote: > But this style makes code full with ugly self.__class__ > > Any standard/pythonic way out there? You are already using one standard way to implement an alternative constructor. If you don't need any instance attributes you can use another way: class Egg(object): @classmethod

Re: Feedback wanted on programming introduction (Python in Windows)

2009-10-29 Thread Richard Heathfield
In , Richard Heathfield wrote: > In <7ku6jhf3a23e...@mid.individual.net>, osmium wrote: >> >> In some cultures, implying that someone is illiterate suggests "not >> smart". > > I don't see that at all. Babies are illiterate. Nobody knows whether > they're smart. Clarification: nobody knows fo

Re: Aaaargh! "global name 'eggz' is not defined"

2009-10-29 Thread exarkun
On 09:52 pm, a...@pythoncraft.com wrote: In article , Robert Kern wrote: I like using pyflakes. It catches most of these kinds of typo errors, but is much faster than pylint or pychecker. Coincidentally, I tried PyFlakes yesterday and was unimpressed with the way it doesn't work with "imp

Re: Feedback wanted on programming introduction (Python in Windows)

2009-10-29 Thread Richard Heathfield
In <7ku6jhf3a23e...@mid.individual.net>, osmium wrote: > "Richard Heathfield" wrote: > >>> if the OP had just been smarter. >> >> Er, no, I didn't have that in mind at all. > > In some cultures, implying that someone is illiterate suggests "not > smart". I don't see that at all. Babies are illi

Re: How to get a unique function name for methods

2009-10-29 Thread Christian Heimes
Philip Guo wrote: > Does anyone know how to get this information either from a code object or > from a related object? I am hacking the interpreter, so I have full access > to everything. Does this help? >>> class A(object): ... def method(self): ... pass ... >>> A.method.im_class >

Re: Checking if a function invocation will throw a TypeError?

2009-10-29 Thread Chris Rebert
On Thu, Oct 29, 2009 at 11:43 AM, Andrey Fedorov wrote: > Is there a standard function that will check whether certain *args, and > **kwargs satisfy a argspec of a function (s.t. it does not throw a > TypeError). Say: > > def foo(a,b=1): >     pass > > check(foo, 1,2) # True > check(foo, 1) # True

Re: Python 2.6 Global Variables

2009-10-29 Thread Dave Angel
AK Eric wrote: 2/ in Python, "global" really means "module-level" - there's nothing like a "true" global namespace. Isn't that __main__? import __main__ __main__.foo = "asdfasdf" print foo # asdfasdf Not advocating, but it does serve the purpose. Good that you're not advocating it,

If a class Child inherits from Parent, how to implement Child.some_method if Parent.some_method() returns Parent instance ?

2009-10-29 Thread metal
Consider the following: class Parent: def some_method(self): return Parent(...) class Child: def some_method(self): ... return Parent.some_method(self)

Re: Aaaargh! "global name 'eggz' is not defined"

2009-10-29 Thread Robert Kern
On 2009-10-29 16:52 PM, Aahz wrote: In article, Robert Kern wrote: I like using pyflakes. It catches most of these kinds of typo errors, but is much faster than pylint or pychecker. Coincidentally, I tried PyFlakes yesterday and was unimpressed with the way it doesn't work with "import *".

Re: PyQT4 user group

2009-10-29 Thread David Boddie
On Thursday 29 October 2009 17:15, Diez B. Roggisch wrote: > Chris wrote: > >> I'm starting to learn and use PyQT4 at work. Is there a good user >> group or forum out there that I should know about? > > The PyQt Mailinglist. There's a #pyqt IRC channel on Freenode: irc://irc.freenode.net/pyqt

Re: Feedback wanted on programming introduction (Python in Windows)

2009-10-29 Thread Ethan Furman
Alf P. Steinbach wrote: * Ethan Furman: Alf P. Steinbach wrote: * James Harris: You get way too deep into Python in places (for a beginner's course in programming). For example, "from now on I’ll always use from __future__ in any program that uses print." Sorry, but I think that hiding su

Re: Feedback wanted on programming introduction (Python in Windows)

2009-10-29 Thread bartc
"Alf P. Steinbach" wrote in message news:hc8pn3$dd...@news.eternal-september.org... [Cross-posted comp.programming and comp.lang.python] I may finally have found the perfect language for a practically oriented introductory book on programming, namely Python. C++ was way too complex for th

Re: __eq__() inconvenience when subclassing set

2009-10-29 Thread Jess Austin
On Oct 29, 3:54 pm, Mick Krippendorf wrote: > Jess Austin wrote: > > That's nice, but it means that everyone who imports my class will have > > to import the monkeypatch of frozenset, as well.  I'm not sure I want > > that.  More ruby than python, ne? > > I thought it was only a toy class? Well,

Re: disutils, project structure & developing - n00b question

2009-10-29 Thread Lie Ryan
Simon Forman wrote: In order for "from pymlb import fetcher" no work you must make the './pymlb' directory into a "package" by adding a file called __init__.py (it can be empty.) Then make sure the "top" directory (i.e. '.' in your example) is in the python PATH. There are a couple of ways to

Re: Feedback wanted on programming introduction (Python in Windows)

2009-10-29 Thread Alf P. Steinbach
* Benjamin Kaplan: On Thu, Oct 29, 2009 at 1:24 PM, Alf P. Steinbach wrote: ActiveState is simplest to install. However, given what I've now learned about the current situation wrt. versions of Python, where Python 3.x is effectively a new language, and where apparently ActiveState has no inst

Re: Recommended number of threads? (in CPython)

2009-10-29 Thread Paul Rubin
Neil Hodgson writes: >If you are running on a 32-bit environment, it is common to run out > of address space with many threads. Each thread allocates a stack and > this allocation may be as large as 10 Megabytes on Linux. I'm sure it's smaller than that under most circumstances. I run pytho

Re: Feedback wanted on programming introduction (Python in Windows)

2009-10-29 Thread Trent Mick
However, given what I've now learned about the current situation wrt. versions of Python, where Python 3.x is effectively a new language, and where apparently ActiveState has no installer for that, I'm rewriting to use the "official" distribution. ... ActiveState does have Python 3 installers. Th

Re: Aaaargh! "global name 'eggz' is not defined"

2009-10-29 Thread Aahz
In article , Robert Kern wrote: > >I like using pyflakes. It catches most of these kinds of typo errors, but is >much faster than pylint or pychecker. Coincidentally, I tried PyFlakes yesterday and was unimpressed with the way it doesn't work with "import *". -- Aahz (a...@pythoncraft.com)

How to get a unique function name for methods

2009-10-29 Thread Philip Guo
Hi all, This is my first post, so sorry for the n00bish question. Let's say I have 2 classes with the same __init__ method defined in a file foo.py: class A: def __init__(self): pass class B: def __init__(self): pass For the purpose of a code analysis, I need to get a UNIQUE name f

Re: Recommended number of threads? (in CPython)

2009-10-29 Thread Neil Hodgson
mk: > I found that when using more than several hundred threads causes weird > exceptions to be thrown *sometimes* (rarely actually, but it happens > from time to time). If you are running on a 32-bit environment, it is common to run out of address space with many threads. Each thread allocat

Re: Aaaargh! "global name 'eggz' is not defined"

2009-10-29 Thread Robert Kern
On 2009-10-29 15:48 PM, kj wrote: How can one check that a Python script is lexically correct? As my Python apps grow in complexity and execution, I'm finding it more often the situation in which a program dies after a lengthy (i.e. expensive) run because the execution reaches, say, a typo. Of

Re: PyQT4 user group

2009-10-29 Thread Colin W.
Diez B. Roggisch wrote: Chris wrote: Hi! I'm starting to learn and use PyQT4 at work. Is there a good user group or forum out there that I should know about? The PyQt Mailinglist. Diez I find the Gmane server, which delivers items from the PyQt Mailing List, easier to use. It threads the

Re: Aaaargh! "global name 'eggz' is not defined"

2009-10-29 Thread Diez B. Roggisch
kj schrieb: How can one check that a Python script is lexically correct? As my Python apps grow in complexity and execution, I'm finding it more often the situation in which a program dies after a lengthy (i.e. expensive) run because the execution reaches, say, a typo. Of course, this typo needs

Re: Aaaargh! "global name 'eggz' is not defined"

2009-10-29 Thread Mick Krippendorf
kj wrote: > How can one check that a Python script is lexically correct? By using pylint. Mick. -- http://mail.python.org/mailman/listinfo/python-list

Re: __eq__() inconvenience when subclassing set

2009-10-29 Thread Mick Krippendorf
Jess Austin wrote: > That's nice, but it means that everyone who imports my class will have > to import the monkeypatch of frozenset, as well. I'm not sure I want > that. More ruby than python, ne? I thought it was only a toy class? Mick. -- http://mail.python.org/mailman/listinfo/python-list

Re: Aaaargh! "global name 'eggz' is not defined"

2009-10-29 Thread Daniel da Silva
There are several static analysis tools that can check whether a variable name is used before it is defined. At my old workplace we used "pylint", so I can recommend that: http://www.logilab.org/857 --Daniel -- http://mail.python.org/mailman/listinfo/python-list

Re: Problem embedding Python.

2009-10-29 Thread Dave Angel
Brandon Keown wrote: On Oct 27, 7:48 pm, "Gabriel Genellina" wrote: Now that you've solved your problem, revise your conclusion. A file without a path *is* searched in the current working directory - but that directory may not be the one you think it is. -- Gabriel Genellina I'm not

Aaaargh! "global name 'eggz' is not defined"

2009-10-29 Thread kj
How can one check that a Python script is lexically correct? As my Python apps grow in complexity and execution, I'm finding it more often the situation in which a program dies after a lengthy (i.e. expensive) run because the execution reaches, say, a typo. Of course, this typo needs to be fixed

Re: Feedback wanted on programming introduction (Python in Windows)

2009-10-29 Thread Benjamin Kaplan
On Thu, Oct 29, 2009 at 1:24 PM, Alf P. Steinbach wrote: > > ActiveState is simplest to install. > > However, given what I've now learned about the current situation wrt. > versions of Python, where Python 3.x is effectively a new language, and > where apparently ActiveState has no installer for t

Re: Building Python on Solaris 10?

2009-10-29 Thread Judy Booth
"M.-A. Lemburg" wrote in news:mailman.2237.1256807688.2807.python-l...@python.org: > Why are you building with "--with-universal-archs=64-bit > --enable-universalsdk" on Solaris ? > > Those options should only be used for Mac OS X. > > Python currently does not support building universal binar

Re: __eq__() inconvenience when subclassing set

2009-10-29 Thread Jess Austin
On Oct 28, 10:07 pm, Mick Krippendorf wrote: > You could just overwrite set and frozenset: > > class eqmixin(object): >     def __eq__(self, other): >         print "called %s.__eq__()" % self.__class__ >         if isinstance(other, (set, frozenset)): >             return True >         return su

Re: Feedback wanted on programming introduction (Python in Windows)

2009-10-29 Thread Alf P. Steinbach
* Richard Heathfield: The best way is the simplest technology that will do the job properly. If that truly is PDF, okay, use PDF. But it is hard for me to envisage circumstances where Web content is best presented in that way. Google docs sharing. It made a mess of my *Word* documents. Ch

Re: Feedback wanted on programming introduction (Python in Windows)

2009-10-29 Thread Alf P. Steinbach
* Ethan Furman: Alf P. Steinbach wrote: * James Harris: You get way too deep into Python in places (for a beginner's course in programming). For example, "from now on I’ll always use from __future__ in any program that uses print." Sorry, but I think that hiding such concerns is a real disse

Re: disutils, project structure & developing - n00b question

2009-10-29 Thread Simon Forman
On Thu, Oct 29, 2009 at 3:45 PM, Simon Forman wrote: > In order for "from pymlb import fetcher" no work you must make the s/no/to/ D'oh! -- http://mail.python.org/mailman/listinfo/python-list

Re: disutils, project structure & developing - n00b question

2009-10-29 Thread Simon Forman
On Thu, Oct 29, 2009 at 2:42 PM, Wells wrote: > So I have my project partitioned like so: > > ./setup.py > ./pymlb/ > ./pymlb/fetcher.py > ./demos > ./demos/demo.py > > In demo.py I have: > > from pymlb import fetcher > > However, it fails b/c pymlb is up a folder. It's also NOT installed as > a m

Python2.6 + win32com crashes with unicode bug

2009-10-29 Thread GerritM
I have automated image generation with Python, win32com and Visio5.0. This works well upto Python2.5 but fails with Python 2.6. Short term solution is to return to 2.5 :-(. I have reproduced the bug below with a minimum of Python lines. Below the problem the working example from 2.5 kind rega

Re: Feedback wanted on programming introduction (Python in Windows)

2009-10-29 Thread osmium
"Richard Heathfield" wrote: >> if the OP had just been smarter. > > Er, no, I didn't have that in mind at all. In some cultures, implying that someone is illiterate suggests "not smart". There is a formal disconnect there but possibly you can see how someone might infer that. At least I found

disutils, project structure & developing - n00b question

2009-10-29 Thread Wells
So I have my project partitioned like so: ./setup.py ./pymlb/ ./pymlb/fetcher.py ./demos ./demos/demo.py In demo.py I have: from pymlb import fetcher However, it fails b/c pymlb is up a folder. It's also NOT installed as a module in my module directory because it's a development effort and I do

Checking if a function invocation will throw a TypeError?

2009-10-29 Thread Andrey Fedorov
Is there a standard function that will check whether certain *args, and **kwargs satisfy a argspec of a function (s.t. it does not throw a TypeError). Say: def foo(a,b=1): pass check(foo, 1,2) # True check(foo, 1) # True check(foo) # False check(foo, 1, a=2) # False Cheers, Andrey -- http:/

Re: Bug(s) in Python 3.1.1 Windows installation

2009-10-29 Thread Ethan Furman
Alf P. Steinbach wrote: * Ethan Furman: Mark Hammond wrote: On 29/10/2009 11:06 AM, Alf P. Steinbach wrote: So I suggest switching to some other more light-weight installer technology. Thanks for the suggestion, but I expect we will stick with MSI even with its shortcomings. Using MSI

Re: Are *.pyd's universal?

2009-10-29 Thread Christian Heimes
Bakes wrote: > Can I use a pyd compiled on linux in a Windows distribution? > > Or must I recompile it for windows users? On Linux and several other Unices the suffix is .so and not .pyd. The compiled extensions depend on the Python version, operating system as well as platform and architecture.

  1   2   >