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

2009-10-31 Thread Gabriel Genellina
En Fri, 30 Oct 2009 14:50:34 -0300, Sean DiZazzo half.ital...@gmail.com escribió: On Oct 29, 10:17 pm, Chris Rebert c...@rebertia.com wrote: On Thu, Oct 29, 2009 at 9:53 PM, Peng Yu pengyu...@gmail.com wrote: I don't see a way to avoid walking over directories of certain names with

Re: How can module determine its own path?

2009-10-31 Thread Gabriel Genellina
En Fri, 30 Oct 2009 20:40:59 -0300, Stef Mientki stef.mien...@gmail.com escribió: Robert Kern wrote: On 2009-10-30 12:19 PM, kj wrote: How can a module determine the path of the file that defines it? (Note that this is, in the general case, different from sys.argv[0].) __file__ but for

How to get output of command called by os.system()?

2009-10-31 Thread Peng Yu
I need to integrate shell program with python. I'm wondering if there is a way get the output of the shell program called by os.system(). Thank you! -- http://mail.python.org/mailman/listinfo/python-list

Re: How to get output of command called by os.system()?

2009-10-31 Thread Chris Rebert
On Fri, Oct 30, 2009 at 11:09 PM, Peng Yu pengyu...@gmail.com wrote: I need to integrate shell program with python. I'm wondering if there is a way get the output of the shell program called by os.system(). You'd probably do better to use the `subprocess` module instead:

How to get the realpath of a symbolic link?

2009-10-31 Thread Peng Yu
Suppose that I have the following directory and files. I want to get the canonical path of a file, a directory or a symbolic link. For example, for 'b' below, I want to get its canonical path as '/private/tmp/abspath/b'. However, os.path.abspath('b') gives me '/private/tmp/abspath/b', but

Why do you use python?

2009-10-31 Thread sk
What would be your answer if this question is asked to you in an interview? a modified version might be: Where would you use python over C/C++/Java? (because my resume says I know C/C++/Java)? -- http://mail.python.org/mailman/listinfo/python-list

Re: Why do you use python?

2009-10-31 Thread Jaime Buelta
On Oct 31, 8:11 am, sk catchyouraak...@gmail.com wrote: What would be your answer if this question is asked to you in an interview? a modified version might be: Where would you use python over C/C++/Java? (because my resume says I know C/C++/Java)? I also know C/C++/Java so... I'd say

Feedback desired on reworked ch 1 progr. intro (now Python 3.x, Windows)

2009-10-31 Thread Alf P. Steinbach
Hi all! After my earlier feedback request a lot of you responded with constructive criticism and suggestions. As a result of that I've changed the text to be based on *Python 3.x* instead of 2.6+, and chapter 1 Getting started has grown from 9 pages to a whopping 11 pages! I would

Re: self.__dict__ tricks

2009-10-31 Thread Hendrik van Rooyen
On Friday, 30 October 2009 17:28:47 MRAB wrote: Wouldn't it be clearer if they were called dromedaryCase and BactrianCase? :-) Ogden Nash: The Camel has a single hump- The Dromedary, two; Or the other way around- I'm never sure. - Are You? - Hendrik --

Re: Sqlite3. Substitution of names in query.

2009-10-31 Thread Lawrence D'Oliveiro
In message mailman.2357.1256964121.2807.python-l...@python.org, Dennis Lee Bieber wrote: This way regular string interpolation operations (or whatever Python 3.x has replaced it with) are safe to construct the SQL, leaving only user supplied (or program generated) data values to be passed via

Re: Are *.pyd's universal?

2009-10-31 Thread Lawrence D'Oliveiro
In message 6e603d9c-2be0-449c-9c3c- bab49e09e...@13g2000prl.googlegroups.com, Carl Banks wrote: It's not Python that's the issue. The issue is that if you have a module with a .dll extension, other programs could accidentally try to load that module instead of the intended dll, if the module

Re: Are *.pyd's universal?

2009-10-31 Thread Albert Hopkins
On Sat, 2009-10-31 at 21:32 +1300, Lawrence D'Oliveiro wrote: Modules will sometimes find themselves on the path in Windows, so the fact that Windows performs a library search on the path is quite significant. Why is it only Windows is prone to this problem? I think as someone pointed

Re: Web development with Python 3.1

2009-10-31 Thread Dotan Cohen
notmm uses Python 2.6 and will probably work just fine with Python 3000. The only reference to notmm that I could find in Google was this thread! I am free, no matter what rules surround me. If I find them tolerable, I tolerate them; if I find them too obnoxious, I break them. I am free

Re: How to get output of command called by os.system()?

2009-10-31 Thread Rominsky
On Oct 30, 11:09 pm, Peng Yu pengyu...@gmail.com wrote: I need to integrate shell program with python. I'm wondering if there is a way get the output of the shell program called by os.system(). Thank you! popen should do what your after. There are several modules that have a popen method

