Re: closures and dynamic binding

2008-09-28 Thread Aaron "Castironpi" Brady
On Sep 28, 1:14 am, Marc 'BlackJack' Rintsch <[EMAIL PROTECTED]> wrote: > On Sat, 27 Sep 2008 21:43:15 -0700, Aaron \"Castironpi\" Brady wrote: > > To me, this is a somewhat unintuitive behavior.  I want to discuss the > > parts of it I don't understand. > > f= [ None ]* 10 > for n in ran

Re: design pattern: MVC in python

2008-09-28 Thread 甜瓜
Really helpful! 2008/9/28 Mikolai Fajer <[EMAIL PROTECTED]>: > The following link directly discusses using MVC and pygame. > > http://ezide.com/games/writing-games.html > > -- > > -Mikolai Fajer- > -- > http://mail.python.org/mailman/listinfo/python-list > -- http://mail.python.org/mailman/lis

Re: What do you call a class not intended to be instantiated

2008-09-28 Thread Terry Reedy
Steven D'Aprano wrote: And modules aren't callable. I've often thought they should be. Modules are not callable because their class, module, has no __call__ instance method. But (in 3.0, which is all I will check) you can subclass module and add one. >>> m = type(__builtins__) >>> m >>>

Re: closures and dynamic binding

2008-09-28 Thread Terry Reedy
Aaron "Castironpi" Brady wrote: Hello all, To me, this is a somewhat unintuitive behavior. I want to discuss the parts of it I don't understand. f= [ None ]* 10 for n in range( 10 ): ... f[ n ]= lambda: n This is equivalent to for n in range(10): def g(): return n f[n] = g which

Re: closures and dynamic binding

2008-09-28 Thread Steven D'Aprano
On Sat, 27 Sep 2008 21:43:15 -0700, Aaron \"Castironpi\" Brady wrote: > Hello all, > > To me, this is a somewhat unintuitive behavior. I want to discuss the > parts of it I don't understand. > f= [ None ]* 10 for n in range( 10 ): > ... f[ n ]= lambda: n > ... f[0]() > 9

Re: str() should convert ANY object to a string without EXCEPTIONS !

2008-09-28 Thread Terry Reedy
est wrote: >>From python manual > > str( [object]) > > Return a string containing a nicely printable representation of an > object. For strings, this returns the string itself. The difference > with repr(object) is that str(object) does not always attempt to > return a string that is acceptable t

Re: str() should convert ANY object to a string without EXCEPTIONS !

2008-09-28 Thread Steven D'Aprano
On Sun, 28 Sep 2008 19:03:42 +1300, Lawrence D'Oliveiro wrote: > In message > <[EMAIL PROTECTED]>, est > wrote: > >> The problem is, why the f**k set ASCII encoding to range(128) > > Because that's how ASCII is defined. > >> while str() is internally byte array it should be handled in

Re: What do you call a class not intended to be instantiated

2008-09-28 Thread Ben Finney
Terry Reedy <[EMAIL PROTECTED]> writes: > Steven D'Aprano wrote: > > > And modules aren't callable. I've often thought they should be. > > Modules are not callable because their class, module, has no > __call__ instance method. But (in 3.0, which is all I will check) > you can subclass module an

The sale of world famous jacket,Jean-COOGI/DG/ginoshoes on

2008-09-28 Thread The best online shopping site!(www.wholenikee.cn)
shoes on AIR Jordan 1 (paypal payment)(www.wholejean.cn ) AIR Jordan 2 AIR Jordan 3 AIR Jordan 4 AIR Jordan 5 (paypal payment)(www.wholejean.cn ) AIR Jordan 6 Rings AIR Jordan 6 AIR Jordan 7 AIR Jordan 8 AIR Jordan 9 (paypal payment)(www.wholejean.cn ) AIR Jordan 10 AIR Jordan 11 AIR Jordan 12 AIR

Re: str() should convert ANY object to a string without EXCEPTIONS !

2008-09-28 Thread Steven D'Aprano
On Sun, 28 Sep 2008 03:55:46 -0400, Terry Reedy wrote: > est wrote: >>>From python manual >> >> str( [object]) >> >> Return a string containing a nicely printable representation of an >> object. For strings, this returns the string itself. The difference >> with repr(object) is that str(object)

Re: str() should convert ANY object to a string without EXCEPTIONS !

2008-09-28 Thread est
> Because that's how ASCII is defined. > Because that's how ASCII is defined. ASCII is a 7-bit code. Then why can't python use another default encoding internally range(256)? > Python refuses to guess and tries the lowest common denominator -- ASCII -- > instead. That's the problem. ASCII is I

Re: str() should convert ANY object to a string without EXCEPTIONS !

2008-09-28 Thread Steven D'Aprano
On Sat, 27 Sep 2008 22:37:09 -0700, est wrote: str(u'\ue863') > Traceback (most recent call last): > File "", line 1, in > UnicodeEncodeError: 'ascii' codec can't encode character u'\ue863' in > position 0 > : ordinal not in range(128) > > FAIL. What result did you expect? [...] > The

