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 os.path.

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 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 that I can be much m

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 particu

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 -- http://mail.python.org/mailman/list

Re: Sqlite3. Substitution of names in query.

2009-10-31 Thread Lawrence D'Oliveiro
In message , 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 the > DB-API parameter system -- so that they ar

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 mod

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 po

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.

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

2009-10-31 Thread Rominsky
On Oct 30, 11:09 pm, Peng Yu 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 including os and subp

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 implementatio

Re: datetime question

2009-10-31 Thread Ben Finney
Albert Hopkins 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 > > (unfortunately)

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 li

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 f

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: http://www.parashi

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 s

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 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? > > It's no

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

Re: Python 2.6.4: ./configure does not work

2009-10-31 Thread knipknap
On 31 Okt., 11:40, Albert Hopkins 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 the tarball: Huh,

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 ?-) -- http://mail.

Re: Are *.pyd's universal?

2009-10-31 Thread Lawrence D'Oliveiro
In message , 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 path in Windows, so the >> fact that Windows

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 an

Re: Are *.pyd's universal?

2009-10-31 Thread Carl Banks
On Oct 31, 1:32 am, Lawrence D'Oliveiro 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 could accidentally try to >

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, 'center_in

Re: Are *.pyd's universal?

2009-10-31 Thread Carl Banks
On Oct 31, 1:32 am, Lawrence D'Oliveiro 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 could accidentally try to >

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 th

Re: problem with read() write()

2009-10-31 Thread Zeynel
On Oct 31, 9:23 am, "Alf P. Steinbach" 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("h

Re: Why do you use python?

2009-10-31 Thread Jaime Buelta
On Oct 31, 11:31 am, "Alf P. Steinbach" 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" 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() But r

Re: problem with read() write()

2009-10-31 Thread Zeynel
On Oct 31, 9:55 am, "Alf P. Steinbach" wrote: > * Zeynel: > > > > > > > On Oct 31, 9:23 am, "Alf P. Steinbach" 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 wrote: > 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 ch

Re: problem with read() write()

2009-10-31 Thread Alf P. Steinbach
* Zeynel: On Oct 31, 9:55 am, "Alf P. Steinbach" wrote: * Zeynel: On Oct 31, 9:23 am, "Alf P. Steinbach" 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

Re: problem with read() write()

2009-10-31 Thread Dave Angel
Zeynel wrote: On Oct 31, 9:55 am, "Alf P. Steinbach" wrote: * Zeynel: On Oct 31, 9:23 am, "Alf P. Steinbach" 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 f

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 so

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" 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 bytes, while 'r

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 - C:/"Prog

Re: import bug

2009-10-31 Thread Jon Clements
On Oct 31, 3:12 pm, kj 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: > > % head ha

Re: python os.path.exists failure

2009-10-31 Thread Benjamin Kaplan
On Sat, Oct 31, 2009 at 11:26 AM, koranthala 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, shell=True).

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 be

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 to

Re: Sqlite3. Substitution of names in query.

2009-10-31 Thread Carsten Haese
Lawrence D'Oliveiro wrote: > In message , 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 the >> DB-AP

Re: self.__dict__ tricks

2009-10-31 Thread Tim Johnson
On 2009-10-31, Steven D'Aprano 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. > >>> invalid parameter shouldn

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 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 import re.

Re: Are *.pyd's universal?