Re: datetime question

2009-10-31 Thread Albert Hopkins
On Sat, 2009-10-31 at 10:08 +1100, Ben Finney wrote: The ‘datetime’ module focusses on individual date+time values (and the periods between them, with the ‘timedelta’ type). For querying the properties of the calendar, use the ‘calendar’ module. Yes, it would be nice if the ‘time’,

Re: Why do you use python?

2009-10-31 Thread Martin P. Hellwig
sk wrote: What would be your answer if this question is asked to you in an interview? a modified version might be: Where would you use python over C/C++/Java? (because my resume says I know C/C++/Java)? I would say where I can, where 'can' is depending on the problem, already

Re: datetime question

2009-10-31 Thread Ben Finney
Albert Hopkins mar...@letterboxes.org writes: On Sat, 2009-10-31 at 10:08 +1100, Ben Finney wrote: Yes, it would be nice if the ‘time’, ‘datetime’, and ‘calendar’ modules were all much more unified and consumed a common set of primitive date+time types. It's a wart, and fixing it would

Re: datetime question

2009-10-31 Thread Albert Hopkins
On Sat, 2009-10-31 at 20:34 +1100, Ben Finney wrote: Fixing ‘time’, ‘datetime’, and ‘calendar’ was the reason for Python 3? No, it wasn't. Or perhaps you mean that any backward-incompatible change was a reason to have Python 3? Even more firmly no. The extent of changes was severely limited

Python 2.6.4: ./configure does not work

2009-10-31 Thread knipknap
Hi, Running ./configure in the 2.6.4 sources produces the following error: config.status: error: cannot find input file: Makefile.pre.in Indeed, such a file is not contained anywhere in the Pakage. Also, I found this note: The Unix build and install process is explained clearly in the README

Re: Why do you use python?

2009-10-31 Thread Alf P. Steinbach
* sk: [title Why do you use python?] What would be your answer if this question is asked to you in an interview? a modified version might be: Where would you use python over C/C++/Java? (because my resume says I know C/C++/Java)? The C++ FAQ addresses this question here: url:

Re. Web development with Python 3.1

2009-10-31 Thread Rustom Mody
Rober Kern wrote But if you insist, you may be interested in Breve: http://pypi.python.org/pypi/Breve/ Thanks for that! Viva internal DSLs! [Sorry -- cut my teeth on lisp] Is there anything like this for xml? Well I guess that is a slightly wrong (if not straight stupid) question. Maybe

Re: Working threads progress

2009-10-31 Thread mattia
Il Wed, 28 Oct 2009 20:04:45 -0700, ryles ha scritto: On Oct 28, 7:02 pm, mattia ger...@gmail.com wrote: Now, I would like to know the activity done (e.g. every two seconds) so I create another thread that checks the queue size (using .qsize()). Have you any suggestion to improve the code?

Re: Python 2.6.4: ./configure does not work

2009-10-31 Thread Albert Hopkins
On Sat, 2009-10-31 at 03:07 -0700, knipknap wrote: Hi, Running ./configure in the 2.6.4 sources produces the following error: config.status: error: cannot find input file: Makefile.pre.in Indeed, such a file is not contained anywhere in the Pakage. Which sources are you referring to?

Re: Python 2.6.4: ./configure does not work

2009-10-31 Thread knipknap
On 31 Okt., 11:40, Albert Hopkins mar...@letterboxes.org wrote: Which sources are you referring to?  Can you verify the checksums: 17dcac33e4f3adb69a57c2607b6de246  13322131  Python-2.6.4.tgz fee5408634a54e721a93531aba37f8c1  11249486  Python-2.6.4.tar.bz2 There is a README at the root of

Re: Why do you use python?

2009-10-31 Thread Bruno Desthuilliers
sk a écrit : What would be your answer if this question is asked to you in an interview? a modified version might be: Where would you use python over C/C++/Java? As far as I'm concerned, I'd put it the other way round : where would I use C/C++/Java over Python ?-) --

Re: Are *.pyd's universal?

2009-10-31 Thread Lawrence D'Oliveiro
In message mailman.2365.1256979069.2807.python-l...@python.org, Albert Hopkins wrote: On Sat, 2009-10-31 at 21:32 +1300, Lawrence D'Oliveiro wrote: In message 6e603d9c-2be0-449c-9c3c-bab49e09e...@13g2000prl.googlegroups.com, Carl Banks wrote: Modules will sometimes find themselves on the

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

2009-10-31 Thread Alan Franzoni
On 10/29/09 9:48 PM, kj wrote: How can one check that a Python script is lexically correct? You can use a pseudo-static analyzer like pyflakes, pylint or pydoctor. Or, better, you can avoid wild imports, excessive local or global namespace manipulation, and break you program in smaller parts

