Re: 2 + 2 = 5

2012-07-04 Thread Steven D'Aprano
On Wed, 04 Jul 2012 23:38:17 -0400, Terry Reedy wrote: > If I run the script in 3.3 Idle, I get the same output you got. If I > then enter '5-2' interactively, I still get 3. Maybe the constant folder > is always on now. Yes, I believe constant folding is always on, since Python 2.4 if I remembe

Re: simpler increment of time values?

2012-07-04 Thread Devin Jeanpierre
On Thu, Jul 5, 2012 at 12:57 AM, Jason Friedman wrote: > I have some thoughts on a solution, but first, what is 12:45 plus 12 > hours? What is 12:45 minus 13 hours? Is there anything unusual that can happen for a notion of time that is dateless, timezone-unaware, and DST-free? I would imagine t

Re: simpler increment of time values?

2012-07-04 Thread Jason Friedman
> Hi all, > I'd like to ask about the possibilities to do some basic manipulation > on timestamps - such as incrementing a given time (hour.minute - > string) by some minutes. > Very basic notion of "time" is assumed, i.e. dateless, > timezone-unaware, DST-less etc. > I first thought, it would be p

Help: PYMALLOC_DBUG and PIL

2012-07-04 Thread tom z
Hi~ all, I encounter a odd problem, when i compile Python with PYMALLOC_DEBUG, the PIL module can't work fine, it always make core-dump like this [Switching to Thread 182897301792 (LWP 16102)] 0x004df264 in PyObject_Malloc (nbytes=64) at Objects/obmalloc.c:804 804 if ((pool

Re: 2 + 2 = 5