Re: str() should convert ANY object to a string without EXCEPTIONS !

2008-09-28 Thread est
On Sep 28, 4:38 pm, Steven D'Aprano <[EMAIL PROTECTED] cybersource.com.au> wrote: > On Sat, 27 Sep 2008 22:37:09 -0700, est wrote: > str(u'\ue863') > > Traceback (most recent call last): > >   File "", line 1, in > > UnicodeEncodeError: 'ascii' codec can't encode character u'\ue863' in > > po

Calculating timespan

2008-09-28 Thread Erhard
I've been looking at the date/time classes and I'm at a loss as to how to do this (probably too used to other platforms). I have two date/time values. One represents 'now' and the other the last modified time of a file on disk (from stat). I need to calculate the difference in time (i.e., a 't

Re: Borg vs Singleton vs OddClass

2008-09-28 Thread Carl Banks
On Sep 27, 2:12 pm, Lie <[EMAIL PROTECTED]> wrote: > I'm thinking about this design pattern (I don't know if anyone has > ever thought of this pattern before): > > class OddClass(object): >     def __init__(self): >         global OddClass >         OddClass = self >     def __call__(): >         r

Re: Calculating timespan

2008-09-28 Thread marek . rocki
Erhard napisał(a): > I've been looking at the date/time classes and I'm at a loss as to how > to do this (probably too used to other platforms). > > I have two date/time values. One represents 'now' and the other the last > modified time of a file on disk (from stat). I need to calculate the > diff

Re: Calculating timespan

2008-09-28 Thread Erhard
[EMAIL PROTECTED] wrote: from datetime import datetime, timedelta span = datetime.now() - datetime(year=2008,month=8,day=27,hour=12,minute=34,second=56) if span < timedelta(minutes=37): # do something timedelta! Yes, it's obvious that's what I was looking for. I was stuck with 'timespan' i

Re: str() should convert ANY object to a string without EXCEPTIONS !

2008-09-28 Thread Lie
On Sep 28, 12:37 pm, est <[EMAIL PROTECTED]> wrote: > From python manual > > str( [object]) > > Return a string containing a nicely printable representation of an > object. For strings, this returns the string itself. The difference > with repr(object) is that str(object) does not always attempt to

Re: str() should convert ANY object to a string without EXCEPTIONS !

2008-09-28 Thread Marc 'BlackJack' Rintsch
On Sun, 28 Sep 2008 01:35:11 -0700, est wrote: >> Because that's how ASCII is defined. >> Because that's how ASCII is defined. ASCII is a 7-bit code. > > Then why can't python use another default encoding internally > range(256)? Because that doesn't suffice. Unicode code points can be >255.

Re: is decorator the right thing to use?

2008-09-28 Thread George Sakkis
On Sep 27, 11:38 pm, "Dmitry S. Makovey" <[EMAIL PROTECTED]> wrote: > George Sakkis wrote: > > It's funny how often you come with a better solution a few moments > > after htting send! The snippet above can (ab)use the decorator syntax > > so that it becomes: > > > class A(Proxy): > > >     @ProxyM

Re: str() should convert ANY object to a string without EXCEPTIONS !

2008-09-28 Thread Olivier Lauzanne
On Sep 28, 11:21 am, est <[EMAIL PROTECTED]> wrote: > On Sep 28, 4:38 pm, Steven D'Aprano <[EMAIL PROTECTED] > Can anyone tell me how to customize a default encoding, let's say > 'ansi' which handles range(256) ? I assume you are using python2.5 Edit the file /usr/lib/python2.5/site.py There is a

Re: how to replace and string in a "SELECT ... IN ()"

2008-09-28 Thread Tino Wildenhain
Michael Mabin wrote: I'm exhausted, so I'll just shut up about this after a few final words. Thank you for your time :-) 1. "edits" is used in data warehousing to describe data scrubbing or filtering of fields in records that are used as input sources for loading into data warehouses. It's a

Re: str() should convert ANY object to a string without EXCEPTIONS !

2008-09-28 Thread Lie
On Sep 28, 4:21 pm, est <[EMAIL PROTECTED]> wrote: > On Sep 28, 4:38 pm, Steven D'Aprano <[EMAIL PROTECTED] > > > > cybersource.com.au> wrote: > > On Sat, 27 Sep 2008 22:37:09 -0700, est wrote: > > str(u'\ue863') > > > Traceback (most recent call last): > > >   File "", line 1, in > > > Unico

Re: str() should convert ANY object to a string without EXCEPTIONS !

2008-09-28 Thread est
On Sep 28, 6:15 pm, Marc 'BlackJack' Rintsch <[EMAIL PROTECTED]> wrote: > On Sun, 28 Sep 2008 01:35:11 -0700, est wrote: > >> Because that's how ASCII is defined. > >> Because that's how ASCII is defined.  ASCII is a 7-bit code. > > > Then why can't python use another default encoding internally >