Re: Are *.pyd's universal?

2009-10-31 Thread Carl Banks
On Oct 31, 1:32 am, Lawrence D'Oliveiro l...@geek- central.gen.new_zealand wrote: In message 6e603d9c-2be0-449c-9c3c- bab49e09e...@13g2000prl.googlegroups.com, Carl Banks wrote: It's not Python that's the issue.  The issue is that if you have a module with a .dll extension, other programs

problem with read() write()

2009-10-31 Thread Zeynel
Hello, I've been studying the official tutorial, so far it's been fun, but today I ran into a problem with the write(). So, I open the file pw and write hello and read: f = open(pw, r+) f.write(hello) f.read() But read() returns a bunch of what looks like meta code: ont': 1,

Re: Are *.pyd's universal?

2009-10-31 Thread Carl Banks
On Oct 31, 1:32 am, Lawrence D'Oliveiro l...@geek- central.gen.new_zealand wrote: In message 6e603d9c-2be0-449c-9c3c- bab49e09e...@13g2000prl.googlegroups.com, Carl Banks wrote: It's not Python that's the issue.  The issue is that if you have a module with a .dll extension, other programs

Re: problem with read() write()

2009-10-31 Thread Alf P. Steinbach
* Zeynel: Hello, I've been studying the official tutorial, so far it's been fun, but today I ran into a problem with the write(). So, I open the file pw and write hello and read: f = open(pw, r+) f.write(hello) f.read() But read() returns a bunch of what looks like meta code: ont': 1,

Re: Are *.pyd's universal?

2009-10-31 Thread Albert Hopkins
On Sat, 2009-10-31 at 23:58 +1300, Lawrence D'Oliveiro wrote: I just checked my Debian installation: l...@theon:~ find /lib /usr/lib -name \*.so -a -not -name lib\* -print | wc -l 2950 l...@theon:~ find /lib /usr/lib -name \*.so -print | wc -l 4708 So 63% of the

Re: problem with read() write()

2009-10-31 Thread Zeynel
On Oct 31, 9:23 am, Alf P. Steinbach al...@start.no wrote: * Zeynel: Hello, I've been studying the official tutorial, so far it's been fun, but today I ran into a problem with the write(). So, I open the file pw and write hello and read: f = open(pw, r+) f.write(hello)

Re: Why do you use python?

