May Introduction to Python class

2010-04-27 Thread Steve Holden
Holden Web is pleased to announce the next run of its popular three-day
Introduction to Python class in Washington DC on May 11-13, 2010.

Further details of all current event listings are available from

  http://holdenweb.eventbrite.com/

regards
 Steve
-- 
Steve Holden   +1 571 484 6266   +1 800 494 3119
See PyCon Talks from Atlanta 2010  http://pycon.blip.tv/
Holden Web LLC http://www.holdenweb.com/
UPCOMING EVENTS:http://holdenweb.eventbrite.com/
-- 
http://mail.python.org/mailman/listinfo/python-announce-list

Support the Python Software Foundation:
http://www.python.org/psf/donations/


PyCon Australia CFP: One Day Left!

2010-04-27 Thread Richard Jones
The Call For Proposals for PyCon Australia 2010 FINISHES TOMORROW!

Presentation subjects may range from reports on open source,
academic and commercial projects to tutorials and case studies.
As long as a presentation is interesting and potentially useful
to the Python community, it will be considered for inclusion in
the program.

We're especially interested in short presentations that will teach
conference-goers something new and useful. Can you show attendees
how to use a module? Explore a Python language feature? Package
an application?

Submit your proposal here: http://pycon-au.org/cfp

As always, please pass this message on to people you feel will find it
interesting.


Richard Jones
PyCon Australia 2010
http://pycon-au.org/
-- 
http://mail.python.org/mailman/listinfo/python-announce-list

Support the Python Software Foundation:
http://www.python.org/psf/donations/


SWIG + expy

2010-04-27 Thread Yingjie Lan
Hi,

Is it possible to use SWIG to parse C/C++, and provide an interface for me to 
generate some code? I thought it might be good to have SWIG help generate expy 
(see http://expy.sourceforge.net) files, then generate the python extension via 
expy.

Yingjie


  
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: WIN32 - get the GUID of a Network Device

2010-04-27 Thread Tim Golden

On 26/04/2010 22:07, Tim Roberts wrote:

Tim Golden wrote:

On 26/04/2010 09:49, Richard Lamboj wrote:

thanks for your response. No, i don't mean the MAC Address. I mean
the GUID -
Sample: {1E2428C1-9F2C-48D7-AB53-3229DFB7E217}

I want to change TcpAckFrequency and TcpDelTicks of a Network
Interface. I Try
to change it over the Registry, but maybe there is another way?


OK; I'm going to hope that Tim Roberts or someone equally
knowledgeable can
kick in here as devices really isn't my area. However this looks like
it *might*
be doing what you want:

code
import wmi

for nic in c.Win32_NetworkAdapter (MACAddress=i.MACAddress):
   for pnp in c.Win32_PNPEntity (DeviceID=nic.PNPDeviceID):
 print pnp.Caption, =, pnp.ClassGuid
/code


No, the PnP class GUID is the Class line from the top of the INF
file.  That will be the same for all network cards.

You can look up the network interface GUID in the registry, in
HKLM\SOFTWARE\Microsoft\Windows NT\CurrentVersion\NetworkCards.  There's
one subkey for each interface, containing a Description and a
ServiceName.  The ServiceName is the interface GUID.



Thanks, Tim. I was sure you'd be in the know :)

TJG
--
http://mail.python.org/mailman/listinfo/python-list


Re: Detect OS shutdown or user logout across different operating systems

2010-04-27 Thread Tim Golden

On 27/04/2010 03:09, pyt...@bdurham.com wrote:

Is there a OS portable way to have a Python script detect when
its operating system is shutting down or a user is logging out?

If not, any Windows specific tips on how to detect these events?

Thank you,
Malcolm



Doubt v. much if there's anything x-platform. I recently wrote-up
the work done my Klaas Tjebbes (sp?) which I think will do what
you want:

http://timgolden.me.uk/python/win32_how_do_i/track-session-events.html

TJG


--
http://mail.python.org/mailman/listinfo/python-list


Re: SWIG + expy

2010-04-27 Thread Stefan Behnel

Yingjie Lan, 27.04.2010 08:30:

Is it possible to use SWIG to parse C/C++, and provide an interface for
me to generate some code? I thought it might be good to have SWIG help
generate expy files, then generate the python extension via expy.


There have been similar discussions on the Cython mailing list (you might 
want to search the archives). The main theme seems to be that clang 
provides a suitable parser, and several people have used it to write up a 
code generator for their specific needs (you might want to look at those).


Stefan

--
http://mail.python.org/mailman/listinfo/python-list


Re: chr(i) ASCII under Python 3

2010-04-27 Thread Antoine Pitrou
Le Mon, 26 Apr 2010 22:26:28 +0200, Alf P. Steinbach a écrit :
 On 26.04.2010 22:12, * Dodo:
 Hi all,
 Under python 2.6, chr() Return a string of one character whose ASCII
 code is the integer i. (quoted from docs.python.org) Under python 3.1,
 chr() Return the string of one character whose Unicode codepoint is
 the integer i.

 I want to convert a ASCII code back to a character under python 3, not
 Unicode.

 How can I do that?
 
 Just use chr().

Or, if you want a bytes object, just use the bytes constructor:

 bytes([65])
b'A'

Regards

Antoine.

-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Some objects missing from tkinter

2010-04-27 Thread Peter Otten
Lie Ryan wrote:

 In fact, never trust IDLE. IDLE is a nice IDE when the alternative is
 Notepad; but for serious work, you need a real IDE or a programmer's
 text editor (vim or emacs, whichever side you're in).

Some people, when confronted with a problem, think I know, I'll use emacs. 
Now they have two problems.

More seriously, the subset of emacs I am using is probably supported by 
idle, too. That's why I sympathize with the OP's decision to stick with 
idle.

Peter
-- 
http://mail.python.org/mailman/listinfo/python-list


keyboard shortcuts glade+python

2010-04-27 Thread varnikat t
How to use keyboard shortcuts like ctrl+o for opening a file from menubar
menuitm OPEN in python+GLADE?

-- 
Varnika Tewari
-- 
http://mail.python.org/mailman/listinfo/python-list


KeyboardInterrupt and DiskIO

2010-04-27 Thread Björn Lindqvist
DiskIO appears to not be interruptable. For example:

 open('bighugefile.sql').read()

Pressing Ctrl-C (on Linux with python 2.6.4) will not interrupt the
command. I believe that it used to in previous versions of python but
I may be mistaken. Is it supposed to be that way? The behavior is
annoying and in other environments ctrl-c interrupts disk io.


-- 
mvh Björn
-- 
http://mail.python.org/mailman/listinfo/python-list


Open Source Pivot table (OLAP cube?)

2010-04-27 Thread Laszlo Nagy


 Hi All,

I'm planning to create a new visual component for wxPython, for 
designing, creating and printing pivot tables. Also known as: decision 
cube, OLAP cube. I was searching on the internet for something similar, 
but I could not find any open source version (or free to use, at least). 
The only available free program was jmagallanes ( 
http://jmagallanes.sourceforge.net/en/ ) but it is a stand alone 
application. I would like to create something that has Python bindings 
(more preferably, written in Python and is extensible).


Before I start on this project, can you please confirm that there is no 
such thing available? I do not want to work on something that is already 
there.


Thanks,

  Laszlo

--
http://mail.python.org/mailman/listinfo/python-list


Re: chr(i) ASCII under Python 3

2010-04-27 Thread Dave Angel

Dodo wrote:

Hi all,
Under python 2.6, chr() Return a string of one character whose ASCII 
code is the integer i. (quoted from docs.python.org)
Under python 3.1, chr() Return the string of one character whose 
Unicode codepoint is the integer i.


I want to convert a ASCII code back to a character under python 3, not 
Unicode.


How can I do that?

Dorian


Like a lot of things, it depends on why you're asking what you are.

Characters are in Unicode on Python 3.x, by definition.  That's not a 
problem, it's a feature.  Such a character is 16 bits, and if it's an 
ASCII value, the bottom 7 bits exactly match ASCII, and the remaining 
ones are zero.


However, sometimes you don't really want strings of characters, you want 
an array of 8 bit values, and you're used to the equivalence that 
earlier versions of Python give you.  In those cases, sometimes a string 
(Unicode) works transparently, and sometimes you really want a byte 
array.  Simplest example is when you're calling a DLL written in another 
language.


The types bytes and bytearray are considered sequences of integers (each 
of range 0 to 255), rather than characters.  And there are ways to 
convert back and forth between those and real strings.


DaveA



--
http://mail.python.org/mailman/listinfo/python-list


Re: Some objects missing from tkinter

2010-04-27 Thread Lie Ryan
On 04/27/10 18:01, Peter Otten wrote:
 Lie Ryan wrote:
 
 In fact, never trust IDLE. IDLE is a nice IDE when the alternative is
 Notepad; but for serious work, you need a real IDE or a programmer's
 text editor (vim or emacs, whichever side you're in).
 
 Some people, when confronted with a problem, think I know, I'll use emacs. 
 Now they have two problems.
 
 More seriously, the subset of emacs I am using is probably supported by 
 idle, too. That's why I sympathize with the OP's decision to stick with 
 idle.

It's not about IDLE's text editing capability, which is perfectly fine.
It's about IDLE mangling your program's execution due to IDLE being
written in Python itself. It's often the case your program would run
fine inside IDLE but crashes badly outside; that's why if you need to
use IDLE, test your program in command line as well. Otherwise you're
going to be surprised.
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Download Proprietary Microsoft Products Now

2010-04-27 Thread Lie Ryan
On 04/27/10 08:41, Andrej Mitrovic wrote:
 Although I agree, moving away from VS would be nice. Since Unladen
 Swallow will eventually be merged with Python, will the dev team
 consider trying out Clang as an alternative to VS?

What would Unladen Swallow brings that would allow the development of
CPython to move away from VS? Isn't Unladen Swallow's goal is only to
speed up CPython. Do you mean PyPy?
-- 
http://mail.python.org/mailman/listinfo/python-list


Python compiled modules are too big in size (even after strip)

2010-04-27 Thread King
Hi,

I have just compiled python 2.6.5 from sources on ubuntu hardy 8.04.
I have used a simple script to do everything in one go:

./configure --enable-shared
make
make install

Python is compiled and installed successfully. However the
modules(_socket.so, _random.so etc) are two big in terms of file size.
They are around 4.5-5.0 mb each. I have used strip strip-all *.so,
but still size is around 1.5 mb each. This is still too big compare to
size of modules on ubuntu karmic's pre installed python 2.6.5.

Am I missing something here? Do I have to re-configure or re-compile
the python again from sources?

Regards

Prashant
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Some objects missing from tkinter

2010-04-27 Thread Paul Rudin
Peter Otten __pete...@web.de writes:


 Some people, when confronted with a problem, think I know, I'll use emacs. 
 Now they have two problems.

Probably you know this ... but the original form of this saying had
regular expressions in place of emacs.

Since Jamie Zawinski coined this saying and he was a significant
contributor to XEmacs it's quite ironic to see it in the form you give
:)
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Engineering numerical format PEP discussion

2010-04-27 Thread Lie Ryan
On 04/27/10 10:36, Keith wrote:
 I think it's worth making the print statement (or print function, as
 the case may be) let us do engineering notation, just like it lets us
 specify scientific notation.

The print statement/function does no magic at all in specifying how
numbers look like when. The apparently magical formatting is done by the
%-operator and for {}-style formatting, the obj.__format__().

If you're using the {}-format, you can override .__format__() to define
your own formatting mini-language.

If you need to, you can monkey patch format() so that it wraps int/float
in Engineer wrapper that defines Engineer.__format__() to whatever
formatting style you're using.
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: when should I explicitly close a file?

2010-04-27 Thread Lawrence D'Oliveiro
In message mailman.2162.1272018097.23598.python-l...@python.org, Adam 
Tauno Williams wrote:

 On Fri, 2010-04-23 at 16:29 +1200, Lawrence D'Oliveiro wrote:

 Any implementation that doesn’t do reference-counting is brain-damaged.
 
 Why?

Because a) it uses extra memory needlessly, and b) waiting until an object 
has dropped out of cache before touching it again just slows things down.

 There are much better ways to do memory management / garbage
 collection;  especially when dealing with large applications.

Especially with large applications, the above considerations apply even more 
so.

If you don’t agree, you might as well stick to Java.
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Engineering numerical format PEP discussion