Re: str() should convert ANY object to a string without EXCEPTIONS !

2008-09-28 Thread Lie
On Sep 28, 3:35 pm, est <[EMAIL PROTECTED]> wrote: > > Because that's how ASCII is defined. > > Because that's how ASCII is defined.  ASCII is a 7-bit code. > > Then why can't python use another default encoding internally > range(256)? > > > Python refuses to guess and tries the lowest common deno

Re: str() should convert ANY object to a string without EXCEPTIONS !

2008-09-28 Thread est
On Sep 28, 7:12 pm, Lie <[EMAIL PROTECTED]> wrote: > On Sep 28, 3:35 pm, est <[EMAIL PROTECTED]> wrote: > > > > Because that's how ASCII is defined. > > > Because that's how ASCII is defined.  ASCII is a 7-bit code. > > > Then why can't python use another default encoding internally > > range(256)?

Re: Borg vs Singleton vs OddClass

2008-09-28 Thread Lie
On Sep 28, 7:22 am, Miles <[EMAIL PROTECTED]> wrote: > Lie wrote: > > This is probably unrelated to Python, as this is more about design > > pattern. I'm asking your comments about this design pattern that is > > similar in functionality to Singleton and Borg: to share states. > > > I'm thinking ab

Re: str() should convert ANY object to a string without EXCEPTIONS !

2008-09-28 Thread Christian Heimes
Steven D'Aprano wrote: str(b'123') # b prefix is added "b'123'" Perhaps I'm misinterpreting it, but from here it looks to me that str() is doing what repr() used to do, and I'm really not sure that's a good thing. I would have expected that str(b'123') in Python 3 should do the same thing a

Re: Borg vs Singleton vs OddClass

2008-09-28 Thread Lie
On Sep 28, 9:45 am, Steven D'Aprano <[EMAIL PROTECTED] cybersource.com.au> wrote: > On Sat, 27 Sep 2008 11:12:00 -0700, Lie wrote: > > This is probably unrelated to Python, as this is more about design > > pattern. I'm asking your comments about this design pattern that is > > similar in functional

Mechanize and Yahoo HTTPS

2008-09-28 Thread Jett
Has anybody used the mechanize library with a Yahoo site? I am trying to create a program that will download my player's stats from Yahoo's Fantasy Football site but for some reason could not get it to load the login page. When I run the program below, it prints the word "start" and then does not

Re: str() should convert ANY object to a string without EXCEPTIONS !

2008-09-28 Thread Roy Smith
In article <[EMAIL PROTECTED]>, Steven D'Aprano <[EMAIL PROTECTED]> wrote: > from random import randint > ''.join(chr(randint(0, 255)) for i in xrange(len(input))) > > > of course. How else should you get random bytes? :) That a UUOL (Useless Usage Of Len; by analogy to UUOC). This works just

Selective importing and package dependencies

2008-09-28 Thread David Pratt
Hi. I am in the midst of preparing a package to convert between various schemas including orms. The issue is I don't want django, slqalchemy, storm, rdflib etc. as hard dependencies of the package. Each module is a schema to schema conversion. As an example, I have imports for sqlalchemy wi

Music knowledge representation

2008-09-28 Thread Mr.SpOOn
Hi, I'm working on an application to analyse music (melodies, chord sequences etc.) I need classes to represent different musical entities. I'm using a class Note to represent all the notes. Inside it stores the name of the natural version of the note (C, D, E, F...) and an integer to calculate th

******GOD OF GIFTS 4 U*********

2008-09-28 Thread enteringheaven
GOD OF GIFTS Free Animations + Wallpapers + Adsens Tips + Hand Reflexogy + Games + Audio + Videos + Nature Health Tips And Beautiful Pics.. http://www.godofgifts.blogspot.com/ -- http://mail.python.org/mailman/listinfo/python-list

Unable to write % character to a file using writelines() method

2008-09-28 Thread dudeja . rajat
Hi, I'm using the writelines() method to write some lines to a text file. But I'm unable to write the % character to the file using the following format: fdTolFile.writelines("\n\tdiff Not in %s '%' range" %(toleranceInPer)) The second % does not get write to the file and Im getting errors. Pl

Tkinter: scrollbar - unable to scroll the scrollbar if I click on arrow buttons of scroll bars

2008-09-28 Thread dudeja . rajat
Hi, Im using a tkinter scrollbars for horinzontal and vertical scrolling. Well the problem is I'm unable to scroll if I click on the arrows buttons of scrollbars ( with both types of scrollbars) Please suggest if I m missing some configuration. My code is as below: self.hsb = Scrollbar(appGu

Re: Python style: exceptions vs. sys.exit()

2008-09-28 Thread Lie
On Sep 25, 3:05 pm, Bruno Desthuilliers wrote: > Steven D'Aprano a écrit : > > > On Wed, 24 Sep 2008 17:11:28 -0400, Ross Ridge wrote: > > >> Plenty of people were quick to say that the exception should be passed > >> through to the caller.  No one said this behaviour should be documented. > >>  T