2009-10-31 Thread Jaime Buelta
On Oct 31, 11:31 am, Alf P. Steinbach al...@start.no wrote: * sk: [title Why do you use python?] What would be your answer if this question is asked to you in an interview? a modified version might be: Where would you use python over C/C++/Java? (because my resume says I know

Re: problem with read() write()

2009-10-31 Thread Alf P. Steinbach
* Zeynel: On Oct 31, 9:23 am, Alf P. Steinbach al...@start.no wrote: * Zeynel: Hello, I've been studying the official tutorial, so far it's been fun, but today I ran into a problem with the write(). So, I open the file pw and write hello and read: f = open(pw, r+) f.write(hello) f.read()

Re: problem with read() write()

2009-10-31 Thread Zeynel
On Oct 31, 9:55 am, Alf P. Steinbach al...@start.no wrote: * Zeynel: On Oct 31, 9:23 am, Alf P. Steinbach al...@start.no wrote: * Zeynel: Hello, I've been studying the official tutorial, so far it's been fun, but today I ran into a problem with the write(). So, I open the file pw

Re: datetime question

2009-10-31 Thread Victor Subervi
Thanks, Rami, that will work. V On Sat, Oct 31, 2009 at 4:54 AM, Albert Hopkins mar...@letterboxes.orgwrote: On Sat, 2009-10-31 at 20:34 +1100, Ben Finney wrote: Fixing ‘time’, ‘datetime’, and ‘calendar’ was the reason for Python 3? No, it wasn't. Or perhaps you mean that any

Re: problem with read() write()

2009-10-31 Thread Alf P. Steinbach
* Zeynel: On Oct 31, 9:55 am, Alf P. Steinbach al...@start.no wrote: * Zeynel: On Oct 31, 9:23 am, Alf P. Steinbach al...@start.no wrote: * Zeynel: Hello, I've been studying the official tutorial, so far it's been fun, but today I ran into a problem with the write(). So, I open the file

Re: problem with read() write()

2009-10-31 Thread Dave Angel
Zeynel wrote: On Oct 31, 9:55 am, Alf P. Steinbach al...@start.no wrote: * Zeynel: On Oct 31, 9:23 am, Alf P. Steinbach al...@start.no wrote: * Zeynel: Hello, I've been studying the official tutorial, so far it's been fun, but today I ran into a problem with the

Scheduling used in the multiprocessing.Pool.map() function

2009-10-31 Thread rpg
Hi all, I have been using the map() function in the multiprocessing module to parallelize my tasks on a dual core CPU. My tasks are embarrassingly parallel, shared nothing tasks. In one of my runs, I found that the this function interleaves execution of two processes over a single list. So far

import bug

2009-10-31 Thread kj
I'm running into an ugly bug, which, IMHO, is really a bug in the design of Python's module import scheme. Consider the following directory structure: ham |-- __init__.py |-- re.py `-- spam.py ...with the following very simple files: % head ham/*.py == ham/__init__.py == == ham/re.py ==

Re: problem with read() write()

2009-10-31 Thread Zeynel
On Oct 31, 10:40 am, Alf P. Steinbach al...@start.no wrote: Thanks! This works. But I need to close the file before read and open it again with r, otherwise I get the garbage again. Can you give me the link where you got this in documentation: The mode 'w+' opens and truncates the file to 0

python os.path.exists failure

2009-10-31 Thread koranthala
Hi all, My code is as follows: path = r'C:/Program Files/testfolder/2.3/test.txt' if os.path.lexists(path): print 'Path Exists' else: print 'No file found in path - %s' %path print Popen(path, stdout=PIPE, shell=True).stdout.read() The output comes as No file found in path -

Re: import bug

2009-10-31 Thread Jon Clements
On Oct 31, 3:12 pm, kj no.em...@please.post wrote: I'm running into an ugly bug, which, IMHO, is really a bug in the design of Python's module import scheme.  Consider the following directory structure: ham |-- __init__.py |-- re.py `-- spam.py ...with the following very simple files:

Re: python os.path.exists failure

2009-10-31 Thread Benjamin Kaplan
On Sat, Oct 31, 2009 at 11:26 AM, koranthala koranth...@gmail.com wrote: Hi all,   My code is as follows: path = r'C:/Program Files/testfolder/2.3/test.txt' if os.path.lexists(path):    print 'Path Exists' else:    print 'No file found in path - %s' %path print Popen(path, stdout=PIPE,

Re: import bug

2009-10-31 Thread Stefan Behnel
kj, 31.10.2009 16:12: My sin appears to be having the (empty) file ham/re.py. So Python is confusing it with the re module of the standard library, and using it when the inspect module tries to import re. 1) it's a bad idea to name your own modules after modules in the stdlib 2) this has been

PIL Image.fromarray( ... , mode=1 )

2009-10-31 Thread Hans Georg Schaathun
Does anyone know how to save two-tone images represented as numpy arrays? I handle grayscale images by converting to PIL Image objects (mode=L) and then use the PIL save method, but I cannot make this work with mode=1. I have tried both boolean arrays and uint8 arrays (mod 2). In both cases I

How to import only one module in a package when the package __init__.py has already imports the modules?

2009-10-31 Thread Peng Yu
I have the following files, which are in the directory 'test'. The parent directory of 'test' is in $PYTHONPATH. I have 'from A import A' and 'from B import B' in '__init__.py', because I want to use 'test.A' and 'test.B' to refer to classes A and B rather than 'test.A.A' and 'test.B.B'. $ll -g

Re: Sqlite3. Substitution of names in query.

2009-10-31 Thread Carsten Haese
Lawrence D'Oliveiro wrote: In message mailman.2357.1256964121.2807.python-l...@python.org, Dennis Lee Bieber wrote: This way regular string interpolation operations (or whatever Python 3.x has replaced it with) are safe to construct the SQL, leaving only user supplied (or program

Re: self.__dict__ tricks

2009-10-31 Thread Tim Johnson
On 2009-10-31, Steven D'Aprano st...@remove-this-cybersource.com.au wrote: Idiomatic Python is to use CamelCase for classes. Can you point me to a discussion on Idiomatic Python, CamelCase and other matters? ... See PEP 8: http://www.python.org/dev/peps/pep-0008/ Got it. Thanks.

Re: How to get the realpath of a symbolic link?

2009-10-31 Thread Emile van Sebille
On 10/31/2009 12:03 AM Peng Yu said... Suppose that I have the following directory and files. I want to get the canonical path of a file, a directory or a symbolic link. For example, for 'b' below, I want to get its canonical path as '/private/tmp/abspath/b'. So, why isn't realpath working for

Re: import bug

2009-10-31 Thread kj
In 4aec591e$0$7629$9b4e6...@newsspool1.arcor-online.net Stefan Behnel stefan...@behnel.de writes: kj, 31.10.2009 16:12: My sin appears to be having the (empty) file ham/re.py. So Python is confusing it with the re module of the standard library, and using it when the inspect module tries to

Re: Are *.pyd's universal?

2009-10-31 Thread Carl Banks
On Oct 31, 6:49 am, Albert Hopkins mar...@letterboxes.org wrote: OTOH this doesn't happen in Linux because a) programs wanting the system's crypt library are looking for libcrypt.so and b) Linux doesn't look in your current directory (by default) for libraries. One other thing is that linux