2010-04-27 Thread Lie Ryan
On 04/27/10 10:47, MRAB wrote:
 Mark Dickinson wrote:
 On Apr 26, 4:36 am, Keith keith.braff...@gmail.com wrote:
 I am considering writing a PEP for the inclusion of an engineering
 format specifier, and would appreciate input from others.

 [...]

 I am thinking that if we simply added something like %n (for eNgineer)
 to the list of format specifiers that we could make life easier for
 engineers:

 (%n % 12345)  == 12.345e+03
 (%n %  1234)  == 1.234e+03
 (%n %   123)  == 123e+00
 (%n % 1.2345e-5)  == 12.345e+06

 I don't think there's much chance of getting changes to old-style
 string formatting accepted;  you might be better off aiming at the new-
 style string formatting.  (And there, the 'n' modifier is already
 taken for internationalization, so you'd have to find something
 different. :)

 e is already used, n is already used, g is already used, etc
 
 t for powers of a thousand, perhaps? (Or m?)

or perhaps as an extension to 'e', activated by '3e' (but that's
occupied for adding spaces, need to think of another way...)
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Engineering numerical format PEP discussion

2010-04-27 Thread Gregory Ewing

Keith wrote:

I kinda like m for the whole Greco-
Roman angle, now that you point it out :-)


I like m, too.

--
Greg
--
http://mail.python.org/mailman/listinfo/python-list


Re: Open Source Pivot table (OLAP cube?)

2010-04-27 Thread Jon Clements
On 27 Apr, 10:10, Laszlo Nagy gand...@shopzeus.com wrote:
   Hi All,

 I'm planning to create a new visual component for wxPython, for
 designing, creating and printing pivot tables. Also known as: decision
 cube, OLAP cube. I was searching on the internet for something similar,
 but I could not find any open source version (or free to use, at least).
 The only available free program was jmagallanes 
 (http://jmagallanes.sourceforge.net/en/) but it is a stand alone
 application. I would like to create something that has Python bindings
 (more preferably, written in Python and is extensible).

 Before I start on this project, can you please confirm that there is no
 such thing available? I do not want to work on something that is already
 there.

 Thanks,

    Laszlo

Please note: this is not a direct answer to your question.

I would personally go for a client-server model; not worrying what the
server is written in or how it works. For some reason I have a scary
thought of your widget pulling in 100million records and cross-tabbing
two dimensions :) Don't worry about python bindings or such, why not
try and find something that can take an OLAP query, maintain
aggregates/computations on a DB that can possibly return in XML/JSON/
WHATEVER then just have your widget render visually the response and
send out XML/JSON/WHATEVER on click events.

Basically your widget is a renderer and UI to update the MDX/whatever
instructions in the OLAP server.

Of course, for small datasets, just nested dicts-of-dicts rendered
would probably do.

hth,

Jon.

-- 
http://mail.python.org/mailman/listinfo/python-list


Re: running .py files on Linux

2010-04-27 Thread Tingting HAN
2010/4/27 Tingting HAN hihigh...@gmail.com

 I did as you say:
 hantingt...@tityro:~/Downloads$ ls
 hdfview_install_linux32.bin  PythonPyTables  triMC3D  triMC3D_v1.0.0.tar.gz
 hantingt...@tityro:~/Downloads$ md5sum triMC3D_v1.0.0.tar.gz  triMC3D.md5
 hantingt...@tityro:~/Downloads$ ls
 hdfview_install_linux32.bin  triMC3D  triMC3D_v1.0.0.tar.gz
 PythonPyTables   triMC3D.md5
 hantingt...@tityro:~/Downloads$ md5sum -c triMC3D.md5
 triMC3D_v1.0.0.tar.gz: OK
 hantingt...@tityro:~/Downloads$ tar zxvf triMC3D_v1.0.0.tar.gz



 So as it shows OK, the package is not corrupt. I extracted it and ran the
 .py files again, but there is still the same error as before:



 hantingt...@tityro:~/Downloads/triMC3D-1.0.0/python$ python

 gentest_empty.py

 Traceback (most recent call last):
   File gentest_empty.py, line 8, in module

 from tables import *
   File /usr/lib/python2.6/dist-packages/tables/__init__.py, line 76, in
 module
 from tables.file import File, openFile, copyFile
   File /usr/lib/python2.6/dist-packages/tables/file.py, line 44, in
 module
 from tables import hdf5Extension
   File hdf5Extension.pyx, line 11, in hdf5Extension
 ImportError: No module named utilsExtension



 I attach two .py files from the downloaded package in this email. Could you
 please try running them and see what is the problem?

 2010/4/26 alex goretoy agore...@gmail.com

 make sure the tar, zip or package you downloaded isn't corrupt. verify it
 with a md5sum and then extract it. just a thought.
 Thank you,
 -Alex Goretoy
 http://launchpad.net/~a1g


   On Mon, Apr 26, 2010 at 11:05 AM, Tingting HAN hihigh...@gmail.comwrote:

   Dear Officer,
 I downloaded a C code packet which contains many .py files. When I try to
 run these.py files on my computer with Linux system, for every .py file the
 following error occurs:

 hantingt...@tityro:~/Downloads/triMC3D/python$ python

 Python 2.6.4 (r264:75706, Dec  7 2009, 18:43:55)

 [GCC 4.4.1] on linux2

 Type help, copyright, credits or license for more information.

 

 [4]+  Stopped python

 hantingt...@tityro:~/Downloads/triMC3D/python$ python test_detector.py

 Traceback (most recent call last):

   File test_detector.py, line 9, in module

 from tables import *

   File /usr/lib/python2.6/dist-packages/tables/__init__.py, line 76,
 in module

 from tables.file import File, openFile, copyFile

   File /usr/lib/python2.6/dist-packages/tables/file.py, line 44, in
 module

 from tables import hdf5Extension

   File hdf5Extension.pyx, line 11, in hdf5Extension

 ImportError: No module named utilsExtension
 I downloaded the .

 I sincerely hope you could give me some advice to solve the problem.

 --
 Best regards,
 HAN Tingting

 ETSI de Telecomunicación - office C-203-1
 Dpto. Ingeniería Electrónica
 Ciudad Universitaria s/n
 Madrid 28040,  Spain
 TEL: +34 65 232 4340


 --
 http://mail.python.org/mailman/listinfo/python-list





 --
 Best regards,
 HAN Tingting

 ETSI de Telecomunicación - office C-203-1
 Dpto. Ingeniería Electrónica
 Ciudad Universitaria s/n
 Madrid 28040,  Spain
 TEL: +34 65 232 4340
 Department of Photoelectric Information Engineering
 Zhejiang University
 Hangzhou 310027, P. R.China




-- 
Best regards,
HAN Tingting

ETSI de Telecomunicación - office C-203-1
Dpto. Ingeniería Electrónica
Ciudad Universitaria s/n
Madrid 28040,  Spain
TEL: +34 65 232 4340
Department of Photoelectric Information Engineering
Zhejiang University
Hangzhou 310027, P. R.China


configuration.py
Description: Binary data


gentest_empty.py
Description: Binary data
-- 
http://mail.python.org/mailman/listinfo/python-list


Python 2.X vs. 3.X - level of acceptance?

2010-04-27 Thread Stephan Schulz
Hi!

I've been using Python for a long while (certainly since it was 1.X),
and I've taught some aspects of it in my lectures. I'm now thinking of
preparing a new lecture where some of the theoretical concepts will be
illustrated by implementations of e.g. automata and DPLL provers,
preferably in Python.

I'm so far only familiar with Python 2.X. Is Python 3 sucessful enough
to make a switch worthwhile now? Or will students still face an
infrastructure with mostly Python 2.X deployed in, say, 2 years time,
when they graduate?

Bye,

Stephan

-- 
-- It can be done! -
   Please email me as sch...@eprover.org (Stephan Schulz)

-- 
http://mail.python.org/mailman/listinfo/python-list


Re: running .py files on Linux

2010-04-27 Thread Chris Rebert
On Tue, Apr 27, 2010 at 3:54 AM, Tingting HAN hihigh...@gmail.com wrote:
snip
 gentest_empty.py
 Traceback (most recent call last):
   File gentest_empty.py, line 8, in module
     from tables import *
   File /usr/lib/python2.6/dist-packages/tables/__init__.py, line 76, in
 module
     from tables.file import File, openFile, copyFile
   File /usr/lib/python2.6/dist-packages/tables/file.py, line 44, in
 module
     from tables import hdf5Extension
   File hdf5Extension.pyx, line 11, in hdf5Extension
 ImportError: No module named utilsExtension



 I attach two .py files from the downloaded package in this email. Could
 you please try running them and see what is the problem?

Seems like your version of PyTables may be outdated. Your error looks
similar to that described in this (fixed) bug:
http://www.pytables.org/trac/ticket/183

What version of PyTables do you have installed?

Cheers,
Chris
--
http://blog.rebertia.com
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Open Source Pivot table (OLAP cube?)

2010-04-27 Thread Laszlo Nagy



Please note: this is not a direct answer to your question.

I would personally go for a client-server model; not worrying what the
server is written in or how it works. For some reason I have a scary
thought of your widget pulling in 100million records and cross-tabbing
two dimensions :) Don't worry about python bindings or such, why not
try and find something that can take an OLAP query, maintain
aggregates/computations on a DB that can possibly return in XML/JSON/
WHATEVER then just have your widget render visually the response and
send out XML/JSON/WHATEVER on click events.
  
Regarding the implementation, I was already thinking about separation of 
the data query and the rendering part. Your answer was particularly 
useful, because I was not thinking about MDX and a real client server 
model. Until now. :-)


Can you tell something about the licence of the MDX language? Can I just 
make a new engine/library that uses MDX? Or do I need to develop a new 
query language in order to make it open source?


It seems strange that several open source RDBMS exist (sqlite, 
postgresql, mysql) but none of them support multi dimensional queries. 
Is this a very difficult thing to implement? Even if we could only have 
a not-so-efficient implementation that works with smaller datasets (100 
000 records or so), it would be nice to have it.


Thanks

  Laszlo

--
http://mail.python.org/mailman/listinfo/python-list


Python 2.5.x _winreg - rename a subkey

2010-04-27 Thread Richard Lamboj

Hello,

is there a way to rename a subkey?

Kind Regards,

Richi
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Python 2.X vs. 3.X - level of acceptance?

2010-04-27 Thread Stefan Behnel

Stephan Schulz, 27.04.2010 12:57:

I've been using Python for a long while (certainly since it was 1.X),
and I've taught some aspects of it in my lectures. I'm now thinking of
preparing a new lecture where some of the theoretical concepts will be
illustrated by implementations of e.g. automata and DPLL provers,
preferably in Python.

I'm so far only familiar with Python 2.X. Is Python 3 sucessful enough
to make a switch worthwhile now? Or will students still face an
infrastructure with mostly Python 2.X deployed in, say, 2 years time,
when they graduate?


Most likely, yes, although it will depend very much on the exact spot you 
look at. In two years time, I'd expect that the mass of open-source 
projects will have made the switch, many companies will have followed, but 
many others will still be using Py2. It depends on the size of their code 
base, the availability of truly required dependencies, the urge to keep 
using a well supported and future proof runtime, and various non-technical 
issues.


Anyway, if you intend to use Python for teaching, I'd consider it worth 
teaching Py3 now, simply because it's a cleaner language that goes out of 
your way another little bit more than Py2. It's also less outdated cruft to 
talk about, e.g. old-style classes are gone, unicode issues are mostly gone 
or at least easier to explain (and worth explaining when they occur). It's 
just more fun to work with. :)


Just my two €-cents...

Stefan

--
http://mail.python.org/mailman/listinfo/python-list


Re: Open Source Pivot table (OLAP cube?)

2010-04-27 Thread Jon Clements
On 27 Apr, 12:16, Laszlo Nagy gand...@shopzeus.com wrote:
  Please note: this is not a direct answer to your question.

  I would personally go for a client-server model; not worrying what the
  server is written in or how it works. For some reason I have a scary
  thought of your widget pulling in 100million records and cross-tabbing
  two dimensions :) Don't worry about python bindings or such, why not
  try and find something that can take an OLAP query, maintain
  aggregates/computations on a DB that can possibly return in XML/JSON/
  WHATEVER then just have your widget render visually the response and
  send out XML/JSON/WHATEVER on click events.

 Regarding the implementation, I was already thinking about separation of
 the data query and the rendering part. Your answer was particularly
 useful, because I was not thinking about MDX and a real client server
 model. Until now. :-)

 Can you tell something about the licence of the MDX language? Can I just
 make a new engine/library that uses MDX? Or do I need to develop a new
 query language in order to make it open source?

IIRC it was MS' analysis services, but it seems so wide spread --
I'm not sure if there's an ISO standard on it or anything...
I'm not a solicitor/lawyer-- GIYF.


 It seems strange that several open source RDBMS exist (sqlite,
 postgresql, mysql) but none of them support multi dimensional queries.