destructor not called

2008-09-28 Thread Marcin201
I have a class which uses a temporary directory for storing data. I would like that directory to be removed when the class is no longer used. I have tried removing the temporary directory from the class destructor, however, it was never called. After I while I traced the problem to the class hav

Re: Unable to write % character to a file using writelines() method

2008-09-28 Thread Christian Heimes
[EMAIL PROTECTED] wrote: Hi, I'm using the writelines() method to write some lines to a text file. But I'm unable to write the % character to the file using the following format: fdTolFile.writelines("\n\tdiff Not in %s '%' range" %(toleranceInPer)) Try %% :) Christian -- http://mail.pyth

Re: destructor not called

2008-09-28 Thread Szabolcs Ferenczi
On Sep 28, 6:00 pm, Marcin201 <[EMAIL PROTECTED]> wrote: > I have a class which uses a temporary directory for storing data.  I > would like that directory to be removed when the class is no longer > used.  I have tried removing the temporary directory from the class > destructor, however, it was n

Re: destructor not called

2008-09-28 Thread Roy Smith
In article <[EMAIL PROTECTED]>, Marcin201 <[EMAIL PROTECTED]> wrote: > I have a class which uses a temporary directory for storing data. I > would like that directory to be removed when the class is no longer > used. I have tried removing the temporary directory from the class > destructor, ho

Re: Unable to write % character to a file using writelines() method

2008-09-28 Thread dudeja . rajat
On Sun, Sep 28, 2008 at 5:51 PM, Christian Heimes <[EMAIL PROTECTED]> wrote: > [EMAIL PROTECTED] wrote: > >> Hi, >> >> >> I'm using the writelines() method to write some lines to a text file. But >> I'm unable to write the % character to the file using the following >> format: >> >> fdTolFile.writ

Re: destructor not called

2008-09-28 Thread Michel Leunen
Marcin201 a écrit : class Foo: def __init__(self): print "Hello" self.f = self.fxn Maybe self.f = self.fxn() is what you want. Note the '()'. -- Michel Leunen http://linux.leunen.com -- http://mail.python.org/mailman/listinfo/python-list

Python 3.0 and repr

2008-09-28 Thread Mark Tolonen
I don't understand the behavior of the interpreter in Python 3.0. I am working at a command prompt in Windows (US English), which has a terminal encoding of cp437. In Python 2.5: Python 2.5 (r25:51908, Sep 19 2006, 09:52:17) [MSC v.1310 32 bit (Intel)] on win 32 Type "help", "copyr

parsing a site/page that uses/calls javascript functions...

2008-09-28 Thread bruce
Hi... I've got a couple of test apps that I use to parse/test different html webpages. However, I'm now looking at how to parse a given site/page that uses javascript calls to dynamically create/display the resulting HTML. I can see the HTML is the Browser page if I manually select the btn that i

urllib2 and exceptions