2012-07-04 Thread Terry Reedy
On 7/4/2012 4:37 PM, Michael Ross wrote: Am 04.07.2012, 21:37 Uhr, schrieb Paul Rubin : I just came across this (https://gist.github.com/1208215): import sys import ctypes pyint_p = ctypes.POINTER(ctypes.c_byte*sys.getsizeof(5)) five = ctypes.cast(id(5), pyint_p) print(2 +

Re: Discussion on some Code Issues

2012-07-04 Thread subhabangalore
On Thursday, July 5, 2012 4:51:46 AM UTC+5:30, (unknown) wrote: > Dear Group, > > I am Sri Subhabrata Banerjee trying to write from Gurgaon, India to discuss > some coding issues. If any one of this learned room can shower some light I > would be helpful enough. > > I got to code a bunch of do

how to interact with Windows cmd?

2012-07-04 Thread self.python
what I want to do is 1.open cmd 2.waiting for user's typing 3.when I type "dir" 4.print the result of "dir" 5.then I type some other commands, printing the result until I type 'exit' I used p=subprocess.Popen('cmd',stdin=subprocess.PIPE,stdout=subprocess.PIPE,stderr=subprocess.PIPE,shell=True) p=c

Re: simpler increment of time values?

2012-07-04 Thread Mark Lawrence
On 05/07/2012 01:29, Vlastimil Brom wrote: Hi all, I'd like to ask about the possibilities to do some basic manipulation on timestamps - such as incrementing a given time (hour.minute - string) by some minutes. Very basic notion of "time" is assumed, i.e. dateless, timezone-unaware, DST-less etc.

Re: 2 + 2 = 5

2012-07-04 Thread Cameron Simpson
On 04Jul2012 19:39, Evan Driscoll wrote: | On 7/4/2012 14:37, Paul Rubin wrote: | > I just came across this (https://gist.github.com/1208215): | > | > import sys | > import ctypes | > pyint_p = ctypes.POINTER(ctypes.c_byte*sys.getsizeof(5)) | > five = ctypes.cast(id(5), pyint_p) |

Re: simpler increment of time values?

2012-07-04 Thread Chris Angelico
On Thu, Jul 5, 2012 at 10:29 AM, Vlastimil Brom wrote: > I'd like to ask about the possibilities to do some basic manipulation > on timestamps - such as incrementing a given time (hour.minute - > string) by some minutes. > Very basic notion of "time" is assumed, i.e. dateless, > timezone-unaware,

Re: 2 + 2 = 5

2012-07-04 Thread Evan Driscoll
On 7/4/2012 14:37, Paul Rubin wrote: > I just came across this (https://gist.github.com/1208215): > > import sys > import ctypes > pyint_p = ctypes.POINTER(ctypes.c_byte*sys.getsizeof(5)) > five = ctypes.cast(id(5), pyint_p) > print(2 + 2 == 5) # False > five.contents[five.

simpler increment of time values?

2012-07-04 Thread Vlastimil Brom
Hi all, I'd like to ask about the possibilities to do some basic manipulation on timestamps - such as incrementing a given time (hour.minute - string) by some minutes. Very basic notion of "time" is assumed, i.e. dateless, timezone-unaware, DST-less etc. I first thought, it would be possible to jus

Re: Using a CMS for small site?

2012-07-04 Thread alex23
On Jul 5, 1:21 am, Roy Smith wrote: > If the content is truly never going to change, there's nothing to > prevent you from creating some static html files with your favorite text > editor. > > This is really getting quite far afield for a Python group.  There are > better forums for these kinds of

Help using Tix and tix.balloon in tkinter.ttk Gui on Py 3.2.3, Mac OS X 10.6.8

2012-07-04 Thread Greg Edwards
Hi, I'm trying to get Tix installed and working, in order to use Tix.balloon in the first instance. I'm using Python 3.2.3 on Mac OS X 10.6.8, installed from direct package download from Python.org. Have also installed Py 2.7.3, and the native Mac Py 2.6.1 and 2.5.4 are all working fine as well a

Re: Discussion on some Code Issues

2012-07-04 Thread Rick Johnson
On Jul 4, 6:21 pm, subhabangal...@gmail.com wrote: > [...] > To detect the document boundaries, I am splitting them into a bag > of words and using a simple for loop as, > > for i in range(len(bag_words)): >         if bag_words[i]=="$": >             print (bag_words[i],i) Ignoring that you are a

Re: Discussion on some Code Issues

2012-07-04 Thread Steven D'Aprano
On Wed, 04 Jul 2012 16:21:46 -0700, subhabangalore wrote: [...] > I got to code a bunch of documents which are combined together. [...] > The task is to separate the documents on the fly and to parse each of > the documents with a definite set of rules. > > Now, the way I am processing is: > I a

Discussion on some Code Issues

2012-07-04 Thread subhabangalore
Dear Group, I am Sri Subhabrata Banerjee trying to write from Gurgaon, India to discuss some coding issues. If any one of this learned room can shower some light I would be helpful enough. I got to code a bunch of documents which are combined together. Like, 1)A Mumbai-bound aircraft with

Re: locals().update(...)

2012-07-04 Thread Steven D'Aprano
On Wed, 04 Jul 2012 18:48:08 -0400, Dave Angel wrote: > As i said above, the rules are different for globals, and they are even > if you use locals() to access them. However, i'd consider it prudent > never to assume you can write to the dictionary constructed by either > the locals() or the glob

Re: import class from string

2012-07-04 Thread Thomas Jollans
On 07/04/2012 10:27 PM, Mariano DAngelo wrote: > Hi I'm trying to create a class from a string > This is my code, but is not working It would be helpful if you posted an error message. Then, we could know what's actually going on. > 'myshop.models.base' > module_name, class_name = model

Re: import class from string

2012-07-04 Thread Steven D'Aprano
On Wed, 04 Jul 2012 13:27:29 -0700, Mariano DAngelo wrote: > Hi I'm trying to create a class from a string This is my code, but > is not working > > 'myshop.models.base' > module_name, class_name = model.rsplit(".", 1) > module = importlib.import_module(module_name) > class_ = getattr(m

Re: locals().update(...)

2012-07-04 Thread Dave Angel
On 07/04/2012 07:56 AM, eis...@gmail.com wrote: > I expected this to work: > > > def f(**args): > locals().update(args) > print locals() > print a > > d=dict(a=1) > > f(**d) > > but: >> global name 'a' is not defined > Where is my mistake? Chris has given you the place where it's docum

Re: 2 + 2 = 5

2012-07-04 Thread Thomas Jollans
On 07/04/2012 09:37 PM, Paul Rubin wrote: > I just came across this (https://gist.github.com/1208215): > > import sys > import ctypes > pyint_p = ctypes.POINTER(ctypes.c_byte*sys.getsizeof(5)) > five = ctypes.cast(id(5), pyint_p) > print(2 + 2 == 5) # False > five.contents[

Re: Using a CMS for small site?

2012-07-04 Thread Gilles
On Wed, 04 Jul 2012 11:21:42 -0400, Roy Smith wrote: >This is really getting quite far afield for a Python group. There are >better forums for these kinds of questions. Probably. I'll keep that in mind while checking Python web frameworks. Thanks. -- http://mail.python.org/mailman/listinfo/pyt

Re: 2 + 2 = 5

2012-07-04 Thread Mark Lawrence
On 04/07/2012 20:37, Paul Rubin wrote: I just came across this (https://gist.github.com/1208215): import sys import ctypes pyint_p = ctypes.POINTER(ctypes.c_byte*sys.getsizeof(5)) five = ctypes.cast(id(5), pyint_p) print(2 + 2 == 5) # False five.contents[five.conten

Re: 2 + 2 = 5

2012-07-04 Thread Michael Ross
Am 04.07.2012, 21:37 Uhr, schrieb Paul Rubin : I just came across this (https://gist.github.com/1208215): import sys import ctypes pyint_p = ctypes.POINTER(ctypes.c_byte*sys.getsizeof(5)) five = ctypes.cast(id(5), pyint_p) print(2 + 2 == 5) # False five.contents[five.con

import class from string

2012-07-04 Thread Mariano DAngelo
Hi I'm trying to create a class from a string This is my code, but is not working 'myshop.models.base' module_name, class_name = model.rsplit(".", 1) module = importlib.import_module(module_name) class_ = getattr(module, class_name)() Anyone know what I'm doing wrong or another way?

Re: 2 + 2 = 5

2012-07-04 Thread Stefan Behnel
Paul Rubin, 04.07.2012 21:37: > I just came across this (https://gist.github.com/1208215): > > import sys > import ctypes > pyint_p = ctypes.POINTER(ctypes.c_byte*sys.getsizeof(5)) > five = ctypes.cast(id(5), pyint_p) > print(2 + 2 == 5) # False > five.contents[five.content

2 + 2 = 5

2012-07-04 Thread Paul Rubin
I just came across this (https://gist.github.com/1208215): import sys import ctypes pyint_p = ctypes.POINTER(ctypes.c_byte*sys.getsizeof(5)) five = ctypes.cast(id(5), pyint_p) print(2 + 2 == 5) # False five.contents[five.contents[:].index(5)] = 4 print(2 + 2 == 5) # Tru

Re: adding a simulation mode

2012-07-04 Thread Paul Rubin
andrea crotti writes: > copytree(src, dest) becomes: > if not PRETEND_ONLY: > copytree(src, dest) > > But I don't like it too much because I would have to add a lot of > garbage around.. I've had good results writing the module under test in the style of a java applet, i.e. one of its args is

Re: code review

2012-07-04 Thread Mark Lawrence
On 04/07/2012 10:29, Paul Rudin wrote: Mark Lawrence writes: On 03/07/2012 03:25, John O'Hagan wrote: On Tue, 3 Jul 2012 11:22:55 +1000 I agree to some extent, but as a counter-example, when I was a child there a subject called "Weights and Measures" which is now redundant because of the Met

Re: adding a simulation mode

2012-07-04 Thread Devin Jeanpierre
For what it's worth, this is the reason that Allen Short wrote Exocet. > This way, you can test your code without having to resort to sys.modules > hackery, and you can better factor your applications by separating > configuration and environment concerns from the rest of your code. See: - http:

Re: adding a simulation mode

2012-07-04 Thread Mike C. Fletcher
On 12-07-04 05:42 AM, andrea crotti wrote: ... copytree(src, dest) becomes: if not PRETEND_ONLY: copytree(src, dest) import globalsub, unittest class MyTest( unittest.TestCase ): def setUp( self ): globalsub.subs( shutil.copytree ) def tearDown( self ): globalsub.re

Re: Using a CMS for small site?

2012-07-04 Thread Roy Smith
In article <7fk8v7pijp359t62clgj5g4n3d4acva...@4ax.com>, Gilles wrote: > On Wed, 04 Jul 2012 06:28:09 -0400, Roy Smith wrote: > >You probably want to look at https://www.django-cms.org/. It's not > >something that a person with "no computer knowledge" could set up, but > >once it's set up, t

Re: Using a CMS for small site?

2012-07-04 Thread Gilles
On Wed, 04 Jul 2012 06:28:09 -0400, Roy Smith wrote: >You probably want to look at https://www.django-cms.org/. It's not >something that a person with "no computer knowledge" could set up, but >once it's set up, that person could use it to build pages. > >But, to be honest, for somebody who rea

Re: adding a simulation mode

2012-07-04 Thread andrea crotti
> Yes there is no easy solution apparently.. But I'm also playing > around with vagrant and virtual machine generations, suppose I'm able > to really control what will be on the machine at time X, creating it > on demand with what I need, it might be a good way to solve my > problems (a bit overki

PyPyODBC 0.6 released! (A Pure Python ODBC module)

2012-07-04 Thread 江文
PyPyODBC - A Pure Python ctypes ODBC module Changes in version 0.6: Added Cursor.commit() and Cursor.rollback(). It is now possible to use only a cursor in your code instead of keeping track of a connection and a cursor. Added readonly keyword to connect. If set to True, SQLSetConnectAttr SQL_ATT

Re: adding a simulation mode

2012-07-04 Thread andrea crotti
2012/7/4 Steven D'Aprano : > > Then, have your code accept the thing as an argument. > > E.g. instead of having a hard-coded database connection, allow the > database connection to be set (perhaps as an argument, perhaps as a > config option, etc.). > > There are libraries to help with mocks, e.g.:

Question about weakref

2012-07-04 Thread Frank Millman
Hi all I have a situation where I thought using weakrefs would save me a bit of effort. I have a basic publish/subscribe scenario. The publisher maintains a list of listener objects, and has a method whereby a listener can subscribe to the list by passing in 'self', whereupon it gets added t

Re: adding a simulation mode

2012-07-04 Thread Steven D'Aprano
On Wed, 04 Jul 2012 10:42:56 +0100, andrea crotti wrote: > I'm writing a program which has to interact with many external > resources, at least: > - mysql database > - perforce > - shared mounts > - files on disk > > And the logic is quite complex, because there are many possible paths to > follo

Re: locals().update(...)

2012-07-04 Thread Christian Heimes
Am 04.07.2012 13:56, schrieb eis...@gmail.com: > I expected this to work: It doesn't work and that's documented: http://docs.python.org/library/functions.html?highlight=locals#locals -- http://mail.python.org/mailman/listinfo/python-list

locals().update(...)

2012-07-04 Thread eisoab
I expected this to work: def f(**args): locals().update(args) print locals() print a d=dict(a=1) f(**d) but: > global name 'a' is not defined Where is my mistake? This does work: globals().update({'a':1}) print a 1 -E -- http://mail.python.org/mailman/listinfo/python-lis

Re: code review

2012-07-04 Thread levi nie
2012/7/4 Paul Rudin > Mark Lawrence writes: > > > On 03/07/2012 03:25, John O'Hagan wrote: > >> On Tue, 3 Jul 2012 11:22:55 +1000 > >> > >> I agree to some extent, but as a counter-example, when I was a child > there > >> a subject called "Weights and Measures" which is now redundant because > o

Re: Using a CMS for small site?

2012-07-04 Thread Roy Smith
In article , Gilles wrote: > Hello > > Someone I know with no computer knowledge has a studio appartment to > rent in Paris and spent four months building a small site in Joomla to > find short-time renters. > > The site is just... > - a few web pages that include text (in four languages) and

adding a simulation mode

2012-07-04 Thread andrea crotti
I'm writing a program which has to interact with many external resources, at least: - mysql database - perforce - shared mounts - files on disk And the logic is quite complex, because there are many possible paths to follow depending on some other parameters. This program even needs to run on many

Re: code review

2012-07-04 Thread Paul Rudin
Mark Lawrence writes: > On 03/07/2012 03:25, John O'Hagan wrote: >> On Tue, 3 Jul 2012 11:22:55 +1000 >> >> I agree to some extent, but as a counter-example, when I was a child there >> a subject called "Weights and Measures" which is now redundant because of the >> Metric system. I don't miss ho

Using a CMS for small site?

2012-07-04 Thread Gilles
Hello Someone I know with no computer knowledge has a studio appartment to rent in Paris and spent four months building a small site in Joomla to find short-time renters. The site is just... - a few web pages that include text (in four languages) and pictures displayed in a Flash slide show - a c

Re: code review

2012-07-04 Thread Mark Lawrence
On 03/07/2012 22:54, Chris Angelico wrote: On Wed, Jul 4, 2012 at 6:13 AM, Dave Angel wrote: On 07/03/2012 12:05 PM, Mark Lawrence wrote: If I go to the moon I will weigh 2st 10lb (if my sums are correct :) but the equivalent Frenchman will still be 86kg. I hereby put this forward as proof tha

Re: a problem about "print"

2012-07-04 Thread Mark Lawrence
@Matteo, @Levi, please don't top post it makes following a thread very difficult, no other comments, TIA. On 04/07/2012 08:51, Matteo Boscolo wrote: in the code2 aList=[1,2,3,4,5,6,7,8,9,10] aList=str(aList) #<--- here you convert the list in a string print aList print aList[2] #<-- here you

Re: a problem about "print"

2012-07-04 Thread levi nie
Yes,you're right. I got it now.I mistaked that aList also had be changed in code1 before. Thanks a lot. 2012/7/4 Matteo Boscolo > in the code2 > > aList=[1,2,3,4,5,6,7,8,9,10] > aList=str(aList) #<--- here you convert the list in a string > > print aList > print aList[2] #<-- here you are prin

Re: a problem about "print"

2012-07-04 Thread levi nie
Yes,you are right. 2012/7/4 Chris Angelico > On Wed, Jul 4, 2012 at 5:28 PM, levi nie wrote: > > aList=str(aList) > > print aList > > print aList[2] > > The str() function takes pretty much anything and returns a string. > When you subscript a string, you get characters. It's not a list of > nu

Re: code review

2012-07-04 Thread rusi
On Jul 4, 11:17 am, alex23 wrote: > On Jul 4, 3:39 pm, "Littlefield, Tyler" wrote: > > > I basically just stopped after a while. It got into a my language is > > better than your language, so I didn't see much constructive info. > > To be fair, it's more "my vision of the language is better than

Re: code review

2012-07-04 Thread alex23
On Jul 4, 3:39 pm, "Littlefield, Tyler" wrote: > I basically just stopped after a while. It got into a my language is > better than your language, so I didn't see much constructive info. To be fair, it's more "my vision of the language is better than yours" :) But yes, it should've been forked in

Re: when "normal" parallel computations in CPython will be implemented at last?

2012-07-04 Thread Tim Roberts
John Nagle wrote: > >It would be "un-Pythonic" to have real concurrency in Python. >You wouldn't be able to patch code running in one thread from >another thread. Some of the dynamic features of Python >would break. If you want fine-grained concurrency, you need >controlled isolation betwee

Re: a problem about "print"

2012-07-04 Thread Matteo Boscolo
in the code2 aList=[1,2,3,4,5,6,7,8,9,10] aList=str(aList) #<--- here you convert the list in a string print aList print aList[2] #<-- here you are printing the third caracter of the string '[1, 2, 3, 4, 5, 6, 7, 8, 9, 10]' not the list '[1, 2, 3, 4, 5, 6, 7, 8, 9, 10]' regards Matteo Il

Re: a problem about "print"

2012-07-04 Thread Chris Angelico
On Wed, Jul 4, 2012 at 5:28 PM, levi nie wrote: > aList=str(aList) > print aList > print aList[2] The str() function takes pretty much anything and returns a string. When you subscript a string, you get characters. It's not a list of numbers any more. (Technically str is a class, not a function,

Re: a problem about "print"

2012-07-04 Thread levi nie
Hi,Harrison. Your method is cool. But i doubt this, if bList and aList just are attached to the same List when i write bList=aList,but why the output of the following two code are different? code1: aList=[1,2,3,4,5,6,7,8,9,10] bList=aList bList=str(bList) print aList print aList[2] code2: aList=[

[no subject]

2012-07-04 Thread levi nie
-- http://mail.python.org/mailman/listinfo/python-list