Not strange at all! When was MD part of the SQL standard? :)

One method would be to create a load of triggers that keep summary
info.
Depends on the DB and other stuff... Although then you're just
duplicating
work, and making the DB store meta-data, when something else should
be
doing that for it (in another DB maybe :) )

 Is this a very difficult thing to implement? Even if we could only have
 a not-so-efficient implementation that works with smaller datasets (100
 000 records or so), it would be nice to have it.

Implement properly for small things (or at least acceptability),
probably not. To do it properly
waste your time and everyone else's -- oh yes.

Let's put it this way -- would you write your own RDBMS from scratch?

It also depends if you want immediate information, or if you're
happy for the queried DB to be slightly out of sync with the main DB.
So many options -- but I think this is getting OT for the python list.


 Thanks

    Laszlo

Again, my humble opinion,

Jon.
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Python 2.X vs. 3.X - level of acceptance?

2010-04-27 Thread Peter Otten
Stephan Schulz wrote:

 I've been using Python for a long while (certainly since it was 1.X),
 and I've taught some aspects of it in my lectures. I'm now thinking of
 preparing a new lecture where some of the theoretical concepts will be
 illustrated by implementations of e.g. automata and DPLL provers,
 preferably in Python.
 
 I'm so far only familiar with Python 2.X. Is Python 3 sucessful enough
 to make a switch worthwhile now? Or will students still face an
 infrastructure with mostly Python 2.X deployed in, say, 2 years time,
 when they graduate?

I think you can make the decision light-heartedly, based on the current 
availability of libraries you'd like your students to use. The difficulty of 
switching between 2.x and 3.x in whatever direction is likely several 
magnitudes smaller than grokking the contents of your lecture.

That said, I expect 2.x to dominate for the next five rather than two years.

Peter
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: running .py files on Linux

2010-04-27 Thread Tingting HAN
I apologize that I am new to Linux. I find this in my computer:
/usr/lib/python2.6/dist-packages/tables$
How should I know which version of PyTables has been installed? What is the
command?
Which version should I download to solve the problem? And could you please
give me the website link to download it because I am afraid I can not find
the right place exactly.



2010/4/27 Chris Rebert c...@rebertia.com

 On Tue, Apr 27, 2010 at 3:54 AM, Tingting HAN hihigh...@gmail.com wrote:
 snip
  gentest_empty.py
  Traceback (most recent call last):
File gentest_empty.py, line 8, in module
  from tables import *
File /usr/lib/python2.6/dist-packages/tables/__init__.py, line 76,
 in
  module
  from tables.file import File, openFile, copyFile
File /usr/lib/python2.6/dist-packages/tables/file.py, line 44, in
  module
  from tables import hdf5Extension
File hdf5Extension.pyx, line 11, in hdf5Extension
  ImportError: No module named utilsExtension
 
 
 
  I attach two .py files from the downloaded package in this email. Could
  you please try running them and see what is the problem?

 Seems like your version of PyTables may be outdated. Your error looks
 similar to that described in this (fixed) bug:
 http://www.pytables.org/trac/ticket/183

 What version of PyTables do you have installed?

 Cheers,
 Chris
 --
 http://blog.rebertia.com




-- 
Best regards,
HAN Tingting

ETSI de Telecomunicación - office C-203-1
Dpto. Ingeniería Electrónica
Ciudad Universitaria s/n
Madrid 28040,  Spain
TEL: +34 65 232 4340
Department of Photoelectric Information Engineering
Zhejiang University
Hangzhou 310027, P. R.China
-- 
http://mail.python.org/mailman/listinfo/python-list


May Introduction to Python class

2010-04-27 Thread Steve Holden
Holden Web is pleased to announce the next run of its popular three-day
Introduction to Python class in Washington DC on May 11-13, 2010.

Further details of all current event listings are available from

  http://holdenweb.eventbrite.com/

regards
 Steve
-- 
Steve Holden   +1 571 484 6266   +1 800 494 3119
See PyCon Talks from Atlanta 2010  http://pycon.blip.tv/
Holden Web LLC http://www.holdenweb.com/
UPCOMING EVENTS:http://holdenweb.eventbrite.com/
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Python compiled modules are too big in size (even after strip)

2010-04-27 Thread Jon Clements
On 27 Apr, 10:43, King animator...@gmail.com wrote:
 Hi,

 I have just compiled python 2.6.5 from sources on ubuntu hardy 8.04.
 I have used a simple script to do everything in one go:

 ./configure --enable-shared
 make
 make install

 Python is compiled and installed successfully. However the
 modules(_socket.so, _random.so etc) are two big in terms of file size.
 They are around 4.5-5.0 mb each. I have used strip strip-all *.so,
 but still size is around 1.5 mb each. This is still too big compare to
 size of modules on ubuntu karmic's pre installed python 2.6.5.

 Am I missing something here? Do I have to re-configure or re-compile
 the python again from sources?

 Regards

 Prashant

Err, the common install on karmic is 2.6.4...

IIRC (and probably not) the default was 2.6.2 on hardy

Obviously doesn't help where you're finding large sized shared libs,
but anyway...

Jon.


-- 
http://mail.python.org/mailman/listinfo/python-list


Re: running .py files on Linux

2010-04-27 Thread Chris Rebert
 2010/4/27 Chris Rebert c...@rebertia.com
 On Tue, Apr 27, 2010 at 3:54 AM, Tingting HAN hihigh...@gmail.com wrote:
 snip
  gentest_empty.py
  Traceback (most recent call last):
    File gentest_empty.py, line 8, in module
      from tables import *
    File /usr/lib/python2.6/dist-packages/tables/__init__.py, line 76,
  in
  module
      from tables.file import File, openFile, copyFile
    File /usr/lib/python2.6/dist-packages/tables/file.py, line 44, in
  module
      from tables import hdf5Extension
    File hdf5Extension.pyx, line 11, in hdf5Extension
  ImportError: No module named utilsExtension
 
 
 
  I attach two .py files from the downloaded package in this email. Could
  you please try running them and see what is the problem?

 Seems like your version of PyTables may be outdated. Your error looks
 similar to that described in this (fixed) bug:
 http://www.pytables.org/trac/ticket/183

 What version of PyTables do you have installed?
On Tue, Apr 27, 2010 at 5:06 AM, Tingting HAN hihigh...@gmail.com wrote:
 I apologize that I am new to Linux. I find this in my computer:
 /usr/lib/python2.6/dist-packages/tables$
 How should I know which version of PyTables has been installed? What is the
 command?

Well, there are more generic ways depending on how you installed it,
but for this particular package:
python -c 'from tables.table import obversion; print obversion'

 Which version should I download to solve the problem?

Dunno exactly, but based on the dates, it was fixed before 2.1.2

 And could you please
 give me the website link to download it because I am afraid I can not find
 the right place exactly.

Might as well just go for the latest version:
http://www.pytables.org/download/preliminary/pytables-2.2b3/tables-2.2b3.tar.gz

Cheers,
Chris
--
http://blog.rebertia.com
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Python 2.5.x _winreg - rename a subkey

2010-04-27 Thread Tim Golden

On 27/04/2010 12:23, Richard Lamboj wrote:

is there a way to rename a subkey?


This is essentially a Windows question, since the _winreg module
is a lightweight wrapper around (some of) the MS Reg functions:

  http://msdn.microsoft.com/en-us/library/ms724875%28v=VS.85%29.aspx

And: no, there isn't a rename key function. Which isn't to say you
can't reproduce the effect by using SaveKey and LoadKey followed by
deleting the original key. The transactional functions which are
available from Vista onwards aren't exposed by Python altho' some
are available via the win32api module of the pywin32 packages:

  http://timgolden.me.uk/pywin32-docs/win32api.html

TJG
--
http://mail.python.org/mailman/listinfo/python-list


Re: dictionary

2010-04-27 Thread Roald de Vries

On Apr 26, 2010, at 8:04 PM, gopi krishna wrote:
When I give a dictionary with key and value in order how can get  
back  iy in same order


I use YAML a lot, which supports ordered dicts, and these are  
interpreted as lists of pairs by Python, so that might be a good choice.

--
http://mail.python.org/mailman/listinfo/python-list


Re: Engineering numerical format PEP discussion

2010-04-27 Thread Mark Dickinson
On Apr 27, 2:16 am, Keith keith.braff...@gmail.com wrote:
 On Apr 26, 8:47 pm, MRAB pyt...@mrabarnett.plus.com wrote:

  t for powers of a thousand, perhaps? (Or m?)

 Both of those letters are fine.  I kinda like m for the whole Greco-
 Roman angle, now that you point it out :-)

By the way, there's already a feature request open for this:

http://bugs.python.org/issue8060

That might be a good place to hash out the precise semantics.  If you
could provide unit tests and/or an implementation that would likely
help move the issue along.

Mark
-- 
http://mail.python.org/mailman/listinfo/python-list


Problems with extra blank line when using csv.writer in Python 3.1

2010-04-27 Thread tkp...@hotmail.com
I’m experiencing a problem with the csv module in Python 3.1.2, and
would greatly appreciate any help anyone can offer me. When writing
csv files in Python 2.6, I open the output file as 'wb' to prevent a
blank line being inserted after every line. Works like a charm. But I
get an error if I do the same in 3.1; i.e if type the following
sequence of commands:
 import csv
 outfile = open('c:/temp/test.csv', 'wb')
 writer = csv.writer(outfile)
 line = [1, 2, 3, 4]
 writer.writerow(line)
Traceback (most recent call last):
  File pyshell#26, line 1, in module
writer.writerow(line)
TypeError: must be bytes or buffer, not str


Switching to
 outfile = open('c:/temp/test.csv', 'w')

makes it work, but I now have a blank line after each line when I open
the file using Excel. Any thoughts or guidance on what I ought to be
doing in 3.1 to fix the extra blank line problem?

Thank you in advance

Thomas Philips
-- 
http://mail.python.org/mailman/listinfo/python-list


Pointers in Python

2010-04-27 Thread Anton Shishkov
Hi, I can't figure out how can I change the variable type in function.
In C I could do that easily by changing pointer.

Code:
def add(b):

b = {}
print type(b)

a = []
print type(a)
add(a)
print type(a)

Output:
type 'list'
type 'dict'
type 'list'
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Pointers in Python

2010-04-27 Thread Chris Rebert
On Tue, Apr 27, 2010 at 6:09 AM, Anton Shishkov
anton.shish...@gmail.com wrote:
 Hi, I can't figure out how can I change the variable type in function.
 In C I could do that easily by changing pointer.

 Code:
 def add(b):

    b = {}
    print type(b)

 a = []
 print type(a)
 add(a)
 print type(a)

 Output:
 type 'list'
 type 'dict'
 type 'list'

Python uses call-by-object
(http://effbot.org/zone/call-by-object.htm), so what you're trying to
do isn't possible.
One would normally just return the new object as a result instead.
If you have a more concrete example, someone might be able to suggest
a better approach.

Cheers,
Chris
--
http://blog.rebertia.com
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Pointers in Python

2010-04-27 Thread Laszlo Nagy



Hi, I can't figure out how can I change the variable type in function.
In C I could do that easily by changing pointer.
  
Please read about mutable and immutable objects in Python. If you 
understand the difference between them, you will get the idea. I'll 
explain program anyway, showing you need to think differently.

Code:
def add(b):

b = {}
  
Here you create a new dict objects, and rebind the local name 'b' to 
this newly created object.

print type(b)

a = []
  
Here you create a new list object, and bind the global name 'a' to this 
object.

print type(a)
add(a)
  
You call your function here, passing the list object you have previously 
created. The list object won't be changed (and in fact, won't be used at 
all).

print type(a)

  

Now, if try to rewrite your example like this:

def add(b):
b.append(10) # Call append() on b - change its state!

a = []
print a
add(a)
print a # Prints [10]


Look how the list object was changed.

If you use an immutable object, it is totally different:


def add(b):
b = b + 2

a = 10
print a
add(a)
print a # Prints 10


It is because inside the add() function, you do not CHANGE the state of the 
integer object. Instead of that, you create a new integer object, and rebind 
that to a local variable name. State of certain objects cannot be changed at 
all. They are called immutable. Integers, floats, strings are immutable. Other 
objects are mutable: lists, dicts etc.

This is a big difference between C and Python. In C, variable names are just pointers to memory locations. In Python, they are references to objects. 


I'm sure others will also answer your question...

Best,

  Laszlo


--
http://mail.python.org/mailman/listinfo/python-list


Re: Problems with extra blank line when using csv.writer in Python 3.1