2009-10-31 Thread Carl Banks
On Oct 31, 6:49 am, Albert Hopkins 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 binaries are usually l

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 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 canonical

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/*

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 le

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 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 import adds the

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

Re: list comprehension problem

2009-10-31 Thread Terry Reedy
alex23 wrote: Terry Reedy 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 as wrong. I also

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 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 cano

Re: problem with read() write()

2009-10-31 Thread Terry Reedy
Zeynel wrote: On Oct 31, 10:40 am, "Alf P. Steinbach" 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

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 submit

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 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 want.

Re: Python newbie data structures question

2009-10-31 Thread codingJoe
On Oct 29, 2:06 am, Chris Rebert wrote: > On Wed, Oct 28, 2009 at 11:31 PM, codingJoe 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 final product should be able to

Re: problem with read() write()

2009-10-31 Thread Zeynel
On Oct 31, 3:11 pm, Terry Reedy wrote: Great, thanks. > Zeynel wrote: > > On Oct 31, 10:40 am, "Alf P. Steinbach" 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

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 wrote: > Peng Yu wrote: >> >> On Sat, Oct 31, 2009 at 11:26 AM, Emile van Sebille >> 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,

Re: Python 2.6.4: ./configure does not work

2009-10-31 Thread Ned Deily
In article , knipknap 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 http://www.python.org/download/releases/2.6.4/ seems to have a perfectly good README and Makefile.pre.in. Problem with

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 wrote: > Peng Yu 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 >

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 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 in the file 't

Re: datetime question

2009-10-31 Thread Ben Finney
Albert Hopkins 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” http://www.python.org/dev/peps/pep-3108/>, and is specifically about removing or renaming mo

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 Pyt

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 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 function realp

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 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. Therefore, I insist o

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 Kern 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 'tes

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 wrote: > On Sat, Oct 31, 2009 at 16:53 -0500, Peng Yu wrote: >> On Sat, Oct 31, 2009 at 4:14 PM, Robert Kern wrote: > > [ snip ] > >> I know that multiple classes or functions are typically defined in one >> file (i.e. module in python). However,

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? -- http://mail.python.o

Re: Sqlite3. Substitution of names in query.

2009-10-31 Thread Lawrence D'Oliveiro
In message , Carsten Haese wrote: > Lawrence D'Oliveiro wrote: > >> In message , 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 generat

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 rever

Re: Sqlite3. Substitution of names in query.

2009-10-31 Thread Carsten Haese
Lawrence D'Oliveiro wrote: > In message , Carsten > Haese wrote: > >> Lawrence D'Oliveiro wrote: >> >>> In message , 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 onl

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 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 rationale of

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 > 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 the readability of the

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 Kern 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 wh

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 modu

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 se

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 , 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 so

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 wrote: > On Sat, Oct 31, 2009 at 18:29 -0500, Peng Yu wrote: >> On Sat, Oct 31, 2009 at 5:45 PM, Wolodja Wentland >> wrote: >> > On Sat, Oct 31, 2009 at 16:53 -0500, Peng Yu wrote: > >> > Are you serious? Do you *really* put each function in its o

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 desi

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 wrote: On Sat, Oct 31, 2009 at 16:53 -0500, Peng Yu wrote: On Sat, Oct 31, 2009 at 4:14 PM, Robert Kern wrote: [ snip ] I know that multiple classes or functions are typically defined in one file (i.e. mod

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, n

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). > > Wh

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 module

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 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 read. Therefore, I insist on

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 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 problems down into single

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 stran

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 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 functions are too > big and need

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 wrote: > Peng Yu wrote: >> >> On Sat, Oct 31, 2009 at 5:45 PM, Wolodja Wentland >> wrote: >> >>> >>> On Sat, Oct 31, 2009 at 16:53 -0500, Peng Yu wrote: >>> On Sat, Oct 31, 2009 at 4:14 PM, Robert Kern wrote: >>> >>> [ snip ] >>> >>

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 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. > > I think you

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 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. I think

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

2009-10-31 Thread Terry Reedy
Peng Yu wrote: 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 function realpath is introduced in the name space in os.path. Would you please let me know? gfind . ! -path '*backup*' -name "*.py" -type

Re: import bug

2009-10-31 Thread Gabriel Genellina
En Sat, 31 Oct 2009 12:12:21 -0300, kj escribió: I'm running into an ugly bug, which, IMHO, is really a bug in the design of Python's module import scheme. The basic problem is that the "import scheme" was not designed in advance. It was a very simple thing at first. Then came packages. And

Re: list comprehension problem

2009-10-31 Thread Steven D'Aprano
On Sat, 31 Oct 2009 14:12:40 -0400, Terry Reedy wrote: > alex23 wrote: >> Terry Reedy 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 cla

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 22:29:12 -0500, Peng Yu wrote: >>> In my question, module A and B exist just for the sake of >>> implementation. Even if I have module A and B, I don't want the user >>> feel the existence of module A and B. I want them feel exact like >>> class A and B are defined in module 't

  1   2   >