2008-09-28 Thread robean
Hi everyone, I have a question about using urllib2. I like urllib2 better than urllib at least in part because it has more elaborate support for handling errors: there is built in support for URLError (for faulty urls) and HTTPError (for http errors that might originate from, say, passing an inva

Re: destructor not called

2008-09-28 Thread George Sakkis
On Sep 28, 12:00 pm, Marcin201 <[EMAIL PROTECTED]> wrote: > I have a class which uses a temporary directory for storing data.  I > would like that directory to be removed when the class is no longer > used.  I have tried removing the temporary directory from the class > destructor, however, it was

What is not objects in Python?

2008-09-28 Thread process
I have heard some criticism about Python, that it is not fully object- oriented. What is not an object in Python? Why isn't len implemented as a str.len and list.len method instead of a len(list) function? -- http://mail.python.org/mailman/listinfo/python-list

Re: What is not objects in Python?

2008-09-28 Thread Christian Heimes
process wrote: What is not an object in Python? Everything that is not part of Python's syntax is an object, including all string and number types, classes, metaclasses, functions, models, code and more. It's technically not possible to have something like e.g. an int that isn't an object.

Re: What is not objects in Python?

2008-09-28 Thread Tino Wildenhain
Hi, process wrote: I have heard some criticism about Python, that it is not fully object- oriented. Don't listen to the voices... ;) What is not an object in Python? Why isn't len implemented as a str.len and list.len method instead of a len(list) function? So you also want to write 1+2

Re: closures and dynamic binding

2008-09-28 Thread Aaron "Castironpi" Brady
On Sep 28, 2:52 am, Steven D'Aprano <[EMAIL PROTECTED] cybersource.com.au> wrote: > On Sat, 27 Sep 2008 21:43:15 -0700, Aaron \"Castironpi\" Brady wrote: > > Hello all, > > > To me, this is a somewhat unintuitive behavior.  I want to discuss the > > parts of it I don't understand. > > f= [ Non

Re: Music knowledge representation

2008-09-28 Thread Aaron "Castironpi" Brady
On Sep 28, 9:37 am, Mr.SpOOn <[EMAIL PROTECTED]> wrote: > Hi, > I'm working on an application to analyse music (melodies, chord sequences > etc.) > > I need classes to represent different musical entities. I'm using a > class Note to represent all the notes. Inside it stores the name of > the natu

Re: How to read a jpg bytearray from a Flash AS3 file

2008-09-28 Thread rsgalloway
Thanks! I'm using form = cgi.FieldStorage(). When I print out the contents of form, I get this: FieldStorage(None, None, '\xff\xd8\xff\xe0\x00\x10JFIF \x00\x01\x01\x00\x00\x01\x00\x01\x00\x00\xff\xdb \x00\x84\x00\x05\x03\x04\x04\x04\x03\x05\x04\x04\x04\x05\x05\x05\x06\x07\x0c \x08\x07\x07\x07

Re: Music knowledge representation

2008-09-28 Thread Mr.SpOOn
On Sun, Sep 28, 2008 at 8:59 PM, Aaron Castironpi Brady <[EMAIL PROTECTED]> wrote: > Here is a link to someone else's design they asked about on the > newsgroup a couple weeks ago. > > http://groups.google.com/group/comp.lang.python/browse_thread/thread/ecffaa827984866d/921cba3084b984dc?lnk=st&q=s

ANN: wxPython 2.8.9.0

2008-09-28 Thread Robin Dunn
Announcing -- The 2.8.9.0 release of wxPython is now available for download at http://wxpython.org/download.php. This release adds support for using Cairo for drawing on wx windows, adds a Win64 build, and various other fixes and enhancements. Source code is available, as well as binar

Re: What is not objects in Python?

2008-09-28 Thread Lie
On Sep 29, 1:29 am, process <[EMAIL PROTECTED]> wrote: > I have heard some criticism about Python, that it is not fully object- > oriented. > > What is not an object in Python? > > Why isn't len implemented as a str.len and list.len method instead of > a len(list) function? A question like this is

Re: urllib2 and exceptions

2008-09-28 Thread Chris Rebert
On Sun, Sep 28, 2008 at 11:03 AM, robean <[EMAIL PROTECTED]> wrote: > Hi everyone, > > I have a question about using urllib2. > > I like urllib2 better than urllib at least in part because it has more > elaborate support for handling errors: there is built in support for > URLError (for faulty urls

Re: how to replace and string in a "SELECT ... IN ()"

2008-09-28 Thread Michael Mabin
Tino, dude, I'm afraid I lied about my previous post being the last word. There are some things you said here that must be addressed. On Sun, Sep 28, 2008 at 6:00 AM, Tino Wildenhain <[EMAIL PROTECTED]> wrote: > Michael Mabin wrote: > >> I'm exhausted, so I'll just shut up about this after a few

Re: What is not objects in Python?

2008-09-28 Thread Terry Reedy
process wrote: I have heard some criticism about Python, that it is not fully object- oriented. Feel free to ignore it if you wish. What is not an object in Python? Depends on what you mean by 'in'. Python is a language for defining and manipulating information objects. Code 'in' Python

standalone buildbot possible/ don't have a remote

2008-09-28 Thread mark
I want to start small and setup a buildbot on one machine (no slaves). I hope this is possible. I assume I only need one master in this case (without slave config)??? from my master.cfg c['slaves'] = [] ... (rest of the sample config) b1 = {'name': "buildbot-full", # 'slavename': "bot1name"

Re: Selective importing and package dependencies

2008-09-28 Thread Chris Rebert
On Sun, Sep 28, 2008 at 7:10 AM, David Pratt <[EMAIL PROTECTED]> wrote: > Hi. I am in the midst of preparing a package to convert between various > schemas including orms. The issue is I don't want django, slqalchemy, storm, > rdflib etc. as hard dependencies of the package. Each module is a schema

Re: Music knowledge representation

2008-09-28 Thread Mark Tolonen
"Mr.SpOOn" <[EMAIL PROTECTED]> wrote in message news:[EMAIL PROTECTED] On Sun, Sep 28, 2008 at 8:59 PM, Aaron Castironpi Brady <[EMAIL PROTECTED]> wrote: Here is a link to someone else's design they asked about on the newsgroup a couple weeks ago. http://groups.google.com/group/comp.lang.pyt

Re: Music knowledge representation

2008-09-28 Thread Aaron "Castironpi" Brady
On Sep 28, 2:08 pm, Mr.SpOOn <[EMAIL PROTECTED]> wrote: > On Sun, Sep 28, 2008 at 8:59 PM, Aaron Castironpi Brady > > <[EMAIL PROTECTED]> wrote: > > Here is a link to someone else's design they asked about on the > > newsgroup a couple weeks ago. > > >http://groups.google.com/group/comp.lang.python

Re: urllib2 and exceptions

2008-09-28 Thread robean
On Sep 28, 12:11 pm, "Chris Rebert" <[EMAIL PROTECTED]> wrote: > On Sun, Sep 28, 2008 at 11:03 AM, robean <[EMAIL PROTECTED]> wrote: > > Hi everyone, > > > I have a question about using urllib2. > > > I like urllib2 better than urllib at least in part because it has more > > elaborate support for h

Re: urllib2 and exceptions

2008-09-28 Thread robean
On Sep 28, 12:27 pm, robean <[EMAIL PROTECTED]> wrote: > On Sep 28, 12:11 pm, "Chris Rebert" <[EMAIL PROTECTED]> wrote: > > > > > On Sun, Sep 28, 2008 at 11:03 AM, robean <[EMAIL PROTECTED]> wrote: > > > Hi everyone, > > > > I have a question about using urllib2. > > > > I like urllib2 better than

generate random digits with length of 5

2008-09-28 Thread sotirac
Wondering if there is a better way to generate string of numbers with a length of 5 which also can have a 0 in the front of the number. random_number = random.sample([0,1,2,3,4,5,6,7,8,9], 5) # choose 5 elements code = 'this is a string' + str(random_number[0]) + str(random_number[1]) + str(ra

Re: generate random digits with length of 5

2008-09-28 Thread Chris Rebert
On Sun, Sep 28, 2008 at 12:59 PM, sotirac <[EMAIL PROTECTED]> wrote: > Wondering if there is a better way to generate string of numbers with > a length of 5 which also can have a 0 in the front of the number. > > > > random_number = random.sample([0,1,2,3,4,5,6,7,8,9], 5) # choose 5 > elements >

Re: What is not objects in Python?

2008-09-28 Thread bearophileHUGS
Terry Reedy: > Partly history and partly practicality. Len is implemented as .__len__ > ;-). The len function is one, __len__ methods are many. If you want to > pass an argument to a function, passing len is easier that passing > operator.attrgetter('__len__'). Passing '__len__' (or 'len') woul

Re: generate random digits with length of 5

2008-09-28 Thread Aaron "Castironpi" Brady
On Sep 28, 2:59 pm, sotirac <[EMAIL PROTECTED]> wrote: > Wondering if there is a better way to generate string of numbers with > a length of 5 which also can have a 0 in the front of the number. > > >  random_number = random.sample([0,1,2,3,4,5,6,7,8,9], 5) # choose 5 > elements >  code = 'this is

Re: how to replace and string in a "SELECT ... IN ()"

2008-09-28 Thread Steve Holden
Michael Mabin wrote: > Tino, dude, I'm afraid I lied about my previous post being the last > word. There are some things you said here that must be addressed. Good grief, is there no utterance so inconsequential that you will walk away from it without yet another round of retaliation? I believe

Re: generate random digits with length of 5

2008-09-28 Thread Gary M. Josack
Chris Rebert wrote: On Sun, Sep 28, 2008 at 12:59 PM, sotirac <[EMAIL PROTECTED]> wrote: Wondering if there is a better way to generate string of numbers with a length of 5 which also can have a 0 in the front of the number. random_number = random.sample([0,1,2,3,4,5,6,7,8,9], 5) # choose

Re: generate random digits with length of 5

2008-09-28 Thread Gary M. Josack
Aaron "Castironpi" Brady wrote: On Sep 28, 2:59 pm, sotirac <[EMAIL PROTECTED]> wrote: Wondering if there is a better way to generate string of numbers with a length of 5 which also can have a 0 in the front of the number. random_number = random.sample([0,1,2,3,4,5,6,7,8,9], 5) # choose 5

Re: generate random digits with length of 5

2008-09-28 Thread bearophileHUGS
sotirac: > random_number = random.sample([0,1,2,3,4,5,6,7,8,9], 5) # choose 5 elements But note that's without replacement. So if you want really random numbers you can do this: >>> from string import digits >>> from random import choice >>> "".join(choice(digits) for d in xrange(5)) '93898' If

Re: generate random digits with length of 5

2008-09-28 Thread Gary M. Josack
Gary M. Josack wrote: Aaron "Castironpi" Brady wrote: On Sep 28, 2:59 pm, sotirac <[EMAIL PROTECTED]> wrote: Wondering if there is a better way to generate string of numbers with a length of 5 which also can have a 0 in the front of the number. random_number = random.sample([0,1,2,3,4,5,6,

Re: What is not objects in Python?

2008-09-28 Thread [EMAIL PROTECTED]
On Sep 28, 2:29 pm, process <[EMAIL PROTECTED]> wrote: > I have heard some criticism about Python, that it is not fully object- > oriented. > > What is not an object in Python? > Parts of the syntax aren't objects. e.g. "=" or ":" aren't objects. Unlike in some less fully OO-languages (e.g. Java

Re: is decorator the right thing to use?

2008-09-28 Thread Dmitry S. Makovey
George Sakkis wrote: > FYI, in case you missed it the final version doesn't need a Proxy base > class, just inherit from object. Also lowercased ProxyMethod to look > similar to staticmethod/classmethod: I cought that, just quoted the wrong one :) > class A(object): > > def __init__(self, b1

Re: generate random digits with length of 5

2008-09-28 Thread Mensanator
On Sep 28, 3:11�pm, "Gary M. Josack" <[EMAIL PROTECTED]> wrote: > Chris Rebert wrote: > > On Sun, Sep 28, 2008 at 12:59 PM, sotirac <[EMAIL PROTECTED]> wrote: > > >> Wondering if there is a better way to generate string of numbers with > >> a length of 5 which also can have a 0 in the front of the

Re: Not fully OO ?

2008-09-28 Thread Bruno Desthuilliers
Tim Rowe a écrit : 2008/9/26 Bruno Desthuilliers <[EMAIL PROTECTED]>: Not to start a troll, but from what I've seen of C# so far I do find this a bit surprising and really suspect more of a library issue than a language one. Care to tell more about the problem and solution ? (NB : I wouldn't e

Re: generate random digits with length of 5

2008-09-28 Thread Aaron "Castironpi" Brady
On Sep 28, 3:44 pm, Mensanator <[EMAIL PROTECTED]> wrote: > On Sep 28, 3:11 pm, "Gary M. Josack" <[EMAIL PROTECTED]> wrote: > > > > > Chris Rebert wrote: > > > On Sun, Sep 28, 2008 at 12:59 PM, sotirac <[EMAIL PROTECTED]> wrote: > > > >> Wondering if there is a better way to generate string of numb

Re: generate random digits with length of 5

2008-09-28 Thread Tim Chase
Wondering if there is a better way to generate string of numbers with a length of 5 which also can have a 0 in the front of the number. If you want to resample the same digit multiple times, either of these two will do: >>> from random import choice >>> ''.join(str(choice(range(10))) for _ in

Re: generate random digits with length of 5

2008-09-28 Thread Michael Ströder
Gary M. Josack wrote: > Aaron "Castironpi" Brady wrote: >> On Sep 28, 2:59 pm, sotirac <[EMAIL PROTECTED]> wrote: >> >>> Wondering if there is a better way to generate string of numbers with >>> a length of 5 which also can have a 0 in the front of the number. >>> >>> >>> random_number = random

Re: Why are "broken iterators" broken?

2008-09-28 Thread Lie
On Sep 21, 10:13 pm, Steven D'Aprano <[EMAIL PROTECTED] cybersource.com.au> wrote: > According to the Python docs, once an iterator raises StopIteration, it > should continue to raise StopIteration forever. Iterators that fail to > behave in this fashion are deemed to be "broken": > > http://docs.p

Re: generate random digits with length of 5

2008-09-28 Thread Aaron "Castironpi" Brady
On Sep 28, 4:08 pm, Michael Ströder <[EMAIL PROTECTED]> wrote: > Gary M. Josack wrote: > > Aaron "Castironpi" Brady wrote: > >> On Sep 28, 2:59 pm, sotirac <[EMAIL PROTECTED]> wrote: > > >>> Wondering if there is a better way to generate string of numbers with > >>> a length of 5 which also can hav

Re: Hello boys!

2008-09-28 Thread Cydrome Leader
In rec.crafts.metalworking default <[EMAIL PROTECTED]> wrote: > On Sat, 27 Sep 2008 23:12:59 + (UTC), Cydrome Leader > <[EMAIL PROTECTED]> wrote: > >>In rec.crafts.metalworking Jim Thompson <[EMAIL PROTECTED]> wrote: >>> >>> On Sat, 27 Sep 2008 18:47:16 -0400, default <[EMAIL PROTECTED]> >>>

Re: how to replace and string in a "SELECT ... IN ()"

2008-09-28 Thread Tino Wildenhain
Michael Mabin wrote: Tino, dude, I'm afraid I lied about my previous post being the last word. There are some things you said here that must be addressed. Well. Its interesting to see thats either my English is so bad you don't understand or you are too tired. All what needs to be said was sai

Re: Not fully OO ?

2008-09-28 Thread Tim Rowe
2008/9/28 Aaron Castironpi Brady <[EMAIL PROTECTED]>: > Before I tried wxFormBuilder, I imagined that C# would be vastly > faster to develop than Python, for anything requiring any non-trivial > graphical interface. I've done extensive VB, so I can attest to that > personally. It is not. I'm co

Re: What is not objects in Python?

2008-09-28 Thread Tim Rowe
2008/9/28 process <[EMAIL PROTECTED]>: > I have heard some criticism about Python, that it is not fully object- > oriented. Why is that a criticism? OO is a tool, not a religion (ok, ok, OO *should be* a tool, not a religion). Is it a criticism of a hammer that it is not a screwdriver? Or do you p

Re: closures and dynamic binding

2008-09-28 Thread Terry Reedy
Aaron "Castironpi" Brady wrote: On Sep 28, 2:52 am, Steven D'Aprano <[EMAIL PROTECTED] As for why the complicated version works, it may be clearer if you expand it from a one-liner: # expand: f[ n ]= (lambda n: ( lambda: n ) )( n ) inner = lambda: n outer = lambda n: inner f[n] = outer(n) o

Re: What is not objects in Python?

2008-09-28 Thread Bruno Desthuilliers
process a écrit : I have heard some criticism about Python, that it is not fully object- oriented. What is not an object in Python? names and statements. Why isn't len implemented as a str.len and list.len method instead of a len(list) function? See other answers here about how the len(obj

Re: Python 3.0 and repr

2008-09-28 Thread Martin v. Löwis
> What are others' opinions? Any insight to this design decision? The intention is that all printable characters in a string get displayed in repr. This was in particular requested by Japanese users (but also by other users of non-ASCII characters) which complained that repr() is fairly useless i

Re: generate random digits with length of 5

2008-09-28 Thread Mensanator
On Sep 28, 3:54�pm, "Aaron \"Castironpi\" Brady" <[EMAIL PROTECTED]> wrote: > On Sep 28, 3:44�pm, Mensanator <[EMAIL PROTECTED]> wrote: > > > > > > > On Sep 28, 3:11 pm, "Gary M. Josack" <[EMAIL PROTECTED]> wrote: > > > > Chris Rebert wrote: > > > > On Sun, Sep 28, 2008 at 12:59 PM, sotirac <[EMAIL

Re: generate random digits with length of 5

2008-09-28 Thread Mensanator
On Sep 28, 4:02�pm, Tim Chase <[EMAIL PROTECTED]> wrote: > > Wondering if there is a better way to generate string of numbers with > > a length of 5 which also can have a 0 in the front of the number. > > If you want to resample the same digit multiple times, either of these > two will do: > > �>>>

Re: generate random digits with length of 5

2008-09-28 Thread bearophileHUGS
Tim Chase: > I suspect that the zfill responses don't have the property of equally > distributed "randomness", as the first digit may more likely be a zero. This code I have shown before: str(randrange(10)).zfill(5) If the numbers are equally distributed in [0, 9], then the leading zeros

rlcompleter and wxPython, problems ...

2008-09-28 Thread Stef Mientki
hello, I'm trying to implement autocompletion into my editor. But I find some weird behavior, or at least I don't have the faintest idea why this behavior occures, and even more important how to solve it In the example below I try to autocomplete " wx.s" , which in my humble opinion should at

Web programming in Python.

2008-09-28 Thread Kurda Yon
Hi, I am totaly newbie in the Python's web programming. So, I dont even know the basic conceptions (but I have ideas about php-web- programming). Does it work in a similar way? First, I have to install a Python-server? On the server where I have my web site (it runs under Linux) if I type "python

privatdetektei detektei central privat detektei frankfurt private detective privatdetektiv in berlin

2008-09-28 Thread webilix950
privatdetektei detektei central privat detektei frankfurt private detective privatdetektiv in berlin + + + + +++ DETEKTEIEN DETEKTIVE ONLINE +++ DETEKTEI HAMBURG +++ PRIVATDETEKTIVE +++ + + http://WWW.DETEKTEI-DETEKTIV.NET http://WWW.DETEKTEI-DETEKTIV.NET http://WWW.DETEKTEI-DETEKTIV.NET http://WW

Milenko Kindl tterter

2008-09-28 Thread sdsdvfsdf
WASHINGTON - Congressional leaders and the White House agreed Sunday to a $700 billion rescue of the ailing financial industry after lawmakers insisted on sharing spending controls with the Bush administration. The biggest U.S. bailout in history won the tentative support of both presidential candi

Re: closures and dynamic binding

2008-09-28 Thread Steven D'Aprano
On Sun, 28 Sep 2008 17:47:44 -0400, Terry Reedy wrote: > Aaron "Castironpi" Brady wrote: >> On Sep 28, 2:52 am, Steven D'Aprano <[EMAIL PROTECTED] > >>> As for why the complicated version works, it may be clearer if you >>> expand it from a one-liner: >>> >>> # expand: f[ n ]= (lambda n: ( lambda

Re: closures and dynamic binding

2008-09-28 Thread Aaron "Castironpi" Brady
On Sep 28, 4:47 pm, Terry Reedy <[EMAIL PROTECTED]> wrote: > Aaron "Castironpi" Brady wrote: > > On Sep 28, 2:52 am, Steven D'Aprano <[EMAIL PROTECTED] > >> As for why the complicated version works, it may be clearer if you expand > >> it from a one-liner: > > >> # expand: f[ n ]= (lambda n: ( lamb

Re: str() should convert ANY object to a string without EXCEPTIONS !

2008-09-28 Thread Lawrence D'Oliveiro
In message <[EMAIL PROTECTED]>, est wrote: > Well, you succeseded in putting all blame to myself alone. Great. Take it as a hint. > When you guy's are dealing with CJK characters in the future, you'll > find out what I mean. Speaking as somebody who HAS dealt with CJK characters in the past--se

  1   2   >