2010-04-27 Thread Peter Otten
tkp...@hotmail.com wrote:

 I’m experiencing a problem with the csv module in Python 3.1.2, and
 would greatly appreciate any help anyone can offer me. When writing
 csv files in Python 2.6, I open the output file as 'wb' to prevent a
 blank line being inserted after every line. Works like a charm. But I
 get an error if I do the same in 3.1; i.e if type the following
 sequence of commands:
 import csv
 outfile = open('c:/temp/test.csv', 'wb')
 writer = csv.writer(outfile)
 line = [1, 2, 3, 4]
 writer.writerow(line)
 Traceback (most recent call last):
   File pyshell#26, line 1, in module
 writer.writerow(line)
 TypeError: must be bytes or buffer, not str
 
 
 Switching to
 outfile = open('c:/temp/test.csv', 'w')
 
 makes it work, but I now have a blank line after each line when I open
 the file using Excel. Any thoughts or guidance on what I ought to be
 doing in 3.1 to fix the extra blank line problem?

Untested, because I don't have Windows available, but try

outfile = open(filename, w,  newline=)

Peter
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Pointers in Python

2010-04-27 Thread Bruno Desthuilliers

Anton Shishkov a écrit :

Hi, I can't figure out how can I change the variable type in function.
In C I could do that easily by changing pointer.


(snip)

Others already answered on this. Now, the real question is : why to you 
want to do such a thing ?


Of one the most common use case for this idiom in C is to workaround the 
lack of multiple return values, so your function returns an error code 
*and* sets a value thru the pointer. This idiom makes no sense in 
Python since we have exception handling. FWIW, other use case are 
usually solved by tuple unpacking, ie:



def fun(a, b):
   return a+b, a*b

sum_, prod = fun(5, 4.5)


HTH
--
http://mail.python.org/mailman/listinfo/python-list


Re: running .py files on Linux

2010-04-27 Thread Tingting HAN
Well, another person in our lab solved it by using the command:
python2.5 configuration.py
I do not know exactly why python2.6 in my computer does not work. The code
packet I dowloaded was was made in 2007, so maybe old versions of python
should work.


2010/4/27 Chris Rebert creb...@ucsd.edu

  2010/4/27 Chris Rebert c...@rebertia.com
  On Tue, Apr 27, 2010 at 3:54 AM, Tingting HAN hihigh...@gmail.com
 wrote:
  snip
   gentest_empty.py
   Traceback (most recent call last):
 File gentest_empty.py, line 8, in module
   from tables import *
 File /usr/lib/python2.6/dist-packages/tables/__init__.py, line
 76,
   in
   module
   from tables.file import File, openFile, copyFile
 File /usr/lib/python2.6/dist-packages/tables/file.py, line 44, in
   module
   from tables import hdf5Extension
 File hdf5Extension.pyx, line 11, in hdf5Extension
   ImportError: No module named utilsExtension
  
  
  
   I attach two .py files from the downloaded package in this email.
 Could
   you please try running them and see what is the problem?
 
  Seems like your version of PyTables may be outdated. Your error looks
  similar to that described in this (fixed) bug:
  http://www.pytables.org/trac/ticket/183
 
  What version of PyTables do you have installed?
 On Tue, Apr 27, 2010 at 5:06 AM, Tingting HAN hihigh...@gmail.com wrote:
  I apologize that I am new to Linux. I find this in my computer:
  /usr/lib/python2.6/dist-packages/tables$
  How should I know which version of PyTables has been installed? What is
 the
  command?

 Well, there are more generic ways depending on how you installed it,
 but for this particular package:
 python -c 'from tables.table import obversion; print obversion'

  Which version should I download to solve the problem?

 Dunno exactly, but based on the dates, it was fixed before 2.1.2

  And could you please
  give me the website link to download it because I am afraid I can not
 find
  the right place exactly.

 Might as well just go for the latest version:

 http://www.pytables.org/download/preliminary/pytables-2.2b3/tables-2.2b3.tar.gz

 Cheers,
 Chris
 --
 http://blog.rebertia.com




-- 
Best regards,
HAN Tingting

ETSI de Telecomunicación - office C-203-1
Dpto. Ingeniería Electrónica
Ciudad Universitaria s/n
Madrid 28040,  Spain
TEL: +34 65 232 4340
Department of Photoelectric Information Engineering
Zhejiang University
Hangzhou 310027, P. R.China
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Python compiled modules are too big in size (even after strip)

2010-04-27 Thread King
Hi Jon,

I do have a limited skill sets in c/c++ and also new on linux. I think
I am missing some flags or anything when I am compiling python from
sources.

Still hoping that some one point me out the missing link.

Cheers

Prashant
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Engineering numerical format PEP discussion

2010-04-27 Thread cassiope
On Apr 25, 10:19 pm, Chris Rebert c...@rebertia.com wrote:
 On Sun, Apr 25, 2010 at 9:42 PM, Keith keith.braff...@gmail.com wrote:
  On Apr 26, 12:02 am, Chris Rebert c...@rebertia.com wrote:
  On Sun, Apr 25, 2010 at 8:36 PM, Keith keith.braff...@gmail.com wrote:
   I am considering writing a PEP for the inclusion of an engineering
   format specifier, and would appreciate input from others.
   snip
  Relevant related information:
  The Decimal datatype supports engineering format 
  directly:http://docs.python.org/library/decimal.html#decimal.Decimal.to_eng_st...

  Thanks for pointing that out.  Does the engineering community get by
  with the decimal module?

  Even though this uses the to_eng_string() function, and even though I
  am using the decimal.Context class:

  c = decimal.Context(prec=5)
  decimal.Decimal(1234567).to_eng_string(c)
  '1234567'

  That is not an engineering notation string.

 Apparently either you and the General Decimal Arithmetic spec differ
 on what constitutes engineering notation, there's a bug in the Python
 decimal library, or you're hitting some obscure part of the spec's
 definition. I don't have the expertise to know which is the case.

 The spec:http://speleotrove.com/decimal/decarith.pdf
 (to-engineering-string is on page 20 if you're interested)

 Cheers,
 Chris
 --http://blog.rebertia.com

As has been pointed out, the Decimal implementation may not have all
the features desired (i.e. forcing a particular exponent, or a
particular number of significant digits).  Perhaps it could be
enhanced.  The other concern is computational complexity - having to
perform complex engineering calculations in Decimal form is presumably
more burdensome than in floats.

What I've done for years is to have a function that converts an
arbitrary float into a string.  The function has an optional parameter
that specifies the number of digits of the output.
Isn't as automatic, of course, probably showing its C origins.

   -f
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: running .py files on Linux

2010-04-27 Thread Chris Rebert
 2010/4/27 Chris Rebert creb...@ucsd.edu
  2010/4/27 Chris Rebert c...@rebertia.com
  On Tue, Apr 27, 2010 at 3:54 AM, Tingting HAN hihigh...@gmail.com
  wrote:
  snip
   gentest_empty.py
   Traceback (most recent call last):
     File gentest_empty.py, line 8, in module
       from tables import *
     File /usr/lib/python2.6/dist-packages/tables/__init__.py, line
   76,
   in
   module
       from tables.file import File, openFile, copyFile
     File /usr/lib/python2.6/dist-packages/tables/file.py, line 44,
   in
   module
       from tables import hdf5Extension
     File hdf5Extension.pyx, line 11, in hdf5Extension
   ImportError: No module named utilsExtension
  
  
  
   I attach two .py files from the downloaded package in this email.
   Could
   you please try running them and see what is the problem?
 
  Seems like your version of PyTables may be outdated. Your error looks
  similar to that described in this (fixed) bug:
  http://www.pytables.org/trac/ticket/183
 
  What version of PyTables do you have installed?
 On Tue, Apr 27, 2010 at 5:06 AM, Tingting HAN hihigh...@gmail.com wrote:
  I apologize that I am new to Linux. I find this in my computer:
  /usr/lib/python2.6/dist-packages/tables$
  How should I know which version of PyTables has been installed? What is
  the
  command?

 Well, there are more generic ways depending on how you installed it,
 but for this particular package:
 python -c 'from tables.table import obversion; print obversion'

  Which version should I download to solve the problem?

 Dunno exactly, but based on the dates, it was fixed before 2.1.2

  And could you please
  give me the website link to download it because I am afraid I can not
  find
  the right place exactly.

 Might as well just go for the latest version:

 http://www.pytables.org/download/preliminary/pytables-2.2b3/tables-2.2b3.tar.gz

On Tue, Apr 27, 2010 at 8:12 AM, Tingting HAN hihigh...@gmail.com wrote:
 Well, another person in our lab solved it by using the command:
 python2.5 configuration.py
 I do not know exactly why python2.6 in my computer does not work. The code
 packet I dowloaded was was made in 2007, so maybe old versions of python
 should work.

That's unsurprising. As stated in the bug, the problem is related to a
language change that happened in Python 2.6; obviously using an older
version of Python would fix that, although you're stuck without the
other niceties of v2.6 over v2.5, and without whatever bug fixes have
been applied to PyTables since the version you're using.

At any rate, glad you got it working.

Cheers,
Chris
--
http://blog.rebertia.com
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Problems with extra blank line when using csv.writer in Python 3.1

2010-04-27 Thread tkp...@hotmail.com
Worked like a charm! Thank you very much.

-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Problems with extra blank line when using csv.writer in Python 3.1

2010-04-27 Thread Terry Reedy

On 4/27/2010 9:05 AM, tkp...@hotmail.com wrote:

I’m experiencing a problem with the csv module in Python 3.1.2, and
would greatly appreciate any help anyone can offer me. When writing
csv files in Python 2.6, I open the output file as 'wb' to prevent a
blank line being inserted after every line. Works like a charm. But I
get an error if I do the same in 3.1; i.e if type the following
sequence of commands:

import csv
outfile = open('c:/temp/test.csv', 'wb')
writer = csv.writer(outfile)
line = [1, 2, 3, 4]
writer.writerow(line)

Traceback (most recent call last):
   File pyshell#26, line 1, inmodule
 writer.writerow(line)
TypeError: must be bytes or buffer, not str


In 3.x, t vs b modes actually mean to read/write text (str (unicode)) vs 
binary (bytes, for instance) objects.



--
http://mail.python.org/mailman/listinfo/python-list


Re: Python 2.X vs. 3.X - level of acceptance?

2010-04-27 Thread Roger Binns
-BEGIN PGP SIGNED MESSAGE-
Hash: SHA1

On 04/27/2010 03:57 AM, Stephan Schulz wrote:
 Is Python 3 sucessful enough to make a switch worthwhile now? 

The language/interpreter is just fine.  The biggest problem is 3rd party
modules.  My own module (APSW) has been available since the early betas of
Python 3 and I make it available for Python 2.3 onwards.

I have a release every month or two, and so you can see adoption trends for
Windows users over time:

  http://code.google.com/p/apsw/downloads/list?can=1q=binary

Python 2.6 is by far the most popular, but 3.1 is picking up.  It is
disturbing just many 2.3 users there still are though.

Roger
-BEGIN PGP SIGNATURE-
Version: GnuPG v1.4.10 (GNU/Linux)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org/

iEYEARECAAYFAkvXFTUACgkQmOOfHg372QR7YwCgpZdsgkV9iBy/1/8eIBwxy3S4
Sy8AoI8vsivExNADG9Bmx+WbWTQN74VD
=0lxT
-END PGP SIGNATURE-

-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Download Visual Studio Express 2008 now

2010-04-27 Thread TerryP
I've generally found it wise to grab the ISO images for the express
editions collection, and save it somewhere in cold storage.

Never have needed to compile Python on Windows, but some modules only
support older versions (e.g. 2.4 or 2.5), which is irksome. So it's a
good idea to have stuff setup for building extension modules by hand.
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Engineering numerical format PEP discussion

2010-04-27 Thread Keith
On Apr 27, 9:03 am, Mark Dickinson dicki...@gmail.com wrote:
 On Apr 27, 2:16 am, Keith keith.braff...@gmail.com wrote:

  On Apr 26, 8:47 pm, MRAB pyt...@mrabarnett.plus.com wrote:

   t for powers of a thousand, perhaps? (Or m?)

  Both of those letters are fine.  I kinda like m for the whole Greco-
  Roman angle, now that you point it out :-)

 By the way, there's already a feature request open for this:

 http://bugs.python.org/issue8060

 That might be a good place to hash out the precise semantics.  If you
 could provide unit tests and/or an implementation that would likely
 help move the issue along.

 Mark

Oh nice!  I don't know how I missed that.

--Keith Brafford
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Download Visual Studio Express 2008 now

