Sunburned Surveyor a écrit :
> On Oct 22, 10:26 am, "Chris Mellon" <[EMAIL PROTECTED]> wrote:
>
(snip)
>>I can't think of a single reason why you would ever want to do this,
>>since your "list of method and property names" would be just as
>>verbose as just typing the actual python code.
>>
>>Auto
Sunburned Surveyor a écrit :
> On Oct 22, 11:47 am, Bruno Desthuilliers
> <[EMAIL PROTECTED]> wrote:
(snip)
>
> Bruno wrote: "You don't need these getters and setters. Python has
> support for
> computed attributes (look for 'property'), so until you n
Steven Bethard a écrit :
(snip)
> In Python, you can use property() to make method calls look like
> attribute access. This could be necessary if you have an existing API
> that used public attributes, but changes to your code require those
> attributes to do additional calculations now.
>
> B
Steven Bethard a écrit :
> Bruno Desthuilliers wrote:
>> Steven Bethard a écrit :
>> (snip)
>>> In Python, you can use property() to make method calls look like
>>> attribute access. This could be necessary if you have an existing
>>> API that used p
Steven Bethard a écrit :
> Bruno Desthuilliers wrote:
>
>> Steven Bethard a écrit :
>>
>>> Bruno Desthuilliers wrote:
>>>
>>>> Steven Bethard a écrit :
>>>> (snip)
>>>>
>>>>> In Python, you can use property()
TimeHorse a écrit :
> I have started work on a new module that would allow the decoration of
> class methods to restrict access based on calling context.
> Specifically, I have created 3 decorators named public, private and
> protected.
Lord have mercy.
--
http://mail.python.org/mailman/listinfo
J. Clifford Dyer a écrit :
> On Tue, Oct 23, 2007 at 08:54:52PM +0200, Bruno Desthuilliers wrote
> regarding Re: New module for method level access modifiers:
>
>> TimeHorse a ?crit :
>>
>>> I have started work on a new module that would allow the
>>>
Steven Bethard a écrit :
> Bruno Desthuilliers wrote:
>
>>> I guess as long as your documentation is clear about which attributes
>>> require computation and which don't...
>>
>>
>> Why should it ? FWIW, I mentionned that I would obviously not use
dineshv a écrit :
> We have a list of N (>2,000) keywords (of datatype string). Each of
> the N keywords has associated with it a list of names of varying
> numbers. For example, keyword(1) will have a list of L1 names
> associated with it, keyword(2) will have a list of L2 names associated
> wit
Steven Bethard a écrit :
> Bruno Desthuilliers wrote:
>
>> Steven Bethard a écrit :
>>
>>> Bruno Desthuilliers wrote:
>>>
>>>>> I guess as long as your documentation is clear about which
>>>>> attributes require computation and
BBands a écrit :
> On Oct 23, 4:20 pm, [EMAIL PROTECTED] wrote:
>> Hello. Indeed the doStuff function in the doStuff module can't do 'a.b
>> = 0' (the double dot was just a typo, right?)
>
> Yes.
>
>> because it doesn't know anything about an object named a.
>
> I was trying to understand why it
[EMAIL PROTECTED] a écrit :
(snip)
> Anyone know why towards arg is True and arg is False, arg is None is
> faster than arg == None ...
Perhaps reading about both the meaning of the 'is' operator might help ?
the expression 'arg is True' will only eval to true if 'id(arg) ==
id(True)'. Now Pyt
Bjoern Schliessmann a écrit :
> Alexandre Badez wrote:
>> I'm just wondering, if I could write a in a "better" way this code
>> [...]
>> I think there is a better way, but I can't see how...
>
> What's "better" for you? Shorter? More performant? More readable?
> Complying with best practice? Close
NoName a écrit :
> sorry! Yes it's work.
> What about 2 question?
> Can i put function after main block?
>
> print qq()
>
> def qq():
> return 'hello'
Where's your "main block" here ?
> Traceback (most recent call last):
> File "C:\Python25\projects\indexer\test.py", line 1, in
> print
Adam Donahue a écrit :
> As an exercise I'm attempting to write a metaclass that causes an
> exception to be thrown whenever a user tries to access
> 'attributes' (in the traditional sense) via a direct reference.
I guess you're new to Python, and coming from either C++ or Java. Am I
wrong ?-)
A
Adam Donahue a écrit :
> Bruno,
>
> I appreciate your attempt to answer my questions below, although I
> think my main point was lost amongst all your commentary and
> assumptions. :^)
Possibly. I sometimes tend to get a bit verbose !-)
> I'm not inexperienced,
Obviously not.
> but I tak
Neil Cerutti a écrit :
> On 2007-10-25, Bruno Desthuilliers
> <[EMAIL PROTECTED]> wrote:
>> The canonical case for small scripts is to have first all
>> functions and globals defined, then the main code protected by
>> a guard, ie:
>
> There's no reas
Chris Mellon a écrit :
> On Thu, 2007-10-25 at 23:13 +0200, Bruno Desthuilliers wrote:
>
>> Dynamically adding methods to classes is pretty
>> straightforward, the tricky point is to dynamically add methods to
>> instances, since the descriptor protocol is
Frank Stutzman a écrit :
> My apologies in advance, I'm new to python
>
> Say, I have a dictionary that looks like this:
>
> record={'BAT': '14.4', 'USD': '24', 'DIF': '45', 'OAT': '16',
> 'FF': '3.9', 'C3': '343', 'E4': '1157', 'C1': '339',
> 'E6': '1182', 'RPM': '996', 'C6': '31
Donn Ingle a écrit :
> Hello,
>
> Is there a way I can, for debugging, access the instance variable name from
> within a class?
> E.g:
> Class X:
> def debug(self):
> print "My instance var is %s" % (some magic Python stuff)
>
> So that:
x = X()
x.debug()
My Instance var is x
>
[EMAIL PROTECTED] a écrit :
> I want to create a program that I type in a word.
>
> for example...
>
> chaos
>
> each letter equals a number
>
> A=1
> B=20
>
> and so on.
>
> So Chaos would be
>
> C=13 H=4 A=1 O=7 S=5
>
> I want to then have those numbers
> 13+4+1+7+5 added together to
Hrvoje Niksic a écrit :
> Donn Ingle <[EMAIL PROTECTED]> writes:
>
>> Is there a way I can, for debugging, access the instance variable name from
>> within a class?
>> E.g:
>> Class X:
>> def debug(self):
>> print "My instance var is %s" % (some magic Python stuff)
>
> As others have answered
[EMAIL PROTECTED] a écrit :
> Im tryin to call
s/call/access/
> a var thats sitting
s/sitting/defined/
> in a function, example:
In this example, s/function/class/
> class someclass(object):
pep08 : should be SomeClass(object):
> somevar = open(blah, 'r').readlines()
Doing IO in
johnbraduk a écrit :
> Thomas,
> Like many others I have been going round the same loop for months.
>
> I have struggled with most of the Python solutions, including
> TurboGears and have given up and gone back to ColdFusion. I am not
> trying to kick of a religious war about the pros and cons of
Hrvoje Niksic a écrit :
> Bruno Desthuilliers <[EMAIL PROTECTED]>
> writes:
>
>>> As others have answered, an instance can live in many variables,
>> "be bound to many names" would be more accurate IMHO.
>
> Technically more accurate maybe (but see
Armando Serrano Lombillo a écrit :
> Why does Python give an error when I try to do this:
>
len(object=[1,2])
> Traceback (most recent call last):
> File "", line 1, in
> len(object=[1,2])
> TypeError: len() takes no keyword arguments
>
> but not when I use a "normal" function:
>
>>>
Hrvoje Niksic a écrit :
> Bruno Desthuilliers <[EMAIL PROTECTED]>
> writes:
>
>> The problem is that your formulation implies (to me at least) that the
>> variable is actually a kind of container for the object.
>
> I really didn't expect it to be read tha
Armando Serrano Lombillo a écrit :
> On Oct 29, 3:20 pm, Bruno Desthuilliers [EMAIL PROTECTED]> wrote:
>> Armando Serrano Lombillo a écrit :
>>
>>> Why does Python give an error when I try to do this:
>>>>>> len(object=[1,2])
>>> Traceb
TYR a écrit :
> On Oct 29, 11:51 am, Duncan Booth <[EMAIL PROTECTED]>
> wrote:
>
>>TYR <[EMAIL PROTECTED]> wrote:
>>
>>>To do anything with it, you then need to create a cursor object by
>>>calling foo's method cursor (bar = foo.cursor).
>>
>>Perhaps this would work better if you actually try call
Steven D'Aprano a écrit :
(snip)
> eval("{" + reduce(lambda x,y: y+', '+x, [mo.group(1) for mo in __import__
> ('re').finditer(r"('E.*?'\s*:\s*'.*?'),?", str(record))], "") + "}")
Maman !
Steven, you choose the wrong language. You definitively want Perl !
--
http://mail.python.org/mailman/listin
Martin v. Löwis a écrit :
>>>egt = {}
>>>for key in record:
>>> if key.startswith('E'):
>>> egt[key] = record[key]
>>
>>I actually had come up with something like this, but thought it wasn't
>>quite as pythonish as it should be. It is certainly much more readable
>>to a neophyte to python.
TYR a écrit :
> Has anyone else experienced a weird SQLite3 problem?
>
> Going by the documentation at docs.python.org, the syntax is as
> follows:
> foo = sqlite3.connect(dbname) creates a connection object representing
> the state of dbname and assigns it to variable foo. If dbname doesn't
> exi
brad a écrit :
> Will len(a_string) become a_string.len()? I was just reading
>
> http://docs.python.org/dev/3.0/whatsnew/3.0.html
>
> One of the criticisms of Python compared to other OO languages is that
> it isn't OO enough
Really ? IIRC, Python doesn't have primitive types, functions are
o
Fuzzyman a écrit :
> On Oct 22, 6:43 pm, Steven Bethard <[EMAIL PROTECTED]> wrote:
(snip)
>> # Inherit from object. There's no reason to create old-style classes.
>
>
> We recently had to change an object pipeline from new style classes to
> old style. A lot of these objects were being created an
brad a écrit :
> Rob Wolfe wrote:
>
>> I wonder why people always complain about `len` function but never
>> about `iter` or `pprint.pprint`? :)
>
> Not complaining. len is simple and understandable and IMO fits nicely
> with split(), strip(), etc... that's why I used it as an example, but
> li
Hrvoje Niksic a écrit :
> Bruno Desthuilliers <[EMAIL PROTECTED]>
> writes:
>
>>> It seems to me that in recent times more Python beginners come from
>>> a Java background than from a C one.
>> Java does have "container" variables for prim
Donn Ingle a écrit :
>>vzcbeg vafcrpg
>>
>>qrs _svaq(senzr, bow):
>>sbe anzr, inyhr va senzr.s_ybpnyf.vgrevgrzf():
>>vs inyhr vf bow:
>>erghea anzr
>>sbe anzr, inyhr va senzr.s_tybonyf.vgrevgrzf():
>>vs inyhr vf bow:
>>erghea anzr
>>envfr XrlReebe
barronmo a écrit :
> I'm new to programming and even newer to Python and would be grateful
> for some help on what has been a tough problem for me. The project I
> am working on is an electronic medical record using MySQL/Python. I'm
> currrently working on a module that looks up a patient's name
c james a écrit :
> Beema shafreen wrote:
>
>> 2721520 2721569A_16_P21360235199-49
>> 2721768 2721821A_16_P03641971139-53
>> 2721960 2722004A_16_P21360237312-44
>>I need to append the column D and E into a list:
>>in
Johny a écrit :
> Is it possible to change record separator when using readline?
> As far as I know readline reads characters until found '\n' and it is
> the end of record for readline.
This is not a "record" separator, but a newline. As the name implies,
file.readline is about reading a text fi
Jeff a écrit :
> If it's a short file you could slurp the entire file and then split it
> however you like using regular expressions.
My my my...
> I'm not sure if you can alter it,
You can. But it hopefully won't alter your binary-compiled system libs.
IOW : it's so (obviously) useless that no
[EMAIL PROTECTED] a écrit :
> On Oct 29, 10:39 pm, sandipm <[EMAIL PROTECTED]> wrote:
>
>>seeing posts from students on group. I am curious to know, Do they
>>teach python in academic courses in universities?
>>
>>in undergrad comp science courses, We had scheme language as scheme
>>is neat and b
brad a écrit :
> Tommy Nordgren wrote:
>
>>> def outer(avar=False):
>>> print avar
>>> if avar == True:
>>> return
>>>
>>> def inner(avar=True):
>>> print avar
>>> return avar
>>>
>>> outer(inner())
>>>
>>> outer()
>
>
>> This is not a general s
Hrvoje Niksic a écrit :
> Bruno Desthuilliers <[EMAIL PROTECTED]>
> writes:
>
>
>>>While Java's variable declarations bear a superficial (syntactical)
>>>similarity to C, their semantics is in fact equivalent to the
>>>object-reference semantic
[EMAIL PROTECTED] a écrit :
> Hi all,
>
> I dare risk my brain exploding by reaching for the understanding of
> metaclasses.
>
> At first i thought i almost got them, even if vaguely back in a corner
> of my mind, my understanding was that, as classes' class a metaclass
> would be able to return
Johny a écrit :
> On Oct 30, 8:44 pm, Bruno Desthuilliers
> <[EMAIL PROTECTED]> wrote:
>> Johny a écrit :
>>
>>> Is it possible to change record separator when using readline?
>>> As far as I know readline reads characters until found '\n' and
mrstephengross a écrit :
> I would like to get the results of a print operation
print is a statement, it doesn't yield any 'result'.
> placed in a
> string. For instance, you can very easily create a list and print it
> to stdout:
>
> x = [1,2,3]
> print x # Will print [1,2,3]
>
> What if
Gustaf a écrit :
> Hi all,
>
> Just for fun, I'm working on a script to count the number of lines in
> source files. Some lines are auto-generated (by the IDE) and shouldn't
> be counted. The auto-generated part of files start with "Begin VB.Form"
> and end with "End" (first thing on the line).
Dennis Lee Bieber a écrit :
> On Wed, 31 Oct 2007 11:13:21 +0100, Bruno Desthuilliers
> <[EMAIL PROTECTED]> declaimed the
> following in comp.lang.python:
>
>> [1] Coma Separated Values - but the separator can be almost anything.
>>
> Comma...
oops...
Bjoern Schliessmann a écrit :
> Jim Hendricks wrote:
(snip)
>> I see the global keyword that allows access to global vars in a
>> function, what I'm not clear on is does that global need to be
>> declared in the global scope,
>
> You can't just declare in Python, you always define objects (and
> b
Steven D'Aprano a écrit :
> On Fri, 02 Nov 2007 03:40:59 +, Tim Roberts wrote:
>
>> Steven D'Aprano <[EMAIL PROTECTED]> wrote:
>>
>>> On Wed, 31 Oct 2007 22:48:12 -0700, Carl Banks wrote:
>>>
> I hope you're not serious that $# would make a good operator.
If you happen to know where I
Jim Hendricks a écrit :
> New to python, programming in 15 or so langs for 24 years.
>
> Couple of questions the tuts I've looked at don't explain:
>
> 1) global vars - python sets scope to the block a var is declared (1st
> set), I see the global keyword that allows access to global vars in a
[EMAIL PROTECTED] a écrit :
> Hi,
>
> The following code works -
>
> one = 1
> if one == 1:
> ok = 1
> print ok
>
> but this does not, without exception -
>
> one = 2
Are you competing for the Most Misleading Name Award(tm) ?-)
> if one == 1:
> ok = 1
> print ok
>
> How do I establish be
stef a écrit :
>
>>
>> Change a=1 to amodule.a=1
>> If you find yourself doing tricks with the module globals, think about
>> redesigning your application.
>>
> Of course I completely agree with you.
>
> But ...
> if you're moving from MatLab to Python,
> and want to show your collegaes,
> with
Stef Mientki a écrit :
> Bruno Desthuilliers wrote:
>
>> stef a écrit :
(snip)
>>> You can explain your collegaes, that
>>> - the startindex of arrays changes from 1 to 0
>>> - slices are upto, instead of including the final border
>>> - indention
tonydevlin a écrit :
> I am creating a workflow in plone using argouml and archgenxml. I have been
> following the steps on the site:-
> http://plone.org/documentation/tutorial/anonymously-adding-custom-content-types-with-argouml-and-archgenxml/creating-a-class-and-workflow-with-argouml
>
> Howev
Karyn Williams a écrit :
> I am new to Pyton. I am trying to modify and understand a script someone
> else wrote. I am trying to make sense of the following code snippet. I know
> line 7 would be best coded with regex. I first would like to understand
> what was coded originally. thelistOut looks l
tonydevlin a écrit :
>
>
> Bruno Desthuilliers wrote:
>
>>tonydevlin a écrit :
>>
>>>I am creating a workflow in plone using argouml and archgenxml. I have
>>>been
>>>following the steps on the site:-
>>>http://plone.org/documen
Carl J. Van Arsdall a écrit :
> For those of you that work on larger applications but still code in
> python... do your development teams use any tools to facilitate the
> design?
Yes : coffee, beer, pizzas, cigarettes, paper napkins, pen, and a good wiki.
> (i'm not asking about editors here,
Stef Mientki a écrit :
> Bruno Desthuilliers wrote:
>
>> Stef Mientki a écrit :
>>
>>> Bruno Desthuilliers wrote:
>>>
>>>> stef a écrit :
>>
>> (snip)
>>
>>>>> but tell them that they are going to loose all t
Duncan Smith a écrit :
> Hello,
> I find myself in the, for me, unusual (and at the moment unique)
> position of having to write a web application. I have quite a lot of
> existing Python code that will form part of the business logic. This
> relies on 3rd party libraries (such as numpy) wh
வினோத் a écrit :
> How can I integrate RPC
You mean xmlrpc or Soap ?
> with WSGI ???
> is any methods for it??
>
What's your problem exactly ?
--
http://mail.python.org/mailman/listinfo/python-list
Dongsheng Ruan a écrit :
> Thanks for your kindly help.
> I am new CS student taking datat structure and algorithms with AHO's book
> with the same title.
>
> The book is done in Pascal, which might be an outdated language.
Yes, somehow - but note, that linked lists are the central data
structu
Robin Becker a écrit :
> A large cgi based web Python-2.3 application needs to be speed improved.
> experiments show the following under reasonable testing (these are 2 second
> reportlab pdf productions)
>
> 1) 2.3 --> 2.5 improvement small 1-2%
> 2) cgi --> fcgi improvement medium 10-12%
>
> I s
Shortash a écrit :
> Hi Gurus,
>
> I want to build a Python web app but im not sure which one to go for. I
> prefer something like asp.Net , which would allow me to fully seperate
> the presentation layer from the logic. Please advise?
Django, Turbogears, Pylons(HQ), web.py, etc, etc, etc...
Wel
billie a écrit :
> robert wrote
>
>> Robin Becker wrote:
>>> A large cgi based web Python-2.3 application needs to be speed improved.
>>> experiments show the following under reasonable testing (these are 2
>>> second reportlab pdf productions)
>>>
>>> 1) 2.3 --> 2.5 improvement small 1-2%
>>> 2)
sturlamolden a écrit :
> Bruno Desthuilliers wrote:
>
>
>>Implementing linked lists in Python is not a great deal - it just
>>doesn't make much sens.
>
>
> It does make sence,
Oh Yec ?-)
sorry...
> as there are memory constraints related to it.
&g
gonzlobo a écrit :
> Greetings,
> I've been using Python to successfully parse files. When the entire
> program was smaller, the variable firstMsg worked fine, but now
> doesn't because it's used in function PID_MinMax. I know it's a result
> of variables and their scope.
>
> I declare the variabl
EdG a écrit :
> I'm using Python version 2.4 and I created a class with some properties
> like:
>
> def GetCallAmount(self):
> return somedata
The recommended naming convention is all_lower,ie:
def get_call_amount(self):
And FWIW, there are idioms to avoid polluting the class namespace
Sean Schertell a écrit :
> I'm trying to decide which template system to get married to. I think
> I've narrowed it down to PyMeld, Cheetah, or Jinja but leaning heavily
> toward PyMeld because I love the idea that your templates are *totally*
> clean and that get manipulated from behind the
EdG a écrit :
(top-post corrected)
>
> Neil Cerutti wrote:
>
>>On 2007-01-18, EdG <[EMAIL PROTECTED]> wrote:
>>
>>>For debugging purposes, I would like to traverse the class
>>>listing out all the properties.
>>
>>This is the first thing that came to mind.
>>
>>def show_properties(cls):
>> for a
gonzlobo a écrit :
Please keep this on clpy...
> Sorry, but I don't understand. I *should* pass firstMsg to the
> function like I did (PID_MinMax(firstMsg)), correct?
Yes.
> Then I should
> pass the variable back to the main loop by 'return firstMsg', correct?
s/variable/value/
Yes, you have
Siggi a écrit :
> Hi all,
>
> how do I avoid the DOS console show-up when starting a WinXP GUI application
> with mouseclick on the respective Python file?
rename yourfile.py to yourfile.pyw
--
http://mail.python.org/mailman/listinfo/python-list
Gert Cuykens a écrit :
> import MySQLdb
>
> class Db:
(snip)
>def excecute(self,cmd):
>self._cursor.execute(cmd)
>self._db.commit()
>
What about autocommit and automagic delegation ?
import MySQLdb
class Db(object):
def __init__(self,server, user, password, database):
Sean Schertell a écrit :
> person.name = 'Joe'
> person.age = 20
> person.sex = 'm'
>
> info_I_need = name
>
> print person.info_I_need
>
> # How can I make it print 'Joe' ?
>
print getattr(person, "name")
--
http://mail.python.org/mailman/listinfo/python-list
Gert Cuykens a écrit :
> Reading all of the above this is the most simple i can come too.
>
> import MySQLdb
>
> class Db:
>
>def __init__(self,server,user,password,database):
>self._db=MySQLdb.connect(server , user , password , database)
>self._db.autocommit(True)
>s
abcd a écrit :
> In my code I am debating whether or not to validate the types of data
> being passed to my functions. For example
>
> def sayHello(self, name):
> if not name:
> rasie "name can't be null"
> if not isinstance(name, str):
> raise "name must be a string"
>
Matthew Woodcraft a écrit :
> abcd <[EMAIL PROTECTED]> wrote:
>
>>Well my example function was simply taking a string and printing, but
>>most of my cases would be expecting a list, dictionary or some other
>>custom object. Still propose not to validate the type of data being
>>passed in?
>
>
>
abcd a écrit :
> Well my example function was simply taking a string and printing, but
> most of my cases would be expecting a list, dictionary or some other
> custom object. Still propose not to validate the type of data being
> passed in?
Yes - unless you have a *very* compelling reason to do o
metaperl a écrit :
> Ok, I have a module called textgen.py. The point of this module is to
> generate a csv file from an array of dictionaries.
Err... You know there's a csv module in the stdlib, don't you ?
> As I iterate through
> each dictionary, I "massage" the dictionary values before writin
Florian Lindner a écrit :
> Hello,
> does python have static variables? I mean function-local variables that keep
> their state between invocations of the function.
Not directly. But there are ways to have similar behaviour:
1/ the mutable default argument hack:
def fun(arg, _hidden_state=[0]):
Neil Cerutti a écrit :
> On 2007-01-24, Florian Lindner <[EMAIL PROTECTED]> wrote:
>
>>does python have static variables? I mean function-local
>>variables that keep their state between invocations of the
>>function.
>
>
> Yup. Here's a nice way. I don't how recent your Python must be
> to supp
[EMAIL PROTECTED] a écrit :
> Bruno Desthuilliers:
>> And this let you share state between functions:
>>
>> def make_counter(start_at=0, step=1):
>>count = [start_at]
>>def inc():
>> count[0] += step
>> return count[0]
&g
[EMAIL PROTECTED] a écrit :
> Hmm, my while loop with "or" doesn't seem to work as I want it to...
> How do I tell the while loop to only accept "Y" or "y" or "N" or "n"
> input from the str(raw_input)?
>
> Thank's in advance!
>
> Snippet of code:
>
> import os
>
> def buildfinder():
> os.s
Peter Otten a écrit :
> Bruno Desthuilliers wrote:
>
>> and simplified again thanks to Python 'in' operator:
>> while not usrinp.lower() in "yn":
>
> But note that 'in' performs a substring search and therefore "yn" and "&qu
antred a écrit :
> Hello everyone,
>
> While working on a program I encountered a situation where I'd
> construct a largish data structure (a tree) from parsing a host of
> files and would end up having to throw away parts of my newly built
> tree if a file turned out to contain invalid data. My f
[EMAIL PROTECTED] a écrit :
>
> On Jan 25, 11:26 am, [EMAIL PROTECTED] wrote:
(snip)
>> #Runs the buildfinder function
>> usrinp = buildfinder()
>>
>> def buildwhiler():
>>
>> while usrinp != "y" or "Y" or "N" or "n": PROBLEM
>> print "Enter Y or N!"
>> usr = str(raw_in
Alan Isaac a écrit :
> I'm fairly new to Python and I've lately been running a script at
> the interpreter while working on it. Sometimes I only want to
> run the first quarter or half etc. What is the "good" way to do this?
If the point is to debug your script, then import pdb; pdb.set_trace()
Matthew Woodcraft a écrit :
> Bruno Desthuilliers <[EMAIL PROTECTED]> wrote:
>> Matthew Woodcraft a écrit :
>
>>> Adding the validation code can make your code more readable, in that
>>> it can be clearer to the readers what kind of values are being
>>&g
Gert Cuykens a écrit :
> import MySQLdb
>
> class Db(object):
>
>def __enter__(self):
>pass
>
>def __init__(self,server,user,password,database):
>self._db=MySQLdb.connect(server , user , password , database)
>self._db.autocommit(True)
>self.cursor=self._db
John Nagle a écrit :
(snip)
>My main concern is with glue code to major packages. The connections
> to OpenSSL, MySQL, and Apache (i.e. mod_python) all exist, but have major
> weaknesses.
Neither MySQLdb nor mod_python are part of the Python's standard lib AFAIK.
> If you're doing web app
Drew a écrit :
> I'm looking to add an element to list of items, however I'd like to
> add it at a specific index greater than the current size:
>
> list = [1,2,3]
NB: better to avoid using builtins types and functions names as identifiers.
> list.insert(10,4)
>
> What I'd like to see is somet
Drew a écrit :
>>What is your actual usecase?
>>
>>diez
>
>
> The issue is that I don't know how long the list will eventually be.
How is this an issue ? Python's lists are not fixed-sized arrays.
> Essentially I'm trying to use a 2D list to hold lines that I will
> eventually print to the sc
[EMAIL PROTECTED] a écrit :
> hi
> can someone explain strip() for these :
> [code]
>
x='www.example.com'
x.strip('cmowz.')
>
> 'example'
> [/code]
>
> when i did this:
> [code]
>
x = 'abcd,words.words'
x.strip(',.')
>
> 'abcd,words.words'
> [/code]
>
> it does not strip off "
stef a écrit :
>
> why should I use *args,
> as in my ignorance,
> making use of a list (or tupple) works just as well,
> and is more flexible in it's calling.
Err... How so ?
> So the simple conclusion might be: never use "*args",
> or am I overlooking something ?
Try writing generic higher or
[EMAIL PROTECTED] a écrit :
> I can't seem to get this nailed down and I thought I'd toss it out
> there as, by gosh, its got to be something simple I'm missing.
>
> I have two different database tables of events that use different
> schemas. I am using python to collate these records for displa
king kikapu a écrit :
> Thanks for the replies.
>
> I think i do not need something like ORM, but just a db-module that i
> can "work" the database with it.
FWIW, SQLAlchemy is not an ORM, but an higher-level API for SQL
integration. The ORM part is an optional feature built on top of this
API.
johnny a écrit :
> What is **kwargs mean in python? When you put double **, does it mean
> passing by reference?
Nope.
Python as support for both positional (*args) and named (**kwargs) varargs.
> For example:
> def redirect_to(request, url, **kwargs):
means that redirect_to expect a positiona
Paddy a écrit :
> On Jan 31, 12:35 pm, Bruno Desthuilliers >Also, using comparison functions is usually not the most efficient way
>>to do such a sort. In your case, I'd go for a good old
>>Decorate/sort/undecorate (AKA schwarzian transform):
>>
>>events = [evt f
Doug Stell a écrit :
> I am having a problem with the corruption of a list. It occurs only
> the first time that I call a function and never happens on subsequent
> calls. Any suggestions would be appreciated.
>
> I call the function, passing in a list as the input data. The function
> must manipu
1701 - 1800 of 3705 matches
Mail list logo