python gtk: input box and "enter"

2009-12-22 Thread edgue
Hello there, I am somewhat fluent in python ... good enough for the daily business scripting stuff. I have a little script that I use to start the afs service on my machine and to collect tokens for multiple afs cells. I want to enter the password using a GUI window (stdin in a terminal window is

Re: Ironpython

2009-12-22 Thread Michel Claveau - MVP
Hi! IronPython is an implementation of Python. IMO, this group talk about all Pythons. Therefore, for me, this group is OK. -- Michel Claveau -- http://mail.python.org/mailman/listinfo/python-list

Retrieving exception value in C

2009-12-22 Thread swapnil
I am trying to retrieve the value of the exception (the message part) raised in python, in C. Running the below script, import shutil fd= open("testfile","w") fd.write("some junk") fd.close() shutil.copy("testfile","testfile") will generate an exception like this, Traceback (most recent call la

Re: syntax error : first python program

2009-12-22 Thread Ben Finney
pradeep writes: > #!/usr/bin/env python > name = "blah" > print name These two lines are indented, but are not inside a block. > bash# /usr/bin/python sample.py > File "sample.py", line 2 > name = "blah" > ^ > SyntaxError: invalid syntax Indentation is syntax in Python. > An

Re: syntax error : first python program

2009-12-22 Thread Erik Max Francis
pradeep wrote: I have this file in linux === sample.py #!/usr/bin/env python name = "blah" print name ... Any one knows , whats the syntax error here? You're indenting for no reason. -- Erik Max Francis && m...@alcyone.com && http://www.alcyone.com/max/ San Jos

syntax error : first python program

2009-12-22 Thread pradeep
I have this file in linux === sample.py #!/usr/bin/env python name = "blah" print name --- I executed this bash# ./sample.py File "./sample.py", line 2 name = "blah" ^ bash# /usr/bin/python sample.py File "sample.py", line

Re: ScrolledText get xy index of rowheader component?

2009-12-22 Thread J Wolfe
Nevermind I figured it out... I set self.dummyvar = self.scrolledtext.component('rowheader') and then did something like so self.dummyvar.index("@%d,%d" % (event.x,event.y)) not sure why it worked like that...but it did :-) -- http://mail.python.org/mailman/listinfo/python-list

Re: lib2to3 pattern creation with unexpected results

2009-12-22 Thread Benjamin Peterson
Zac Burns gmail.com> writes: > I'm trying to match any function block, the two examples were just a part of my unit tests.   I know. I was just giving an example to indicate why it doesn't work. find_pattern.py is useful because it gives you a base from which it's easy to extrapolate the genera

Re: Python (and me) getting confused finding keys

2009-12-22 Thread Alf P. Steinbach
* Steven D'Aprano: [snip] The obvious follow-up is to ask how to make an immutable class. http://northernplanets.blogspot.com/2007/01/immutable-instances-in-python.html Thanks, I've been wondering about that. By the way, the link at the bottom in the article you linked to, referring to an

Re: How to run python script in emacs

2009-12-22 Thread Pedro Insua
On Wed, Nov 25, 2009 at 09:38:54AM -0800, doug wrote: > > When I type C-c C-c my emacs window just hangs. If I use Task Manager > to kill cmdproxy I can get emacs back but of course interactivity with > Python is not accomplished. By the way, if I do C-c ! then I get a > functional python shell.

Re: lib2to3 pattern creation with unexpected results

2009-12-22 Thread Zac Burns
On Tue, Dec 22, 2009 at 3:21 PM, Benjamin Peterson wrote: > > The pattern for that is funcdef< 'def' 'singleLineFunc' parameters< '(' ')' > > > ':' simple_stmt< return_stmt< 'return' arith_expr< '1' '+' '2' > > '\n' > > >. No > suite. > > I'm trying to match any function block, the two examples we

Re: dict initialization

2009-12-22 Thread MRAB
mattia wrote: Il Tue, 22 Dec 2009 23:09:04 +0100, Peter Otten ha scritto: mattia wrote: Is there a function to initialize a dictionary? Right now I'm using: d = {x+1:[] for x in range(50)} Is there any better solution? There is a dictionary variant that you don't have to initialize: from co

Re: Strange Problem

2009-12-22 Thread MRAB
Victor Subervi wrote: Hi; I have the following code: print 'printTheForm: ', descrProds, '' for value in descrProds: print 'value: ', value, '' which prints this: printTheForm: [['ID', 'tinyint', '5', '0', None], ['SKU', 'varchar', '40', '', None], ['Category', 'varchar', '40', '',

Re: dict initialization

2009-12-22 Thread Jon Clements
On Dec 22, 11:51 pm, mattia wrote: > Il Tue, 22 Dec 2009 23:09:04 +0100, Peter Otten ha scritto: > > > mattia wrote: > > >> Is there a function to initialize a dictionary? Right now I'm using: > >> d = {x+1:[] for x in range(50)} > >> Is there any better solution? > > > There is a dictionary varia

Re: Line indexing in Python

2009-12-22 Thread MRAB
Lie Ryan wrote: On 12/22/2009 11:25 PM, Steve Holden wrote: > > If you want to extract an index number from the first part of of a given > line use split( split_character, maximum_splits_to_do ) and then angle > brackets to reference the first part (index 0)... > > a = "20 GOTO 10"

Re: dict initialization

2009-12-22 Thread mattia
Il Tue, 22 Dec 2009 23:09:04 +0100, Peter Otten ha scritto: > mattia wrote: > >> Is there a function to initialize a dictionary? Right now I'm using: >> d = {x+1:[] for x in range(50)} >> Is there any better solution? > > There is a dictionary variant that you don't have to initialize: > > from

Re: Python-list Digest, Vol 75, Issue 226

2009-12-22 Thread Gabriel Genellina
En Tue, 22 Dec 2009 16:30:58 -0300, r0g escribió: Gabriel Genellina wrote: En Mon, 21 Dec 2009 16:30:13 -0300, Pulkit Agrawal escribió: I am writing a script wherein I need to merge files into existing tar.gz files. Currently, I am using tarfile module. I extract the tar.gz to a tempdir a

Re: OS independent way to check if a python app is running?

2009-12-22 Thread Hans Mulder
Dan Sommers wrote: On Mon, 14 Dec 2009 14:14:05 -0500, python wrote: Is there an os independent way to check if a python app is running? Goal: I have a server program based on cherrypy that I only want to have running once. If a system administrator accidentally attempts to run this program mo

Re: lib2to3 pattern creation with unexpected results

2009-12-22 Thread Benjamin Peterson
Zac Burns gmail.com> writes: > > > Greetings,I'm trying to re-purpose the lib2to3 module and along the way came up with this pattern:"funcdef<'def' name=NAME parameters ['->' test] ':' suite=suite>"It seems to have 2 problems: > > Single-line defs are not matched. Eg: "def singleLineFunc(): re

Re: Python (and me) getting confused finding keys

2009-12-22 Thread Steven D'Aprano
On Tue, 22 Dec 2009 17:33:04 +0100, John wrote: > Hi there, > > I have a rather lengthy program that troubles me for quite some time. > After some debugging, I arrived at the following assertion error: > > for e in edges.keys(): > assert edges.has_key(e) > > Oops!? Is there ANY way that s

Re: dict initialization

2009-12-22 Thread mattia
Il Tue, 22 Dec 2009 23:09:04 +0100, Peter Otten ha scritto: > mattia wrote: > >> Is there a function to initialize a dictionary? Right now I'm using: >> d = {x+1:[] for x in range(50)} >> Is there any better solution? > > There is a dictionary variant that you don't have to initialize: > > from

Re: Python (and me) getting confused finding keys

2009-12-22 Thread Steven D'Aprano
On Tue, 22 Dec 2009 17:47:14 +0100, Christian Heimes wrote: > John schrieb: >> Hi there, >> >> I have a rather lengthy program that troubles me for quite some time. >> After some debugging, I arrived at the following assertion error: >> >> for e in edges.keys(): >> assert edges.has_key(e) >

Re: dict initialization

2009-12-22 Thread Peter Otten
mattia wrote: > Is there a function to initialize a dictionary? > Right now I'm using: > d = {x+1:[] for x in range(50)} > Is there any better solution? There is a dictionary variant that you don't have to initialize: from collections import defaultdict d = defaultdict(list) Peter -- http://ma

Re: Strange Problem

2009-12-22 Thread Dave Angel
Victor Subervi wrote: Hi; I have the following code: print 'printTheForm: ', descrProds, '' for value in descrProds: print 'value: ', value, '' which prints this: printTheForm: [['ID', 'tinyint', '5', '0', None], ['SKU', 'varchar', '40', '', None], ['Category', 'varchar', '40', '', Non

Re: dict initialization

2009-12-22 Thread Mark Tolonen
"mattia" wrote in message news:4b313b3a$0$1135$4fafb...@reader1.news.tin.it... Is there a function to initialize a dictionary? Right now I'm using: d = {x+1:[] for x in range(50)} Is there any better solution? Depending on your use case, a defaultdict might suite you: from collections impo

Re: dict initialization

2009-12-22 Thread Irmen de Jong
On 22-12-2009 22:33, mattia wrote: Is there a function to initialize a dictionary? Right now I'm using: d = {x+1:[] for x in range(50)} Is there any better solution? Maybe you can use: dict.fromkeys(xrange(1,51)) but this will initialize all values to None instead of an empty list... -

Re: dict initialization

2009-12-22 Thread Emile van Sebille
On 12/22/2009 1:33 PM mattia said... Is there a function to initialize a dictionary? Right now I'm using: d = {x+1:[] for x in range(50)} Is there any better solution? I tend to use setdefault and fill in as I go, but if you need to have a complete 50-element dict from the get go, I'd probably

Re: dict initialization

2009-12-22 Thread Robert Kern
On 2009-12-22 15:33 PM, mattia wrote: Is there a function to initialize a dictionary? Right now I'm using: d = {x+1:[] for x in range(50)} Is there any better solution? For things like this? No. If you find yourself writing this pattern frequently, though, you can wrap it up in a function and

dict initialization

2009-12-22 Thread mattia
Is there a function to initialize a dictionary? Right now I'm using: d = {x+1:[] for x in range(50)} Is there any better solution? -- http://mail.python.org/mailman/listinfo/python-list

Re: Problem with win32ui

2009-12-22 Thread Mike Driscoll
On Dec 22, 11:05 am, "Gabriel Genellina" wrote: > En Tue, 22 Dec 2009 12:31:37 -0300, Marc Grondin   > escribió: > > > Hello everyone, > > So i have been building an app with python(and learning as i go along) my > > knowledge of python is still kinda limited but the app work on my pc. I   > > ha

Re: Python (and me) getting confused finding keys

2009-12-22 Thread Terry Reedy
On 12/22/2009 11:33 AM, John wrote: Hi there, I have a rather lengthy program that troubles me for quite some time. After some debugging, I arrived at the following assertion error: for e in edges.keys(): assert edges.has_key(e) If you are claiming that the above *did* raise Assertion

Re: Strange Problem

2009-12-22 Thread Emile van Sebille
On 12/22/2009 10:57 AM Victor Subervi said... Hi; I have the following code: print 'printTheForm: ', descrProds, '' This doesn't match what you say the below is the output from. There's no below... for value in descrProds: print 'value: ', value, '' When I assign your result la

Re: RotatingFileHandler key error when parsing a logging config file

2009-12-22 Thread Vinay Sajip
On Dec 21, 9:33 pm, jordilin wrote: > Hi, >  I've a config forloggingwhere I set up a file rotation with > handlers.RotatingFileHandler and when the app parses thelogging > config it says keyError when trying to parse that section > ('RotatingFileHandler' is not defined). Curiously enough, I can d

Re: Line indexing in Python

2009-12-22 Thread r0g
Steve Holden wrote: > r0g wrote: >> seafoid wrote: >>> Hi Guys, >>> >>> When python reads in a file, can lines be referred to via an index? >>> >>> Example: >>> >>> for line in file: >>> if line[0] == '0': >>> a.write(line) >>> >>> This works, however, I am unsure if line[0] refers on

Re: Python-list Digest, Vol 75, Issue 226

2009-12-22 Thread r0g
Gabriel Genellina wrote: > En Mon, 21 Dec 2009 16:30:13 -0300, Pulkit Agrawal > escribió: > >> I am writing a script wherein I need to merge files into existing tar.gz >> files. Currently, I am using tarfile module. I extract the tar.gz to a >> tempdir and copy the new file there and re-compress

Re: Problem with win32ui

2009-12-22 Thread Marc Grondin
ok so that got me a little further. The app now works on win2k but on winXP i get this: File "printorders.py", line 2, in File "win32ui.pyc", line 12, in File "win32ui.pyc", line 10, in __load ImportError: DLL load failed: This application has failed to start because the a pplication config

Re: C Structure rebuild with ctypes

2009-12-22 Thread Mark Tolonen
"Georg" wrote in message news:7pb8ubfll...@mid.individual.net... Hi Mark, many thanks for your valuable help. # numVars contains size of returned arrays. Recast to access. varNamesArray = c.cast(varNames,c.POINTER(PCHAR * numVars.value)) varTypesArray = c.cast(varTypes,c.POINTER(INT * numV

Strange Problem

2009-12-22 Thread Victor Subervi
Hi; I have the following code: print 'printTheForm: ', descrProds, '' for value in descrProds: print 'value: ', value, '' which prints this: printTheForm: [['ID', 'tinyint', '5', '0', None], ['SKU', 'varchar', '40', '', None], ['Category', 'varchar', '40', '', None], ['Name', 'varchar',

Re: Python (and me) getting confused finding keys

2009-12-22 Thread Lie Ryan
On 12/23/2009 3:33 AM, John wrote: Hi there, I have a rather lengthy program that troubles me for quite some time. After some debugging, I arrived at the following assertion error: for e in edges.keys(): assert edges.has_key(e) Oops!? Is there ANY way that something like this can possi

Re: Threading with queues

2009-12-22 Thread Lie Ryan
On 12/22/2009 10:47 AM, Gib Bogle wrote: This is indented over one indentation level too much. You want it to be at the same level as the for above. Here, its at the same level with "t" -- meaning this entire loop gets repeated five times. I sorta really recommend a tab width of 4 spaces, not 2

how to read stdout without blocking

2009-12-22 Thread Hamish McKenzie
I need to run a cmd line app from python whose run time can vary from a fraction of a second to minutes. I need to be able to tell whether the process is still waiting, or whether it has stalled - and this is farily easily done by keeping an eye on whether its writing to stdout or not. The pro

Re: Anybody use web2py?

2009-12-22 Thread mdipierro
Some may find useful to compare: - A Crash Course on Django http://articles.sitepoint.com/article/django-crash-course - A Crash Course on Web2py http://www.web2py.com/AlterEgo/default/show/253 They basically describe the same app and the steps to built it. Sorry I had not time to make screenshot

sqlite3 .mode option to create HTML table automatically?

2009-12-22 Thread davidj411
the CLI for sqlite3 shows .mode of "html", which formats the output in HTML format that is good to add to . BUT i have not yet found anything for sqlite in python that does this. in fact, i found an old post saying 'if you want the output in a table, you must create it yourself'. Does anyone kno

Re: Windows, IDLE, __doc_, other

2009-12-22 Thread Lie Ryan
On 12/22/2009 12:06 PM, W. eWatson wrote: Stephen Hansen wrote: On Mon, Dec 21, 2009 at 2:57 PM, W. eWatson wrote: [snip Now, I go to the script and enter from math import * dir is now bulked up with the math functions. I change back math.cos to cos and the program runs well. This sort of fig

Re: Default working directory

2009-12-22 Thread vsoler
On 22 dic, 18:22, "Gabriel Genellina" wrote: > En Tue, 22 Dec 2009 14:04:23 -0300, vsoler   > escribió: > > > I'm using Python 2.6.4 on Windows (Vista & 7) > > > I usually start Python by clicking on Start Menu the Python IDLE > > (Python GUI). > > > However, if I want to save a new source *.py f

Re: Line indexing in Python

2009-12-22 Thread Lie Ryan
On 12/22/2009 11:25 PM, Steve Holden wrote: > > If you want to extract an index number from the first part of of a given > line use split( split_character, maximum_splits_to_do ) and then angle > brackets to reference the first part (index 0)... > > a = "20 GOTO 10" int( a.split('

lib2to3 pattern creation with unexpected results

2009-12-22 Thread Zac Burns
Greetings, I'm trying to re-purpose the lib2to3 module and along the way came up with this pattern: "funcdef<'def' name=NAME parameters ['->' test] ':' suite=suite>" It seems to have 2 problems: 1. Single-line defs are not matched. Eg: "def singleLineFunc(): return 1 + 2" is not matched,

Re: Default working directory

2009-12-22 Thread Gabriel Genellina
En Tue, 22 Dec 2009 14:04:23 -0300, vsoler escribió: I'm using Python 2.6.4 on Windows (Vista & 7) I usually start Python by clicking on Start Menu the Python IDLE (Python GUI). However, if I want to save a new source *.py file, the default directory proposed for saving is not the one that

Re: Python (and me) getting confused finding keys

2009-12-22 Thread Gabriel Genellina
En Tue, 22 Dec 2009 13:56:36 -0300, John escribió: another thread can remove the key prior to the has_key call; or perhaps edges isn't a real dictionary? of course. But unless there is a way of using threading without being aware of it, this is not the case. Also, edges is definitely a di

Re: Default working directory

2009-12-22 Thread Tim Golden
vsoler wrote: I'm using Python 2.6.4 on Windows (Vista & 7) I usually start Python by clicking on Start Menu the Python IDLE (Python GUI). However, if I want to save a new source *.py file, the default directory proposed for saving is not the one that I want. What can I do if I want that the c

Re: Python (and me) getting confused finding keys

2009-12-22 Thread Tim Golden
John wrote: another thread can remove the key prior to the has_key call; or perhaps edges isn't a real dictionary? of course. But unless there is a way of using threading without being aware of it, this is not the case. Also, edges is definitely a dict (has been declared some lines before,

Re: Python (and me) getting confused finding keys

2009-12-22 Thread Zac Burns
On Tue, Dec 22, 2009 at 8:56 AM, John wrote: > > another thread can remove the key prior to the has_key call; or perhaps > > edges isn't a real dictionary? > > > > of course. But unless there is a way of using threading without being aware > of > it, this is not the case. Also, edges is definite

Re: Problem with win32ui

2009-12-22 Thread Gabriel Genellina
En Tue, 22 Dec 2009 12:31:37 -0300, Marc Grondin escribió: Hello everyone, So i have been building an app with python(and learning as i go along) my knowledge of python is still kinda limited but the app work on my pc. I have also compiled it to an exe using py2exe and it also works fine th

Default working directory

2009-12-22 Thread vsoler
I'm using Python 2.6.4 on Windows (Vista & 7) I usually start Python by clicking on Start Menu the Python IDLE (Python GUI). However, if I want to save a new source *.py file, the default directory proposed for saving is not the one that I want. What can I do if I want that the change of default

Re: Python (and me) getting confused finding keys

2009-12-22 Thread John
> another thread can remove the key prior to the has_key call; or perhaps > edges isn't a real dictionary? > of course. But unless there is a way of using threading without being aware of it, this is not the case. Also, edges is definitely a dict (has been declared some lines before, and no ob

Re: OT Question

2009-12-22 Thread Victor Subervi
On Tue, Dec 22, 2009 at 12:08 PM, Emile van Sebille wrote: > On 12/21/2009 10:27 PM Victor Subervi said... > > Hi; >> Back when I worked with Zope, they had this nifty form element where I >> could select from a list of elements on the right and click an arrow to make >> them go into a list on t

Re: Python (and me) getting confused finding keys

2009-12-22 Thread Christian Heimes
John schrieb: > Hi there, > > I have a rather lengthy program that troubles me for quite some time. After > some debugging, I arrived at the following assertion error: > > for e in edges.keys(): > assert edges.has_key(e) > > Oops!? Is there ANY way that something like this can possibly ha

Re: Python (and me) getting confused finding keys

2009-12-22 Thread Tim Golden
John wrote: Hi there, I have a rather lengthy program that troubles me for quite some time. After some debugging, I arrived at the following assertion error: for e in edges.keys(): assert edges.has_key(e) Oops!? Is there ANY way that something like this can possibly happen? Three w

Re: Python (and me) getting confused finding keys

2009-12-22 Thread Robin Becker
On 22/12/2009 16:33, John wrote: Hi there, I have a rather lengthy program that troubles me for quite some time. After some debugging, I arrived at the following assertion error: for e in edges.keys(): assert edges.has_key(e) Oops!? Is there ANY way that something like this can possibl

[no subject]

2009-12-22 Thread jholg
Hi, I need to convert Python decimal.Decimal data to the XMLSchema xs:decimal datatype. This is reasonably straightforward, but there are some corner cases. In particular, xs:decimal does not allow exponential notation like: >>> print Decimal('0.002343000837483727772') 2.343

Python (and me) getting confused finding keys

2009-12-22 Thread John
Hi there, I have a rather lengthy program that troubles me for quite some time. After some debugging, I arrived at the following assertion error: for e in edges.keys(): assert edges.has_key(e) Oops!? Is there ANY way that something like this can possibly happen? Cheers, John -- http:/

Re: OT Question

2009-12-22 Thread Emile van Sebille
On 12/21/2009 10:27 PM Victor Subervi said... Hi; Back when I worked with Zope, they had this nifty form element where I could select from a list of elements on the right and click an arrow to make them go into a list on the left. I need to add this functionality to the store I am creating. Wh

Re: Regex help needed!

2009-12-22 Thread Paul McGuire
On Dec 21, 5:38 am, Oltmans wrote: > Hello,. everyone. > > I've a string that looks something like > > lksjdfls kdjff lsdfs sdjfls =   "amazon_35343433">sdfsdwelcome > > > From above string I need the digits within the ID attribute. For > example, required output from above string is

how to register with pypi - no such setup.py

2009-12-22 Thread Phlip
And the next question in the series - how to make sure the resulting package has a setup.py file? The basic steps are... - build a python package - create a minimal setup.py - (github it, natch) - throw it at pypi with: python setup.py bdist upload - attempt to install it with: sud

Problem with win32ui

2009-12-22 Thread Marc Grondin
Hello everyone, So i have been building an app with python(and learning as i go along) my knowledge of python is still kinda limited but the app work on my pc. I have also compiled it to an exe using py2exe and it also works fine this way on my pc(where python is installed) if however i try to run

Re: How to validate the __init__ parameters

2009-12-22 Thread Lie Ryan
On 12/22/2009 8:52 PM, Bruno Desthuilliers wrote: Steve Holden a écrit : (snip) What's the exact reason for requiring that a creator argument be of a specific type? So operations on the instances don't go wrong? Well, why not just admit that we don't have control over everything, and just *let t

Re: more efficient?

2009-12-22 Thread Zubin Mithra
thank you for your help and support. i`ll keep your advice in mind. :) cheers!!! Zubin On Tue, Dec 22, 2009 at 8:07 PM, Lie Ryan wrote: > On 12/22/2009 5:13 PM, Zubin Mithra wrote: >> >> I have the following two implementation techniques in mind. >> >> def myfunc(mystring): >>     check = "hel

Re: more efficient?

2009-12-22 Thread Lie Ryan
On 12/22/2009 5:13 PM, Zubin Mithra wrote: I have the following two implementation techniques in mind. def myfunc(mystring): check = "hello, there " + mystring + "!!!" print check OR structure = ["hello, there",,"!!!"] def myfunc(mystring): structure[2] = mystring output =

Can I configure Markdown to not wrap my text in elements?

2009-12-22 Thread Stodge
I want to use Markdown to process some text before displaying it in a list. However, Markdown, by default, wraps the resulting text in elements, which screws up my list and displays the list item symbol and text on different lines. Can I stop Markdown from wrapping text in paragraphs elements? Sor

Re: Regex help needed!

2009-12-22 Thread Umakanth
how about re.findall(r'\w+.=\W\D+(\d+)?',str) ? this will work for any string within id ! ~Ukanth On Dec 21, 6:06 pm, Oltmans wrote: > On Dec 21, 5:05 pm, Umakanth wrote: > > > How about re.findall(r'\d+(?:\.\d+)?',str) > > > extracts only numbers from any string > > Thank you. However, I

Clustering technique

2009-12-22 Thread Luca
Dear all, excuse me if i post a simple question.. I am trying to find a software/algorythm that can "cluster" simple data on an excel sheet Example: Variable a Variable b Variable c Case 11 0 0 Case 20 1

Re: which pi formula is given in the decimal module documentation?

2009-12-22 Thread Albert van der Horst
In article <00b967e1$0$15623$c3e8...@news.astraweb.com>, Steven D'Aprano wrote: >Nice work! But I have a question... > >On Mon, 21 Dec 2009 20:40:40 +, Albert van der Horst wrote: > >> def pi4(): >> ' Calculate pi by a 5th order process, with favorable stop >> criterion' >> precis

Re: more efficient?

2009-12-22 Thread Jean-Michel Pichavant
Zubin Mithra wrote: I have the following two implementation techniques in mind. def myfunc(mystring): check = "hello, there " + mystring + "!!!" print check OR structure = ["hello, there",,"!!!"] def myfunc(mystring): structure[2] = mystring output = ''.join(mystring) i heard

Re: How to validate the __init__ parameters

2009-12-22 Thread r0g
Bruno Desthuilliers wrote: > Steve Holden a écrit : > (snip) >> What's the exact reason for requiring that a creator argument be of a >> specific type? So operations on the instances don't go wrong? Well, why >> not just admit that we don't have control over everything, and just *let >> things go w

Re: Line indexing in Python

2009-12-22 Thread Steve Holden
r0g wrote: > seafoid wrote: >> Hi Guys, >> >> When python reads in a file, can lines be referred to via an index? >> >> Example: >> >> for line in file: >> if line[0] == '0': >> a.write(line) >> >> This works, however, I am unsure if line[0] refers only to the first line or >> the fir

Re: RotatingFileHandler key error when parsing a logging config file

2009-12-22 Thread Jean-Michel Pichavant
jordilin wrote: Hi, I've a config for logging where I set up a file rotation with handlers.RotatingFileHandler and when the app parses the logging config it says keyError when trying to parse that section ('RotatingFileHandler' is not defined). Curiously enough, I can do import logging and from

Re: Clustering technique

2009-12-22 Thread Jon Clements
On Dec 22, 11:12 am, Luca wrote: > Dear all, excuse me if i post a simple question.. I am trying to find > a software/algorythm that can "cluster" simple data on an excel sheet > > Example: >                 Variable a   Variable b   Variable c > Case 1        1                   0              0

Re: For...in statement and generators

2009-12-22 Thread Duncan Booth
"Gabriel Genellina" wrote: > En Mon, 21 Dec 2009 11:39:46 -0300, Lucas Prado Melo > escribió: > >> Is there a way to send() information back to a generator while using the >> for...in statement? > > No. You have to write the iteration as a while loop. > You *can* use send() to a generator w

Re: How to validate the __init__ parameters

2009-12-22 Thread Bruno Desthuilliers
Steve Holden a écrit : (snip) What's the exact reason for requiring that a creator argument be of a specific type? So operations on the instances don't go wrong? Well, why not just admit that we don't have control over everything, and just *let things go wrong* when the wrong type is passed? va

Re: How to validate the __init__ parameters

2009-12-22 Thread Bruno Desthuilliers
Denis Doria a écrit : Hi; I'm checking the best way to validate attributes inside a class. Of course I can use property to check it, but I really want to do it inside the __init__: If you use a property, you'll have the validation in the initializer AND everywhere else too. If you care about

Re: more efficient?

2009-12-22 Thread Irmen de Jong
On 12/22/09 7:13 AM, Zubin Mithra wrote: I have the following two implementation techniques in mind. def myfunc(mystring): check = "hello, there " + mystring + "!!!" print check OR structure = ["hello, there",,"!!!"] def myfunc(mystring): structure[2] = mystring output = ''

Re: Class variables static by default?

2009-12-22 Thread Daniel Fetchinson
>> I don't think Steven cares much, he loves this type of nitpicking and >> uber pedantic formulations, but only if he can apply it to other >> people's post :) > > Heh heh :) > > I actually do care, because (not having a Java/C++ background) I actually > do get a mental "double-take" every time I

Re: converting string to a date format

2009-12-22 Thread M.-A. Lemburg
tekion wrote: > All, > I know there is a datetime module for converting and manipulate date > format. I have this string date format: 24/Nov/2009:10:39:03 -0500 > and would like to convert it to a date format of "2009-11-24 > 10:39:03". At the moment I am reading datetime module trying to find >