2010-04-27 Thread Paul Rudin
Martin v. Loewis mar...@v.loewis.de writes:

 Microsoft has just released Visual Studio 2010, along with its free (of
 charge) Express edition. Following a tradition, they are likely to
 withdraw support and availability for VS 2008 Express some time in the
 future.

 Python 2.6, 2.7, and 3.1 are all built with that release (i.e. 2008).
 Because of another long tradition, Python extension modules must be
 built with the same compiler version (more specifically, CRT version) as
 Python itself. So to build extension modules for any of these releases,
 you need to have a copy of VS 2008 or VS 2008 Express.

 If you are planning to build Python extension modules in the next five
 years, I recommend that you obtain a copy of VS Express, just in case
 Microsoft removes it from their servers. As mentioned, it's free of
 charge. When downloading it for later use, it's probably best to get the
 offline ISO image release, available from

 http://www.microsoft.com/express/Downloads/#2008-All

 Disclaimer: I'm not connected with Microsoft or its release process. Any
 claim on future actions that Microsoft may take is purely hypothetical.


I'm curious to know exactly the differences between the c/c++ compilers
you get with various versions of VS and those you get with the (command
line only) Windows SDK (formerly called the platform SDK). 

The windows sdk is a free download. Is the compiler you get the same as
the one you get with the full paid version of VS?  This web page seems
to suggest it might be
http://msdn.microsoft.com/en-us/windows/bb980924.aspx
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Detect OS shutdown or user logout across different operating systems

2010-04-27 Thread python
Hi Tim,

 Doubt v. much if there's anything x-platform. I recently wrote-up
 the work done my Klaas Tjebbes (sp?) which I think will do what
 you want:

http://timgolden.me.uk/python/win32_how_do_i/track-session-events.html

Looks good - I'll study this code. Thanks for the help!

Cheers,
Malcolm
-- 
http://mail.python.org/mailman/listinfo/python-list


Oddity with large dictionary (several million entries)

2010-04-27 Thread Lothar Werzinger
Hi,

I am trying to load files into a dictionary for analysis. the size of the 
dictionary will grow quite large (several million entries) and as inserting 
into a dictionary is roughly O(n) I figured if I loaded each file into it's 
own dictionary it would speed things up. However it did not.

So I decided to write a small test program (attached)

As you can see I am inserting one million entries a time into a map. I ran 
the tests where I put all three million entries into one map and one where I 
put one million each into it's own map.

What I would have expected is that if I insert one million into it's own map 
the time to do that would be roughly constant for each map. Interestingly it 
is not. It's about the same as if I load everything into one map.

Oh and I have 4G of RAM and the test consumes about 40% at it's max. I even 
run the test on one of our servers with 64G of RAM, so I can rule out 
swapping as the issue.

Can anyone explain this oddity? Any insight is highly appreciated.

Here's the output of the test runs:

$ ./dicttest.py -t 0
Inserting into one map
Inserting 100 keys lasted 0:00:26 (38019 1/s)
len(map) 100
Inserting 100 keys lasted 0:01:17 (12831 1/s)
len(map) 200
Inserting 100 keys lasted 0:02:23 (6972 1/s)
len(map) 300
total 300

$ ./dicttest.py -t 1
Inserting into three maps
Inserting 100 keys lasted 0:00:32 (30726 1/s)
len(map) 100
Inserting 100 keys lasted 0:01:29 (11181 1/s)
len(map) 100
Inserting 100 keys lasted 0:02:23 (6957 1/s)
len(map) 100
total 300


Thanks,
Lothar