Re: How to get the realpath of a symbolic link?

2009-10-31 Thread Peng Yu
On Sat, Oct 31, 2009 at 11:26 AM, Emile van Sebille em...@fenx.com wrote: On 10/31/2009 12:03 AM Peng Yu said... Suppose that I have the following directory and files. I want to get the canonical path of a file, a directory or a symbolic link. For example, for 'b' below, I want to get its

Re: import bug

2009-10-31 Thread Albert Hopkins
On Sat, 2009-10-31 at 16:27 +, kj wrote: 2) this has been fixed in Py3 In my post I illustrated that the failure occurs both with Python 2.6 *and* Python 3.0. Did you have a particular version of Python 3 in mind? I was not able to reproduce with my python3: $ head ham/*.py

Re: self.__dict__ tricks

2009-10-31 Thread MRAB
Hendrik van Rooyen wrote: On Friday, 30 October 2009 17:28:47 MRAB wrote: Wouldn't it be clearer if they were called dromedaryCase and BactrianCase? :-) Ogden Nash: The Camel has a single hump- The Dromedary, two; Or the other way around- I'm never sure. - Are You? If you make the first

Re: How to import only one module in a package when the package __init__.py has already imports the modules?

2009-10-31 Thread Duncan Booth
Peng Yu pengyu...@gmail.com wrote: I'm wondering if there is a way to make the following two things hold. Thank you1 1. When I 'import test', I can refer to class A as 'test.A'. 2. When I 'import test.A', I can refer to class A as 'test.A.A' and class B shall not be imported. No. Either

Re: How to get the realpath of a symbolic link?

2009-10-31 Thread Emile van Sebille
On 10/31/2009 10:11 AM Peng Yu said... My definition of 'realpath' is different from the definition of 'os.path.realpath'. But I'm not short what term I should use to describe. I use the following example to show what I want. In my example in the original post, '/tmp/abspath/b' is a

Re: list comprehension problem

2009-10-31 Thread Terry Reedy
alex23 wrote: Terry Reedy tjre...@udel.edu wrote: alex23 wrote: You're completely wrong. Immutability has nothing to do with identity, ... I'm honestly not getting your point here. Let me try again, a bit differently. I claim that the second statement, and therefor the first, can be seen

Re: How to get the realpath of a symbolic link?

2009-10-31 Thread Terry Reedy
Peng Yu wrote: On Sat, Oct 31, 2009 at 11:26 AM, Emile van Sebille em...@fenx.com wrote: On 10/31/2009 12:03 AM Peng Yu said... Suppose that I have the following directory and files. I want to get the canonical path of a file, a directory or a symbolic link. For example, for 'b' below, I want

Re: problem with read() write()

2009-10-31 Thread Terry Reedy
Zeynel wrote: On Oct 31, 10:40 am, Alf P. Steinbach al...@start.no wrote: Thanks! This works. But I need to close the file before read and open it again with r, otherwise I get the garbage again. Can you give me the link where you got this in documentation: The mode 'w+' opens and truncates the

Re: OT: DARPA red balloon challenge

2009-10-31 Thread John Nagle
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 location of all 10 balloons and

Re: How to get the realpath of a symbolic link?

2009-10-31 Thread Peng Yu
On Sat, Oct 31, 2009 at 1:10 PM, Emile van Sebille em...@fenx.com wrote: On 10/31/2009 10:11 AM Peng Yu said... My definition of 'realpath' is different from the definition of 'os.path.realpath'. But I'm not short what term I should use to describe. I use the following example to show what I

Re: Python newbie data structures question

2009-10-31 Thread codingJoe
On Oct 29, 2:06 am, Chris Rebert c...@rebertia.com wrote: On Wed, Oct 28, 2009 at 11:31 PM, codingJoe tracy.monte...@gmail.com wrote: Hi all! I am trying to choose the right data structure to do a value lookup with multiple keys. I want to lookup data by:  key, key,{ values } My

Re: problem with read() write()

2009-10-31 Thread Zeynel
On Oct 31, 3:11 pm, Terry Reedy tjre...@udel.edu wrote: Great, thanks. Zeynel wrote: On Oct 31, 10:40 am, Alf P. Steinbach al...@start.no wrote: Thanks! This works. But I need to close the file before read and open it again with r, otherwise I get the garbage again. Can you give me the

Re: How to get the realpath of a symbolic link?

2009-10-31 Thread Peng Yu
On Sat, Oct 31, 2009 at 1:46 PM, Terry Reedy tjre...@udel.edu wrote: Peng Yu wrote: On Sat, Oct 31, 2009 at 11:26 AM, Emile van Sebille em...@fenx.com wrote: On 10/31/2009 12:03 AM Peng Yu said... Suppose that I have the following directory and files. I want to get the canonical path of a

Re: Python 2.6.4: ./configure does not work

2009-10-31 Thread Ned Deily
In article bdb4ce25-22ea-4e83-8e73-ae53cd125...@a31g2000yqn.googlegroups.com, knipknap knipk...@gmail.com wrote: Huh, looks like the .bz2 package is broken (even though the md5 is fine). The .gz works fine. Hmm, the .bz2 from the official download page

Re: How to import only one module in a package when the package __init__.py has already imports the modules?

2009-10-31 Thread Peng Yu
On Sat, Oct 31, 2009 at 12:47 PM, Duncan Booth duncan.bo...@invalid.invalid wrote: Peng Yu pengyu...@gmail.com wrote: I'm wondering if there is a way to make the following two things hold. Thank you1 1. When I 'import test', I can refer to class A as 'test.A'. 2. When I 'import test.A', I

Re: How to import only one module in a package when the package __init__.py has already imports the modules?

2009-10-31 Thread Robert Kern
On 2009-10-31 15:31 PM, Peng Yu wrote: The original problem comes from the maintenance of the package. When A and B are large classes, it is better to put them in separate files under the directory 'test' than put them in the file 'test.py'. The interface 'test.A' is used by end users. However,

Re: How to import only one module in a package when the package __init__.py has already imports the modules?

2009-10-31 Thread Peng Yu
On Sat, Oct 31, 2009 at 4:14 PM, Robert Kern robert.k...@gmail.com wrote: On 2009-10-31 15:31 PM, Peng Yu wrote: The original problem comes from the maintenance of the package. When A and B are large classes, it is better to put them in separate files under the directory 'test' than put them

Re: datetime question

2009-10-31 Thread Ben Finney
Albert Hopkins mar...@letterboxes.org writes: No, I meant cleaning up the standard library in spite of incompatibilities was one of the goals of Python3 (PEP 3108). Ah, okay. That PEP is “Standard Library Reorganization” URL:http://www.python.org/dev/peps/pep-3108/, and is specifically about

Re: Why do you use python?

2009-10-31 Thread TerryP
For me a language is a language for the most part, doesn't matter... Python is a language I choose for any of several reasons: 0.) It is easy to setup dependent packages on both BSD, Linux, and Windows 1.) Most important things already have a Python binding somewhere 2.) Working in

Re: How to get the realpath of a symbolic link?

2009-10-31 Thread Wolodja Wentland
On Sat, Oct 31, 2009 at 14:48 -0500, Peng Yu wrote: On Sat, Oct 31, 2009 at 1:46 PM, Terry Reedy tjre...@udel.edu wrote: Peng Yu wrote: [ snip ] I find the following two files that define realpath. But I don't find 'realpath' in os.py. I looked at 'os.py'. But I don't understand how the

Re: How to import only one module in a package when the package __init__.py has already imports the modules?

2009-10-31 Thread Wolodja Wentland
On Sat, Oct 31, 2009 at 16:53 -0500, Peng Yu wrote: On Sat, Oct 31, 2009 at 4:14 PM, Robert Kern robert.k...@gmail.com wrote: [ snip ] I know that multiple classes or functions are typically defined in one file (i.e. module in python). However, I feel this make the code not easy to read.

Re: How to import only one module in a package when the package __init__.py has already imports the modules?

2009-10-31 Thread Robert Kern
On 2009-10-31 16:53 PM, Peng Yu wrote: On Sat, Oct 31, 2009 at 4:14 PM, Robert Kernrobert.k...@gmail.com wrote: On 2009-10-31 15:31 PM, Peng Yu wrote: The original problem comes from the maintenance of the package. When A and B are large classes, it is better to put them in separate files

Re: How to import only one module in a package when the package __init__.py has already imports the modules?

2009-10-31 Thread Peng Yu
On Sat, Oct 31, 2009 at 5:45 PM, Wolodja Wentland wentl...@cl.uni-heidelberg.de wrote: On Sat, Oct 31, 2009 at 16:53 -0500, Peng Yu wrote: On Sat, Oct 31, 2009 at 4:14 PM, Robert Kern robert.k...@gmail.com wrote: [ snip ] I know that multiple classes or functions are typically defined in one

Why 'import module' will not import module.py but the directory module?

2009-10-31 Thread Peng Yu
If I have both the directory 'module' and the file 'module.py' in a directory in $PYTHONPATH, python will import 'module' rather than 'module.py'. I'm wondering what is the design rationale of setting higher priorities to directories. Is there a way to reverse the priority? --

Re: Sqlite3. Substitution of names in query.

2009-10-31 Thread Lawrence D'Oliveiro
In message mailman.2376.1257005738.2807.python-l...@python.org, Carsten Haese wrote: Lawrence D'Oliveiro wrote: In message mailman.2357.1256964121.2807.python-l...@python.org, Dennis Lee Bieber wrote: This way regular string interpolation operations (or whatever Python 3.x has replaced

Re: Why 'import module' will not import module.py but the directory module?

2009-10-31 Thread Robert Kern
On 2009-10-31 18:51 PM, Peng Yu wrote: If I have both the directory 'module' and the file 'module.py' in a directory in $PYTHONPATH, python will import 'module' rather than 'module.py'. I'm wondering what is the design rationale of setting higher priorities to directories. Is there a way to

Re: Sqlite3. Substitution of names in query.

2009-10-31 Thread Carsten Haese
Lawrence D'Oliveiro wrote: In message mailman.2376.1257005738.2807.python-l...@python.org, Carsten Haese wrote: Lawrence D'Oliveiro wrote: In message mailman.2357.1256964121.2807.python-l...@python.org, Dennis Lee Bieber wrote: This way regular string interpolation operations (or

Re: Why 'import module' will not import module.py but the directory module?

2009-10-31 Thread Peng Yu
On Sat, Oct 31, 2009 at 7:02 PM, Robert Kern robert.k...@gmail.com wrote: On 2009-10-31 18:51 PM, Peng Yu wrote: If I have both the directory 'module' and the file 'module.py' in a directory in $PYTHONPATH, python will import 'module' rather than 'module.py'. I'm wondering what is the design

Re: How to import only one module in a package when the package __init__.py has already imports the modules?

2009-10-31 Thread Wolodja Wentland
On Sat, Oct 31, 2009 at 18:29 -0500, Peng Yu wrote: On Sat, Oct 31, 2009 at 5:45 PM, Wolodja Wentland wentl...@cl.uni-heidelberg.de wrote: On Sat, Oct 31, 2009 at 16:53 -0500, Peng Yu wrote: Are you serious? Do you *really* put each function in its own file? How exactly does this enhance

Re: Why 'import module' will not import module.py but the directory module?

2009-10-31 Thread Robert Kern
On 2009-10-31 19:16 PM, Peng Yu wrote: On Sat, Oct 31, 2009 at 7:02 PM, Robert Kernrobert.k...@gmail.com wrote: On 2009-10-31 18:51 PM, Peng Yu wrote: If I have both the directory 'module' and the file 'module.py' in a directory in $PYTHONPATH, python will import 'module' rather than

Problems in merge.py when building the Python MSI installer

2009-10-31 Thread Gabriel Genellina
I'm trying to build a Python MSI installer for Windows using the scripts provided at Tools\msi\ msi.py runs fine and generates a python-xxx.msi file. Then, when I run the merge.py script, I get these error messages: e:\prog\python\py3k\Tools\msi\msilib.py:8: DeprecationWarning: the sets

Re: How to import only one module in a package when the package __init__.py has already imports the modules?

2009-10-31 Thread Robert Kern
On 2009-10-31 19:21 PM, Wolodja Wentland wrote: On Sat, Oct 31, 2009 at 18:29 -0500, Peng Yu wrote: And I always put a single class in a file. Why? What do you gain by that? While it's never a good idea to follow the rule slavishly, it's often a good idea. Many classes are themselves a

Re: Are *.pyd's universal?

2009-10-31 Thread Steven D'Aprano
On Sat, 31 Oct 2009 23:58:33 +1300, Lawrence D'Oliveiro wrote: In message mailman.2365.1256979069.2807.python-l...@python.org, Albert Hopkins wrote: On Sat, 2009-10-31 at 21:32 +1300, Lawrence D'Oliveiro wrote: In message 6e603d9c-2be0-449c-9c3c-bab49e09e...@13g2000prl.googlegroups.com,

Re: How to import only one module in a package when the package __init__.py has already imports the modules?

2009-10-31 Thread Peng Yu
On Sat, Oct 31, 2009 at 7:21 PM, Wolodja Wentland wentl...@cl.uni-heidelberg.de wrote: On Sat, Oct 31, 2009 at 18:29 -0500, Peng Yu wrote: On Sat, Oct 31, 2009 at 5:45 PM, Wolodja Wentland wentl...@cl.uni-heidelberg.de wrote: On Sat, Oct 31, 2009 at 16:53 -0500, Peng Yu wrote: Are you

Re: import bug

2009-10-31 Thread Steven D'Aprano
On Sat, 31 Oct 2009 16:27:20 +, kj wrote: 1) it's a bad idea to name your own modules after modules in the stdlib Obviously, since it leads to the headaches this thread illustrates. But there is nothing intrisically wrong with it. The fact that it is problematic in Python is a design

Re: How to import only one module in a package when the package __init__.py has already imports the modules?

2009-10-31 Thread Dave Angel
Peng Yu wrote: On Sat, Oct 31, 2009 at 5:45 PM, Wolodja Wentland wentl...@cl.uni-heidelberg.de wrote: On Sat, Oct 31, 2009 at 16:53 -0500, Peng Yu wrote: On Sat, Oct 31, 2009 at 4:14 PM, Robert Kern robert.k...@gmail.com wrote: [ snip ] I know that multiple classes or

Re: How to import only one module in a package when the package __init__.py has already imports the modules?

2009-10-31 Thread Steven D'Aprano
On Sat, 31 Oct 2009 18:29:35 -0500, Peng Yu wrote: If two functions are too long to put in file, I generally put them in two different files. If two functions are too long for a single file, the functions are too big and need to be broken up into ten or thirty sub-functions each! Ideally, no

Re: How to import only one module in a package when the package __init__.py has already imports the modules?

2009-10-31 Thread Steven D'Aprano
On Sat, 31 Oct 2009 20:03:29 -0500, Peng Yu wrote: If it should ever happen that two functions are too long to put in a single file you should refactor your code. It is usually a good idea of breaking problems down into single steps (ie functions) so you never end up with a 5000 SLOC

Re: How to import only one module in a package when the package __init__.py has already imports the modules?

2009-10-31 Thread Steven D'Aprano
On Sat, 31 Oct 2009 16:53:50 -0500, Peng Yu wrote: I know that multiple classes or functions are typically defined in one file (i.e. module in python). However, I feel this make the code not easy to read. Therefore, I insist on one class or function per file (i.e module in python). When

Looking for help getting tkinter to work.

2009-10-31 Thread Shue Boks
I tried to compile Python and Tcl/Tk on Linux using the following files: Python-3.1.1.tar.gz tcl8.5.7-src.tar.gz Cannot get tkinter to work after compiling installing Tcl/Tk. I get the following error after compiling Python: Python build finished, but the necessary bits to build these modules

Re: How to import only one module in a package when the package __init__.py has already imports the modules?

2009-10-31 Thread Peng Yu
On Sat, Oct 31, 2009 at 10:03 PM, Steven D'Aprano st...@remove-this-cybersource.com.au wrote: On Sat, 31 Oct 2009 16:53:50 -0500, Peng Yu wrote: I know that multiple classes or functions are typically defined in one file (i.e. module in python). However, I feel this make the code not easy to

Re: How to import only one module in a package when the package __init__.py has already imports the modules?

2009-10-31 Thread Peng Yu
On Sat, Oct 31, 2009 at 9:42 PM, Steven D'Aprano st...@remove-this-cybersource.com.au wrote: On Sat, 31 Oct 2009 20:03:29 -0500, Peng Yu wrote: If it should ever happen that two functions are too long to put in a single file you should refactor your code. It is usually a good idea of breaking

Re: How to import only one module in a package when the package __init__.py has already imports the modules?

2009-10-31 Thread Robert Kern
Peng Yu wrote: I have defined 'long' in one of my previous message. I consider a file long, when it does not fit in one or two screen. Basically, I want to get a whole picture of the file after glancing of the file. I think you are going to have to get used to the fact that you have very

Re: How to import only one module in a package when the package __init__.py has already imports the modules?

2009-10-31 Thread Peng Yu
On Sat, Oct 31, 2009 at 9:34 PM, Steven D'Aprano st...@remove-this-cybersource.com.au wrote: On Sat, 31 Oct 2009 18:29:35 -0500, Peng Yu wrote: If two functions are too long to put in file, I generally put them in two different files. If two functions are too long for a single file, the

Re: How to import only one module in a package when the package __init__.py has already imports the modules?

2009-10-31 Thread Peng Yu
On Sat, Oct 31, 2009 at 9:18 PM, Dave Angel da...@ieee.org wrote: Peng Yu wrote: On Sat, Oct 31, 2009 at 5:45 PM, Wolodja Wentland wentl...@cl.uni-heidelberg.de wrote: On Sat, Oct 31, 2009 at 16:53 -0500, Peng Yu wrote: On Sat, Oct 31, 2009 at 4:14 PM, Robert Kern robert.k...@gmail.com

Re: How to import only one module in a package when the package __init__.py has already imports the modules?

2009-10-31 Thread Peng Yu
On Sat, Oct 31, 2009 at 10:35 PM, Robert Kern robert.k...@gmail.com wrote: Peng Yu wrote: I have defined 'long' in one of my previous message. I consider a file long, when it does not fit in one or two screen. Basically, I want to get a whole picture of the file after glancing of the file.

Re: How to import only one module in a package when the package __init__.py has already imports the modules?

2009-10-31 Thread Robert Kern
Peng Yu wrote: On Sat, Oct 31, 2009 at 10:35 PM, Robert Kern robert.k...@gmail.com wrote: Peng Yu wrote: I have defined 'long' in one of my previous message. I consider a file long, when it does not fit in one or two screen. Basically, I want to get a whole picture of the file after glancing

  1   2   >