,[ /home/lothar/tmp/dicttest.py ]
| #!/usr/bin/python
| # -*- coding: utf-8 -*-
| 
| import datetime
| import optparse
| import sys
| import time
| 
| 
| 
| 
| def fillDict(map, nop, num, guid):
|   before = time.time()
|   
|   for i in xrange(0, num):
| key = (i, guid)
| if not nop:
|   map[key] = ([], {})
|   
|   after = time.time()
|   elapsed = (after - before)
|   if elapsed = 0:
| divide = 1.0
|   else:
| divide = elapsed
|   elapsedTime = datetime.timedelta(seconds=int(elapsed))
|   print(Inserting %d keys lasted %s (%d 1/s) % (num, elapsedTime, (num /
|   divide))) print(len(map) %d % (len(map)))
| 
| 
| def test0(nop, num):
|   print(Inserting into one map)
|   map = {}
|   fillDict(map, nop, num, 0561c83c-9675-4e6f-bedc-86bcb6acfd71)
|   fillDict(map, nop, num, 0561c83c-9675-4e6f-bedc-86bcb6acfd72)
|   fillDict(map, nop, num, 0561c83c-9675-4e6f-bedc-86bcb6acfd73)
|   print(total %d % (len(map)))
| 
| 
| def test1(nop, num):
|   print(Inserting into three maps)
|   map1 = {}
|   map2 = {}
|   map3 = {}
|   fillDict(map1, nop, num, 0561c83c-9675-4e6f-bedc-86bcb6acfd71)
|   fillDict(map2, nop, num, 0561c83c-9675-4e6f-bedc-86bcb6acfd72)
|   fillDict(map3, nop, num, 0561c83c-9675-4e6f-bedc-86bcb6acfd73)
|   total = 0
|   for map in [map1, map2, map3]:
| total += len(map)
|   print(total %d % (total))
| 
| 
| 
| if __name__ == __main__:
|   usage = USAGE: %prog [options]
|   description=test
|   version=%prog 1.0
|   
|   parser = optparse.OptionParser(usage=usage, version=version,
|   description=description) parser.add_option(
| -t,
| --testnum,
| action=store,
| dest=testnum,
| help=the number of the test to execute,
| type=int,
| default=1
|   )
|   parser.add_option(
| -i,
| --iterations,
| action=store,
| dest=iterations,
| help=the number of iterations,
| type=int,
| default=100
|   )
|   parser.add_option(
| -n,
| --nop,
| action=store_true,
| dest=nop,
| help=don't store in the dictionary only load and parse,
| default=False
|   )
| 
|   (options, args) = parser.parse_args()
|   
|   testmap = {
| 0:test0,
| 1:test1,
|   }
| 
|   test = testmap[options.testnum]
| 
|   test(options.nop, options.iterations)
`
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Oddity with large dictionary (several million entries)

2010-04-27 Thread MRAB

Lothar Werzinger wrote:

Hi,

I am trying to load files into a dictionary for analysis. the size of the 
dictionary will grow quite large (several million entries) and as inserting 
into a dictionary is roughly O(n) I figured if I loaded each file into it's 
own dictionary it would speed things up. However it did not.


So I decided to write a small test program (attached)

As you can see I am inserting one million entries a time into a map. I ran 
the tests where I put all three million entries into one map and one where I 
put one million each into it's own map.


What I would have expected is that if I insert one million into it's own map 
the time to do that would be roughly constant for each map. Interestingly it 
is not. It's about the same as if I load everything into one map.


Oh and I have 4G of RAM and the test consumes about 40% at it's max. I even 
run the test on one of our servers with 64G of RAM, so I can rule out 
swapping as the issue.


Can anyone explain this oddity? Any insight is highly appreciated.

Here's the output of the test runs:

$ ./dicttest.py -t 0
Inserting into one map
Inserting 100 keys lasted 0:00:26 (38019 1/s)
len(map) 100
Inserting 100 keys lasted 0:01:17 (12831 1/s)
len(map) 200
Inserting 100 keys lasted 0:02:23 (6972 1/s)
len(map) 300
total 300

$ ./dicttest.py -t 1
Inserting into three maps
Inserting 100 keys lasted 0:00:32 (30726 1/s)
len(map) 100
Inserting 100 keys lasted 0:01:29 (11181 1/s)
len(map) 100
Inserting 100 keys lasted 0:02:23 (6957 1/s)
len(map) 100
total 300


[snip]
Inserting into a Python dict is O(1).
--
http://mail.python.org/mailman/listinfo/python-list


Re: Oddity with large dictionary (several million entries)

2010-04-27 Thread Peter Otten
Lothar Werzinger wrote:

 I am trying to load files into a dictionary for analysis. the size of the
 dictionary will grow quite large (several million entries) and as
 inserting into a dictionary is roughly O(n) I figured if I loaded each
 file into it's own dictionary it would speed things up. However it did
 not.
 
 So I decided to write a small test program (attached)
 
 As you can see I am inserting one million entries a time into a map. I ran
 the tests where I put all three million entries into one map and one where
 I put one million each into it's own map.
 
 What I would have expected is that if I insert one million into it's own
 map the time to do that would be roughly constant for each map.
 Interestingly it is not. It's about the same as if I load everything into
 one map.
 
 Oh and I have 4G of RAM and the test consumes about 40% at it's max. I
 even run the test on one of our servers with 64G of RAM, so I can rule out
 swapping as the issue.
 
 Can anyone explain this oddity? Any insight is highly appreciated.

When you are creating objects like there is no tomorrow Python's cyclic 
garbage collections often takes a significant amount of time. The first 
thing I'd try is therefore switching it off with

import gc
gc.disable()

Peter


-- 
http://mail.python.org/mailman/listinfo/python-list


ANN: Intro+Intermediate Python course, SF, May 10-12

2010-04-27 Thread wesley chun
*** FINAL REMINDER ***

Need to get up-to-speed with Python as quickly as possible? Come join
me, Wesley Chun, author of Prentice-Hall's bestseller Core Python
Programming, for a comprehensive Python course coming up this May in
beautiful Northern California! I welcome new Python programmers as
well as veterans who may have run into bugs that are difficult to
explain and/or who want to learn more about objects, references, and
Python's memory model. Come join us if you're looking for *more* than
just a vanilla beginners class.

Please pass on this note to whomever you think may be interested. I
look forward to meeting you and your colleagues! feel free to pass
around the flyer below.

(Comprehensive) Introduction to Python
Mon-Wed, 2010 May 10-12, 9am-5pm

- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
(COMPREHENSIVE) INTRO+INTERMEDIATE PYTHON

Although this course may appear to those new to Python, it is also
perfect for those who have tinkered with it and want to fill in the
gaps and/or want to get more in-depth formal training.  It combines
the best of both an introduction to the language as well as a Python
Internals training course.

We will immerse you in the world of Python in only a few days, showing
you more than just its syntax (which you don't really need a book to
learn, right?). Knowing more about how Python works under the covers,
including the relationship between data objects and memory management,
will make you a much more effective Python programmer coming out of
the gate. 3 hands-on labs each day will help hammer the concepts home.

Come find out why Google, Yahoo!, Disney, ILM/LucasFilm, VMware,
NASA, Ubuntu, YouTube, and Red Hat all use Python. Users supporting
or jumping to Plone, Zope, TurboGears, Pylons, Django, Google App
Engine, Jython, IronPython, and Mailman will also benefit!

PREVIEW 1: you will find (and can download) a video clip of a
class session recorded live to get an idea of my lecture style and
the interactive classroom environment at:

http://cyberwebconsulting.com

PREVIEW 2: Partnering with O'Reilly and Pearson, Safari Books
Online has asked me to deliver a 1-hour webcast last Spring called
What is Python?. This was an online seminar based on a session
that I've delivered at numerous conferences in the past. It will give
you an idea of lecture style as well as an overview of the material
covered in the course.

info:http://www.safaribooksonline.com/events/WhatIsPython.html
download (reg req'd):
http://www.safaribooksonline.com/Corporate/DownloadAndResources/webcastInfo.php?page=WhatIsPython
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -

WHERE: near the San Francisco Airport (SFO/San Bruno), CA, USA

WEB:   http://cyberwebconsulting.com

FLYER: http://starship.python.net/crew/wesc/flyerPP1may10.pdf

LOCALS: easy freeway (101/280/380) with lots of parking plus public
transit (BART and CalTrain) access via the San Bruno stations, easily
accessible from all parts of the Bay Area

VISITORS: free shuttle to/from the airport, free high-speed internet,
free breakfast and regular evening receptions; fully-equipped suites

See website for costs, venue info, and registration.

Hope to see you there!
-- wesley

- - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
Python Web Development with Django, Addison Wesley, (c) 2009
http://withdjango.com

wesley.j.chun :: wescpy-at-gmail.com
python training and technical consulting
cyberweb.consulting : silicon valley, ca
http://cyberwebconsulting.com
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Python compiled modules are too big in size (even after strip)

2010-04-27 Thread Antoine Pitrou
Le Tue, 27 Apr 2010 02:43:19 -0700, King a écrit :
 
 Python is compiled and installed successfully. However the
 modules(_socket.so, _random.so etc) are two big in terms of file size.
 They are around 4.5-5.0 mb each. I have used strip strip-all *.so, but
 still size is around 1.5 mb each.

This is way more than it should be. Even if debug mode, most extension 
modules should be around 100kB or smaller.

 Am I missing something here? Do I have to re-configure or re-compile the
 python again from sources?

I would suggest to check the compile options gcc gets (look at make 
output), and try changing them.


-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Oddity with large dictionary (several million entries)

2010-04-27 Thread Lothar Werzinger
Peter Otten wrote:

 Lothar Werzinger wrote:
 Can anyone explain this oddity? Any insight is highly appreciated.
 
 When you are creating objects like there is no tomorrow Python's cyclic
 garbage collections often takes a significant amount of time. The first
 thing I'd try is therefore switching it off with
 
 import gc
 gc.disable()
 
 Peter

Wow, that really MAKES a difference! Thanks a lot!

$ ~/tmp/dicttest.py -t 0
Inserting into one map
Inserting 100 keys lasted 0:00:01 (960152 1/s)
len(map) 100
Inserting 100 keys lasted 0:00:01 (846416 1/s)
len(map) 200
Inserting 100 keys lasted 0:00:04 (235241 1/s)
len(map) 300
total 300

$ ~/tmp/dicttest.py -t 1
Inserting into three maps
Inserting 100 keys lasted 0:00:01 (973344 1/s)
len(map) 100
Inserting 100 keys lasted 0:00:00 (1011303 1/s)
len(map) 100
Inserting 100 keys lasted 0:00:00 (1021796 1/s)
len(map) 100
total 300
~/beacon


Thanks!
-- 
Lothar
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: pyjamas 0.7 released

2010-04-27 Thread lkcl
On Apr 26, 11:25 pm, Patrick Maupin pmau...@gmail.com wrote:
 On Apr 26, 4:12 pm, lkcl luke.leigh...@googlemail.com wrote:

   and, given that you can use AJAX (e.g. JSONRPC) to communicate with a
  server-side component, installed on 127.0.0.1 and effectively do the
  exact same thing, nobody bothers.

 I suppose, but again, that pushes off the security thing.  There are a
 lot of obvious ways to make unintended security holes in a 127.0.0.1
 application,

 not to an experienced web developer.  by starting the browser at a
URL which can only used once, you can effectively do the same trick
that X-Server X-Auth magic cookies does.

 so I'm sure there are also a lot of ways that would be
 unobvious to this security non-expert.  And, of course, the real
 dealbreaker is, it still requires a separate install.

 not necessarily.  luis pamirez created pygtkweb (a reimplementation
of gtk widgets, to be compiled to javascript, to run in a web browser)
and he created it as a stand-alone app that 1) fired off a web browser
2) ran a small cgi-bin-esque web service 3) served static (pre-
compiled) pages 4) served AJAX to the compiled app.

 with pyjd, that step 1 can be bypassed or more specifically step 1
and 2 can be combined into the _one_ python app (two threads /
processes); you effectively combine the start the window with the
browser engine in it step with the start a mini web server step.

 so it can be done: it's just not immediately obvious.

 l.
-- 
http://mail.python.org/mailman/listinfo/python-list


How to check what is holding reference to object

2010-04-27 Thread Michal M
Hi

I've just found out that one of objects is not destroyed when it
should be. This means that something was holding reference to this
object or part of it (i.e. method). Is there any way to check what
holds that reference? I am unable to do that just looking to the code
or debugging it because it is pretty complicated, but I am able to
invoke this situation again.

Regards
Michal M.
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: How to check what is holding reference to object

2010-04-27 Thread Xavier Ho
Michal,

May I ask why do you care about the object's management? Let Python worry
about that. What's your use case?
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: How to check what is holding reference to object

2010-04-27 Thread Almar Klein
 I've just found out that one of objects is not destroyed when it
 should be. This means that something was holding reference to this
 object or part of it (i.e. method). Is there any way to check what
 holds that reference? I am unable to do that just looking to the code
 or debugging it because it is pretty complicated, but I am able to
 invoke this situation again.


I don't think that's possible, since that would mean Python would need to
keep a reference to the object holding the reference, which seems pretty
awkward.

You can however, obtain the number of referencing objects using
sys.getrefcount(object). You have to subtract 1 from the result, as the
function itself of course holds a reference to at the moment it is being
called.

  Almar
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: How to check what is holding reference to object

2010-04-27 Thread Chris Rebert
On Tue, Apr 27, 2010 at 1:45 PM, Michal M mich.mier...@googlemail.com wrote:
 I've just found out that one of objects is not destroyed when it
 should be. This means that something was holding reference to this
 object or part of it (i.e. method). Is there any way to check what
 holds that reference? I am unable to do that just looking to the code
 or debugging it because it is pretty complicated, but I am able to
 invoke this situation again.

gc.get_referrers(your_object) ?

Docs: http://docs.python.org/library/gc.html#gc.get_referrers

Cheers,
Chris
--
Thanks for having me learn something new today!
http://blog.rebertia.com
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: How to check what is holding reference to object

2010-04-27 Thread Duncan Booth
Michal M mich.mier...@googlemail.com wrote:

 Hi
 
 I've just found out that one of objects is not destroyed when it
 should be. This means that something was holding reference to this
 object or part of it (i.e. method). Is there any way to check what
 holds that reference? I am unable to do that just looking to the code
 or debugging it because it is pretty complicated, but I am able to
 invoke this situation again.
 
See if this code helps:

http://groups.google.com/group/comp.lang.python/browse_thread/thread/394ba5b48f83ebfb/237dc92f3629dd9a#237dc92f3629dd9a

It's pretty old so it may need some adjustment, but I wrote it
to figure out exactly that sort of problem.
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: How to check what is holding reference to object

2010-04-27 Thread Michal M
On 27 Kwi, 23:21, Duncan Booth duncan.bo...@invalid.invalid wrote:
 Michal M mich.mier...@googlemail.com wrote:
  Hi

  I've just found out that one of objects is not destroyed when it
  should be. This means that something was holding reference to this
  object or part of it (i.e. method). Is there any way to check what
  holds that reference? I am unable to do that just looking to the code
  or debugging it because it is pretty complicated, but I am able to
  invoke this situation again.

 See if this code helps:

 http://groups.google.com/group/comp.lang.python/browse_thread/thread/...

 It's pretty old so it may need some adjustment, but I wrote it
 to figure out exactly that sort of problem.

Thanks you for answers.
I tried to use gc.get_referrers(self) in point in code when according
to me object should be destroyed earlier but I did not see anything
interesting. Then just realised that gc will not destroy object even
when itself holds reference to his own method.

For example

class A(object):
  def a(self):
pass
  def b(self):
self.method = self.a
  def __del__(self):
print A object deleted

 a = A()
 del a
A object delted
 a = A()
 a.b()
 del a
... nothing ...

I thought gc would discover such circle loops but apparently it did
not.
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: How to check what is holding reference to object

2010-04-27 Thread Chris Rebert
On Tue, Apr 27, 2010 at 2:42 PM, Michal M mich.mier...@googlemail.com wrote:
 On 27 Kwi, 23:21, Duncan Booth duncan.bo...@invalid.invalid wrote:
 Michal M mich.mier...@googlemail.com wrote:
  I've just found out that one of objects is not destroyed when it
  should be. This means that something was holding reference to this
  object or part of it (i.e. method). Is there any way to check what
  holds that reference? I am unable to do that just looking to the code
  or debugging it because it is pretty complicated, but I am able to
  invoke this situation again.

 See if this code helps:

 http://groups.google.com/group/comp.lang.python/browse_thread/thread/...

 It's pretty old so it may need some adjustment, but I wrote it
 to figure out exactly that sort of problem.

 Thanks you for answers.
 I tried to use gc.get_referrers(self) in point in code when according
 to me object should be destroyed earlier but I did not see anything
 interesting. Then just realised that gc will not destroy object even
 when itself holds reference to his own method.

 For example

 class A(object):
  def a(self):
    pass
  def b(self):
    self.method = self.a
  def __del__(self):
    print A object deleted

 a = A()
 del a
 A object delted
 a = A()
 a.b()
 del a
 ... nothing ...

 I thought gc would discover such circle loops but apparently it did
 not.

No, it does, you just didn't give it long enough; for performance
reasons, cyclical GC is only done every so often:

 from weakref import ref
 class A(object):
...  def a(self):
...pass
...  def b(self):
...self.method = self.a
...
 a = A()
 def bye(x): print BYE:, x
...
 b = ref(a, bye)
 del a
BYE: weakref at 0x377990; dead
 a = A()
 b = ref(a, bye)
 a.b()
 del a

 #indeed, it didn't get GC-ed immediately
 from gc import collect
 collect() #but if we force a cyclical GC run...
BYE: weakref at 0x4441b0; dead

Cheers,
Chris
--
http://blog.rebertia.com
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: How to check what is holding reference to object

2010-04-27 Thread Chris Rebert
On Tue, Apr 27, 2010 at 2:58 PM, Chris Rebert c...@rebertia.com wrote:
 On Tue, Apr 27, 2010 at 2:42 PM, Michal M mich.mier...@googlemail.com wrote:
 On 27 Kwi, 23:21, Duncan Booth duncan.bo...@invalid.invalid wrote:
 Michal M mich.mier...@googlemail.com wrote:
  I've just found out that one of objects is not destroyed when it
  should be. This means that something was holding reference to this
  object or part of it (i.e. method). Is there any way to check what
  holds that reference? I am unable to do that just looking to the code
  or debugging it because it is pretty complicated, but I am able to
  invoke this situation again.

 See if this code helps:

 http://groups.google.com/group/comp.lang.python/browse_thread/thread/...

 It's pretty old so it may need some adjustment, but I wrote it
 to figure out exactly that sort of problem.

 Thanks you for answers.
 I tried to use gc.get_referrers(self) in point in code when according
 to me object should be destroyed earlier but I did not see anything
 interesting. Then just realised that gc will not destroy object even
 when itself holds reference to his own method.

 For example

 class A(object):
  def a(self):
    pass
  def b(self):
    self.method = self.a
  def __del__(self):
    print A object deleted

 a = A()
 del a
 A object delted
 a = A()
 a.b()
 del a
 ... nothing ...

 I thought gc would discover such circle loops but apparently it did
 not.

 No, it does, you just didn't give it long enough; for performance
 reasons, cyclical GC is only done every so often:

Addendum:
Also, defining __del__ in your example was likely problematic:
See http://docs.python.org/library/gc.html#gc.garbage

- Chris
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Cross-platform way to retrieve the current (Operative system) DNS server IP address in python

2010-04-27 Thread joamag
On 24 Abr, 14:50, DarkBlue pict...@gmail.com wrote:
 On Apr 22, 4:55 pm, joamag joa...@gmail.com wrote:

  Does anybody know a cross platform way to retrieve the default DNS
  server IP address in python ?

  Thanks !
  João

 import os,urllib2,re

 def getIpAddr():
     
     Function for parsing external ip adress by pinging dyndns.com
     
     External_IP=urllib2.urlopen('http://checkip.dyndns.com/').read()
     m = re.search(r(([0-9]+\.){3}[0-9]+), External_IP)
     my_IP= m.group(1)
     return my_IP

 print('Current Ip from DynDns :  %s ') % getIpAddr()

 this gets you your ip address

 hope it helps.

Hi,

It's not my ip address that I want to discover... I want to discover
my default dns server ip address.
This ip is stored in an operative system basis.

Dos anyone know how to get it ?
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Download Visual Studio Express 2008 now

2010-04-27 Thread Martin v. Loewis
 I'm curious to know exactly the differences between the c/c++ compilers
 you get with various versions of VS and those you get with the (command
 line only) Windows SDK (formerly called the platform SDK). 
 
 The windows sdk is a free download. Is the compiler you get the same as
 the one you get with the full paid version of VS?  This web page seems
 to suggest it might be
 http://msdn.microsoft.com/en-us/windows/bb980924.aspx

The primary difference is the CRT version that it ships with. Also,
one difference is whether it ships with a compiler at all. For a long
time, the SDK didn't include a compiler at all. Then, for several years,
 it included an Itanium compiler and an AMD64 compiler, but no x86
compiler. Now it does, and I don't know what CRT version it links with
(at some point, the SDK would link with crtdll.dll, then msvcrt.dll,
but it's some other version now).

In any case, AFAIK, the SDK binaries will be linked with one specific
version of the CRT, which may or may not be the same as the one used in
one specific version of Visual Studio.

HTH,
Martin
-- 
http://mail.python.org/mailman/listinfo/python-list


How to use a class property to store function variables?

2010-04-27 Thread GZ
I want to store a reference to a function into a class property.

So I am expecting that:

class A:
 fn = lambda x: x

fn = A.fn
fn(1)

Traceback (most recent call last):
  File string, line 1, in string
TypeError: unbound method lambda() must be called with A instance as
first argument (got int instance instead)


The problem is that A.fn is treated as a bounded method. I really want
A.fn to be a variable that stores a reference to a function. Is there
any way to achieve this?

Thanks,
GZ
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: How to use a class property to store function variables?

2010-04-27 Thread Chris Rebert
On Tue, Apr 27, 2010 at 4:36 PM, GZ zyzhu2...@gmail.com wrote:
 I want to store a reference to a function into a class property.

 So I am expecting that:

 class A:
     fn = lambda x: x

 fn = A.fn
 fn(1)

 Traceback (most recent call last):
  File string, line 1, in string
 TypeError: unbound method lambda() must be called with A instance as
 first argument (got int instance instead)


 The problem is that A.fn is treated as a bounded method. I really want
 A.fn to be a variable that stores a reference to a function. Is there
 any way to achieve this?

Use the staticmethod() decorator:

class A(object):
@staticmethod
def fn(x):
return x

#rest same as before

Cheers,
Chris
--
http://blog.rebertia.com
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Cross-platform way to retrieve the current (Operative system) DNS server IP address in python

2010-04-27 Thread Tiago Katcipis
maybe this helps you:

http://pypi.python.org/pypi/netifaces/0.3

best regards,
Katcipis

On Tue, Apr 27, 2010 at 7:49 PM, joamag joa...@gmail.com wrote:

 On 24 Abr, 14:50, DarkBlue pict...@gmail.com wrote:
  On Apr 22, 4:55 pm, joamag joa...@gmail.com wrote:
 
   Does anybody know a cross platform way to retrieve the default DNS
   server IP address in python ?
 
   Thanks !
   João
 
  import os,urllib2,re
 
  def getIpAddr():
  
  Function for parsing external ip adress by pinging dyndns.com
  
  
  External_IP=urllib2.urlopen('http://checkip.dyndns.com/').read(http://checkip.dyndns.com/%27%29.read%28
 )
  m = re.search(r(([0-9]+\.){3}[0-9]+), External_IP)
  my_IP= m.group(1)
  return my_IP
 
  print('Current Ip from DynDns :  %s ') % getIpAddr()
 
  this gets you your ip address
 
  hope it helps.

 Hi,

 It's not my ip address that I want to discover... I want to discover
 my default dns server ip address.
 This ip is stored in an operative system basis.

 Dos anyone know how to get it ?
 --
 http://mail.python.org/mailman/listinfo/python-list

-- 
http://mail.python.org/mailman/listinfo/python-list


PyCon Australia CFP: One Day Left!

2010-04-27 Thread Richard Jones
The Call For Proposals for PyCon Australia 2010 FINISHES TOMORROW!

Presentation subjects may range from reports on open source,
academic and commercial projects to tutorials and case studies.
As long as a presentation is interesting and potentially useful
to the Python community, it will be considered for inclusion in
the program.

We're especially interested in short presentations that will teach
conference-goers something new and useful. Can you show attendees
how to use a module? Explore a Python language feature? Package
an application?

Submit your proposal here: http://pycon-au.org/cfp

As always, please pass this message on to people you feel will find it
interesting.


Richard Jones
PyCon Australia 2010
http://pycon-au.org/
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: How to use a class property to store function variables?

2010-04-27 Thread Terry Reedy

On 4/27/2010 7:36 PM, GZ wrote:

I want to store a reference to a function into a class property.

So I am expecting that:

class A:
  fn = lambda x: x

fn = A.fn
fn(1)

Traceback (most recent call last):
   File string, line 1, instring
TypeError: unbound methodlambda() must be called with A instance as
first argument (got int instance instead)


The problem is that A.fn is treated as a bounded method. I really want
A.fn to be a variable that stores a reference to a function. Is there
any way to achieve this?


Use 3.1, though you will have the same issue when calling it and same 
fix that Chris gave.


Terry Jan Reedy



--
http://mail.python.org/mailman/listinfo/python-list


Re: Oddity with large dictionary (several million entries)

2010-04-27 Thread Benjamin Peterson
Lothar Werzinger lothar at tradescape.biz writes:
 Wow, that really MAKES a difference! Thanks a lot!

You should also try Python 2.7 or 3.1. We've recently optimized the garabage
collector for situations where many objects are being created.




-- 
http://mail.python.org/mailman/listinfo/python-list


Re: How to use a class property to store function variables?

2010-04-27 Thread GZ
Hi Chris,

On Apr 27, 6:43 pm, Chris Rebert c...@rebertia.com wrote:
 On Tue, Apr 27, 2010 at 4:36 PM, GZ zyzhu2...@gmail.com wrote:
  I want to store a reference to a function into a class property.

  So I am expecting that:

  class A:
      fn = lambda x: x

  fn = A.fn
  fn(1)

  Traceback (most recent call last):
   File string, line 1, in string
  TypeError: unbound method lambda() must be called with A instance as
  first argument (got int instance instead)

  The problem is that A.fn is treated as a bounded method. I really want
  A.fn to be a variable that stores a reference to a function. Is there
  any way to achieve this?

 Use the staticmethod() decorator:

 class A(object):
     @staticmethod
     def fn(x):
         return x

 #rest same as before

 Cheers,
 Chris
 --http://blog.rebertia.com- Hide quoted text -

 - Show quoted text -

I do not think it will help me. I am not trying to define a function
fn() in the class, but rather I want to make it a function reference
so that I can initialize it any way I like later.

For example, I want to be able to write the following:

A.fn = lambda x : x*x
f = A.fn
f(1)
A.fn = lambda x : x^2
f= A.fn
f(2)

In other words, I want to make A.fn a reference to a function not
known to me at the time I define class A. I want to be able to
initialize it later.


-- 
http://mail.python.org/mailman/listinfo/python-list


Ignoring XML Namespaces with cElementTree

2010-04-27 Thread dmtr
Is there any way to configure cElementTree to ignore the XML root
namespace?  Default cElementTree (Python 2.6.4) appears to add the XML
root namespace URI to _every_ single tag.  I know that I can strip
URIs manually, from every tag, but it is a rather idiotic thing to do
(performance wise).
-- 
http://mail.python.org/mailman/listinfo/python-list


Simple game like graphics

2010-04-27 Thread Vincent Davis
I am working on a simulation of a bicycle race. I would like a very simple
real time graphic of the position of the bicycles during the simulation and
a few of the key values. I will not be iterating with the simulation while
it is running.

I am not really sure where to start. Currently to watch the values of the
variables I just print them at intervals.

I know there are many option to do this. For me, I would like the option
that would be quick, easy and few lines of code. I am not sure of a better
way to describe my requirements.
Any suggestions would be great especially if you have a
tutorial/documentation you would recommend.

Thanks

*Vincent Davis
720-301-3003 *
vinc...@vincentdavis.net
 my blog http://vincentdavis.net |
LinkedInhttp://www.linkedin.com/in/vincentdavis
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: How to use a class property to store function variables?

2010-04-27 Thread MRAB

Terry Reedy wrote:

On 4/27/2010 7:36 PM, GZ wrote:

I want to store a reference to a function into a class property.

So I am expecting that:

class A:
  fn = lambda x: x

fn = A.fn
fn(1)

Traceback (most recent call last):
   File string, line 1, instring
TypeError: unbound methodlambda() must be called with A instance as
first argument (got int instance instead)


The problem is that A.fn is treated as a bounded method. I really want
A.fn to be a variable that stores a reference to a function. Is there
any way to achieve this?


Use 3.1, though you will have the same issue when calling it and same 
fix that Chris gave.


Python 3.1.1 (r311:74483, Aug 17 2009, 17:02:12) [MSC v.1500 32 bit 
(Intel)] on win32

Type copyright, credits or license() for more information.
 class A:
fn = lambda x: x


 fn = A.fn
 fn(1)
1
--
http://mail.python.org/mailman/listinfo/python-list


assigning multi-line strings to variables

2010-04-27 Thread goldtech
Hi,

This is undoubtedly a newbie question. How doI assign variables
multiline strings? If I try this i get what's cited below. Thanks.


 d=d
d
 d
Traceback (most recent call last):
  File interactive input, line 1, in module
NameError: name 'd' is not defined
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: How to use a class property to store function variables?

2010-04-27 Thread alex23
GZ zyzhu2...@gmail.com wrote:
 I do not think it will help me. I am not trying to define a function
 fn() in the class, but rather I want to make it a function reference
 so that I can initialize it any way I like later.

It always helps to try an idea out before dismissing it out of hand.
Experimentation in the interpreter is cheap and easy.

 class A(object):
...   fn = staticmethod(lambda x: x*x)
...
 A.fn(10)
100
 A.fn = staticmethod(lambda x: x**x)
 A.fn(3)
27
 def third(x): return x/3
...
 A.fn = staticmethod(third)
 A.fn(9)
3

However, I'm assuming you're wanting to do something like this:

 class B(object):
...   def act(self):
... print self.fn()

That is, providing a hook in .act() that you can redefine on demand.
If so, note that you only need to decorate functions as staticmethods
if you're assigning them to the class. If you intend on overriding on
_instances_, you don't:

 B.fn = staticmethod(lambda: 'one') # assign on class
 b = B() # instantiate
 b.act() # act on instance
one
 B.fn = staticmethod(lambda: 'two') # assign on class
 b.act() # existing instance calls new version on class
two
 b.fn = staticmethod(lambda: 'three') # assign on instance
 b.act()
Traceback (most recent call last):
  File stdin, line 1, in module
  File stdin, line 3, in act
TypeError: 'staticmethod' object is not callable
 b.fn = lambda: 'three' # look Ma, no staticmethod!
 b.act()
three

Incidentally, this is known as the Strategy pattern, and you can see a
simple example of it in Python here: 
http://en.wikipedia.org/wiki/Strategy_pattern#Python

Hope this helps.
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: assigning multi-line strings to variables

2010-04-27 Thread MRAB

goldtech wrote:

Hi,

This is undoubtedly a newbie question. How doI assign variables
multiline strings? If I try this i get what's cited below. Thanks.



d=d

d

d

Traceback (most recent call last):
  File interactive input, line 1, in module
NameError: name 'd' is not defined


Use a triple-quoted string literal:

 d = d
... d
 d
'd\nd'
--
http://mail.python.org/mailman/listinfo/python-list


Re: assigning multi-line strings to variables

2010-04-27 Thread Brendan Abel
On Apr 27, 7:20 pm, goldtech goldt...@worldpost.com wrote:
 Hi,

 This is undoubtedly a newbie question. How doI assign variables
 multiline strings? If I try this i get what's cited below. Thanks.

  d=d
 d
  d

 Traceback (most recent call last):
   File interactive input, line 1, in module
 NameError: name 'd' is not defined



d = d\
d

or

d = dd\
dd

You don't need the trailing slash in the first example if you are
writing this in a script, python assumes it.
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Python 2.X vs. 3.X - level of acceptance?

2010-04-27 Thread John Nagle

Roger Binns wrote:

On 04/27/2010 03:57 AM, Stephan Schulz wrote:
Is Python 3 sucessful enough to make a switch worthwhile now? 


The language/interpreter is just fine.  The biggest problem is 3rd party
modules.  


   Indeed.  Python 3 is a good language, and the CPython interpreter
is in good shape, but many key modules aren't ready for prime time
under Python 3 yet.

   For teaching purposes, I'd teach Python 3.  Most Python 3 code
will run in 2.6/2.7, more or less.

   I have a Python 3.1 installed for fun, but I can't actually
do much useful with it until the MySQLdb module fully supports it.

John Nagle
--
http://mail.python.org/mailman/listinfo/python-list


Re: assigning multi-line strings to variables

2010-04-27 Thread goldtech
On Apr 27, 7:31 pm, Brendan Abel 007bren...@gmail.com wrote:
 On Apr 27, 7:20 pm, goldtech goldt...@worldpost.com wrote:

  Hi,

  This is undoubtedly a newbie question. How doI assign variables
  multiline strings? If I try this i get what's cited below. Thanks.

   d=d
  d
   d

  Traceback (most recent call last):
    File interactive input, line 1, in module
  NameError: name 'd' is not defined

 d = d\
     d

 or

 d = dd\
 dd

 You don't need the trailing slash in the first example if you are
 writing this in a script, python assumes it.

Thanks but what if the string is 500 lines. Seems it would be hard to
put a \ manually at the end of every line. How could i do that?
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: assigning multi-line strings to variables

2010-04-27 Thread goldtech
On Apr 27, 7:33 pm, MRAB pyt...@mrabarnett.plus.com wrote:
 goldtech wrote:
  Hi,

  This is undoubtedly a newbie question. How doI assign variables
  multiline strings? If I try this i get what's cited below. Thanks.

  d=d
  d
  d
  Traceback (most recent call last):
    File interactive input, line 1, in module
  NameError: name 'd' is not defined

 Use a triple-quoted string literal:

   d = d
 ... d
   d
 'd\nd'

Only seems to work when there's a '... ' on the 2nd line. I need a way
to assign large blocks of text to a variable w/out special formatting.
Thanks.
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: assigning multi-line strings to variables

2010-04-27 Thread Benjamin Kaplan
On Tue, Apr 27, 2010 at 10:51 PM, goldtech goldt...@worldpost.com wrote:

 On Apr 27, 7:33 pm, MRAB pyt...@mrabarnett.plus.com wrote:
  goldtech wrote:
   Hi,
 
   This is undoubtedly a newbie question. How doI assign variables
   multiline strings? If I try this i get what's cited below. Thanks.
 
   d=d
   d
   d
   Traceback (most recent call last):
 File interactive input, line 1, in module
   NameError: name 'd' is not defined
 
  Use a triple-quoted string literal:
 
d = d
  ... d
d
  'd\nd'

 Only seems to work when there's a '... ' on the 2nd line. I need a way
 to assign large blocks of text to a variable w/out special formatting.
 Thanks.
 --

Neither the '...' or the '' on the other lines have anything to do with
Python, it's just a convenience thing when you're using the interactive
shell.  means you're on the first line of an expression and ... means
you're in the middle of a multi-line block. When you actually write scripts,
they aren't there.

$ cat test.py
d = dd
ddd
ddd
ddd
print d

$ python test.py
dd
ddd
ddd
ddd


http://mail.python.org/mailman/listinfo/python-list

-- 
http://mail.python.org/mailman/listinfo/python-list


Re: assigning multi-line strings to variables

2010-04-27 Thread geremy condra
On Tue, Apr 27, 2010 at 10:51 PM, goldtech goldt...@worldpost.com wrote:
 On Apr 27, 7:33 pm, MRAB pyt...@mrabarnett.plus.com wrote:
 goldtech wrote:
  Hi,

  This is undoubtedly a newbie question. How doI assign variables
  multiline strings? If I try this i get what's cited below. Thanks.

  d=d
  d
  d
  Traceback (most recent call last):
    File interactive input, line 1, in module
  NameError: name 'd' is not defined

 Use a triple-quoted string literal:

   d = d
 ... d
   d
 'd\nd'

 Only seems to work when there's a '... ' on the 2nd line. I need a way
 to assign large blocks of text to a variable w/out special formatting.
 Thanks.

The '...' is the interpreter's way of telling you that you are in a
block, e.g. a function definition, with statement, etc.

The '\n' you see in the middle of the string is the newline
character. If you try to print the string, the expected
happens:

 d = 
... ddd
 d
'\nddd'
 print(d)

ddd

Geremy Condra
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: assigning multi-line strings to variables

2010-04-27 Thread MRAB

goldtech wrote:

On Apr 27, 7:33 pm, MRAB pyt...@mrabarnett.plus.com wrote:

goldtech wrote:

Hi,
This is undoubtedly a newbie question. How doI assign variables
multiline strings? If I try this i get what's cited below. Thanks.

d=d

d

d

Traceback (most recent call last):
  File interactive input, line 1, in module
NameError: name 'd' is not defined

Use a triple-quoted string literal:

  d = d
... d
  d
'd\nd'


Only seems to work when there's a '... ' on the 2nd line. I need a way
to assign large blocks of text to a variable w/out special formatting.
Thanks.


I copied it from an interactive session in IDLE. In an actual script I
would write:

text = first line
second line
third line
--
http://mail.python.org/mailman/listinfo/python-list


Re: assigning multi-line strings to variables

2010-04-27 Thread Ben Finney
goldtech goldt...@worldpost.com writes:

 Only seems to work when there's a '... ' on the 2nd line.

You seem to be confused by the presentation of the interactive
interpreter. That text is a prompt.

 I need a way to assign large blocks of text to a variable w/out
 special formatting.

That's what triple-quoted string syntax is for.

You would do well to work through the entirety of the Python tutorial
URL:http://docs.python.org/tutorial/. Take the time to actually
perform each exercise and experiment until you understand the concept
being presented, before moving on.

-- 
 \  “I find the whole business of religion profoundly interesting. |
  `\ But it does mystify me that otherwise intelligent people take |
_o__)it seriously.” —Douglas Adams |
Ben Finney
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: SWIG + expy

2010-04-27 Thread Yingjie Lan
 From: Stefan Behnel stefan...@behnel.de
 Subject: Re: SWIG + expy
 To: python-list@python.org
 Date: Tuesday, April 27, 2010, 11:57 AM
 Yingjie Lan, 27.04.2010 08:30:
  Is it possible to use SWIG to parse C/C++, and provide
 an interface for
  me to generate some code? I thought it might be good
 to have SWIG help
  generate expy files, then generate the python
 extension via expy.
 
 There have been similar discussions on the Cython mailing
 list (you might want to search the archives). The main theme
 seems to be that clang provides a suitable parser, and
 several people have used it to write up a code generator for
 their specific needs (you might want to look at those).
 

Thank you very much, I will take a look at this.
BTW, is there a similar project going on for Cython?

Yingjie


  
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: assigning multi-line strings to variables

2010-04-27 Thread Sagar K
Use triple quote:
d =  this is
a sample text
which does
not mean
anything

goldtech goldt...@worldpost.com wrote in message 
news:4e25733e-eafa-477b-a84d-a64d139f7...@u34g2000yqu.googlegroups.com...
On Apr 27, 7:31 pm, Brendan Abel 007bren...@gmail.com wrote:
 On Apr 27, 7:20 pm, goldtech goldt...@worldpost.com wrote:

  Hi,

  This is undoubtedly a newbie question. How doI assign variables
  multiline strings? If I try this i get what's cited below. Thanks.

   d=d
  d
   d

  Traceback (most recent call last):
  File interactive input, line 1, in module
  NameError: name 'd' is not defined

 d = d\
 d

 or

 d = dd\
 dd

 You don't need the trailing slash in the first example if you are
 writing this in a script, python assumes it.

Thanks but what if the string is 500 lines. Seems it would be hard to
put a \ manually at the end of every line. How could i do that? 


-- 
http://mail.python.org/mailman/listinfo/python-list


Re: assigning multi-line strings to variables

2010-04-27 Thread Alf P. Steinbach

On 28.04.2010 07:11, * Sagar K:

Use triple quote:
d =  this is
a sample text
which does
not mean
anything

goldtechgoldt...@worldpost.com  wrote in message
news:4e25733e-eafa-477b-a84d-a64d139f7...@u34g2000yqu.googlegroups.com...
On Apr 27, 7:31 pm, Brendan Abel007bren...@gmail.com  wrote:

On Apr 27, 7:20 pm, goldtechgoldt...@worldpost.com  wrote:


Hi,



This is undoubtedly a newbie question. How doI assign variables
multiline strings? If I try this i get what's cited below. Thanks.



d=d

d

d



Traceback (most recent call last):
File interactive input, line 1, inmodule
NameError: name 'd' is not defined


d = d\
d

or

d = dd\
dd

You don't need the trailing slash in the first example if you are
writing this in a script, python assumes it.


Thanks but what if the string is 500 lines. Seems it would be hard to
put a \ manually at the end of every line. How could i do that?


That depends. You can put the string in a separate text file and read the file, 
or you can have it as a literal. For the latter your editor should provide you 
with the tools to format the string any which way you want, and if not, then 
just a write a Python script to format it for you.


Consider this little example[1]:


code file=jabberwocky.py
The Jabberwocky poem, by Lewis Carrol

text = (
'Twas brillig, and the slithy toves\n
Did gyre and gimble in the wabe;\n
  All mimsy were the borogoves,\n
And the mome raths outgrabe.\n
\n
\Beware the jabberwock, my son!\n
  The jaws that bite, the claws that catch!\n
Beware the jubjub bird, and shun\n
  The frumious bandersnatch!\\n
\n
He took his vorpal sword in hand:\n
  Long time the manxome foe he sought--\n
So rested he by the tumtum tree,\n
  And stood awhile in thought.\n
\n
And as in uffish thought he stood,\n
  The jabberwock, with eyes of flame,\n
Came whiffling through the tulgey wood,\n
  And burbled as it came!\n
\n
One, two! one, two! and through and through\n
  The vorpal blade went snicker-snack!\n
He left it dead, and with its head\n
  He went galumphing back.\n
\n
\And hast thou slain the jabberwock?\n
  Come to my arms, my beamish boy!\n
O frabjous day! callooh! callay!\\n
  He chortled in his joy.\n
\n
'Twas brillig, and the slithy toves\n
Did gyre and gimble in the wabe;\n
  All mimsy were the borogoves,\n
And the mome raths outgrabe.
)
/code


This defines /one/ string value, using compile time concatenation (any adjacent 
string literals are concatenated at compile time, in Python[2] and in C++).


The text was just copied and pasted from Wikipedia, and subjected to a few well 
chosen keystrokes in an editor.


As a hopefully illuminating exercise, consider a Python program that uses this 
string (just import the above module and use its 'text') and generates the above 
source code as output.



Cheers  hth.,

- Alf

Notes:
[1] From an example at the end of chapter 2 at url: 
http://tinyurl.com/programmingbookP3.

[2] I'm not sure how well that plays with Python doc strings; haven't tried.
--
http://mail.python.org/mailman/listinfo/python-list


[issue8545] i didn't get rqrd output for programme in python?(plz... help)

2010-04-27 Thread Georg Brandl

Georg Brandl ge...@python.org added the comment:

Please use python-h...@python.org or comp.lang.python for usage questions, not 
the tracker.

--
nosy: +georg.brandl
resolution:  - invalid
status: open - closed

___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue8545
___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue1462525] URI parsing library

2010-04-27 Thread Paul Jimenez

Paul Jimenez p...@place.org added the comment:

Since no one else has commented on this in over a year, and the new (2.6+) code 
works fine, I'll just close this to help clean things up.

--
status: open - closed

___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue1462525
___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue8128] String interpolation with unicode subclass fails to call __str__

2010-04-27 Thread Georg Brandl

Georg Brandl ge...@python.org added the comment:

In Python 2.x, __unicode__ is called instead of __str__.  Whether that's 
correct behavior, I'm not sure, but at least it is consistent with 
{}.format(K()).

In Python 3.x, __unicode__ doesn't exist and __str__ isn't called; but for 
{}.format(K()), it is.  Therefore I think here a fix should be made in any 
case.

Benjamin, what do you think?

--
assignee:  - benjamin.peterson
nosy: +benjamin.peterson, georg.brandl

___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue8128
___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue4037] doctest.py should include method descriptors when looking inside a class __dict__

2010-04-27 Thread Georg Brandl

Georg Brandl ge...@python.org added the comment:

So for staticmethods and classmethods, valname doesn't need to be reassigned?

--
nosy: +georg.brandl

___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue4037
___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue8546] The parameter buffering in _pyio.open doesn't work the same as in the builtin open

2010-04-27 Thread Patrick Sabin

New submission from Patrick Sabin patricksa...@gmx.at:

As far as I understand the _pyio.open function should resemble the builtin 
open, but in case of the buffering parameter, it doesn't. The builtin version 
doesn't allow None as argument, but this is the default in the _pyio.open 
signature.

I attached a patch, which changes the default value of the buffering parameter 
to -1, which is the default in the builtin version.

--
assignee: d...@python
components: Documentation, Library (Lib)
files: change_pyio_open_buffering_parameter.diff
keywords: patch
messages: 104301
nosy: d...@python, pyfex
priority: normal
severity: normal
status: open
title: The parameter buffering in _pyio.open doesn't work the same as in the 
builtin open
type: behavior
versions: Python 3.1, Python 3.2, Python 3.3
Added file: 
http://bugs.python.org/file17103/change_pyio_open_buffering_parameter.diff

___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue8546
___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue7384] curses crash on FreeBSD

2010-04-27 Thread Stefan Krah

Stefan Krah stefan-use...@bytereef.org added the comment:

Roumen Petrov rep...@bugs.python.org wrote:
 Yes , I  understand .
 For the protocol did gcc on FreeBSD warn if library order is -lncursesw 
   -lreadline  ?

No.

 P.S. Issue with readline library linked to termcap compatible library on 
 system that distribute more then one termcap compatible library is about 
 10 years old.

I didn't want to touch the termcap logic. There's potential for breakage,
and a real investigation would be time consuming.

(There's a needless warning on Tiger about /usr/lib/termcap that could
be fixed in another issue.)

--

___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue7384
___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



  1   2   3   >