> Doesn't short-circuit evaluation refer specifically to the behavior
> where arguments are only evaluated if they need to be? It's a very
> useful feature, but not technically required for the "val = val or 1"
> behavior to work.
Its essential.
If Python always evaluated all parts of a boole
ALAN GAULD wrote:
Doesn't short-circuit evaluation refer specifically to the behavior
where arguments are only evaluated if they need to be? It's a very
useful feature, but not technically required for the "val = val or 1"
behavior to work.
Its essential.
If Python always evaluated all par
I'm currently working through the Google Python tutorial exercises and
had questions about the following function:
def not_bad(s):
# +++your code here+++
# LAB(begin solution)
n = s.find('not')
b = s.find('bad')
if n != -1 and b != -1 and b > n:
s = s[:n] + 'good' + s[b+3:]
return
Hello Modulok:
The code below is very simple, so I don't think you would have needed to
read it. I will review the subprocess doc and look this up in my books
and class notes. If I have more questions, I will email the group.
I also realized that I wasn't clear in asking a secondary question w
"Steven D'Aprano" wrote
Python knows that if val is true then it doesn't need to evaluate
the second term that causes it to return val rather than 1.
That's what makes it short circuiting, but that's not why it returns
the first argument. `or` in standard Pascal doesn't short-circuit.
But
"Ben Ganzfried" wrote
n = s.find('not')
b = s.find('bad')
if n != -1 and b != -1 and b > n:
s = s[:n] + 'good' + s[b+3:]
return s
It's clear that n!=-1 and b!=-1 means something like : "if in the
string 's' we find the word "not" and in string 's' we find the word
"bad."
Exactly the o
Hi all,
I was googling a way to do something like
mydict=mydict.extend(additionaldict)
and someone on a forum recommends this:
mydict=dict(mydict, **additionaldict)
What is the ** doing here? I tried to look it up, but Google seems to
ignore it since it is punctuation. The poster on the forum says
The value you provide as the second argument must be a dictionary.
Google kwargs python for lots of more in depth info
On Fri, Dec 10, 2010 at 2:14 PM, Alex Hall wrote:
> Hi all,
> I was googling a way to do something like
> mydict=mydict.extend(additionaldict)
>
> and someone on a forum recomm
Dnia 10-12-2010 o 20:14:30 Alex Hall napisał(a):
Hi all,
I was googling a way to do something like
mydict=mydict.extend(additionaldict)
and someone on a forum recommends this:
mydict=dict(mydict, **additionaldict)
What is the ** doing here?
As far as I know the ** indicates that the argumen
On Fri, Dec 10, 2010 at 8:14 PM, Alex Hall wrote:
> Hi all,
> I was googling a way to do something like
> mydict=mydict.extend(additionaldict)
>
mydict.update(additionaldict)
see also:
http://docs.python.org/library/stdtypes.html#dict.update
> and someone on a forum recommends this:
> mydict=di
List,
Forgive me if I don't describe this well, I'm new to it:
Assume I'm working in a command shell on a terminal. Something like
tcsh on xterm, for example. I have a program which does *something*.
Let's say it counts down from 10. How do I print a value, and then
erase that value, replacing it
If you just want a single line you can use chr(13) which is a carriage
return. If you want a more complex program you'll need a curses type
library
hth, wayne
On 12/10/10, Modulok wrote:
> List,
>
> Forgive me if I don't describe this well, I'm new to it:
>
> Assume I'm working in a command shell
On 12/10/2010 3:14 PM, Modulok wrote:
List,
Forgive me if I don't describe this well, I'm new to it:
Assume I'm working in a command shell on a terminal. Something like
tcsh on xterm, for example. I have a program which does *something*.
Let's say it counts down from 10. How do I print a valu
On 12/10/2010 3:34 PM, Wayne Werner wrote:
If you just want a single line you can use chr(13) which is a carriage
return. If you want a more complex program you'll need a curses type
library
hth, wayne
On 12/10/10, Modulok wrote:
List,
Forgive me if I don't describe this well, I'm new to it
Hello members:
I need your help, I'm developing a python script to make an excel file...
I've been working in this for a long time. The module will write some data
from a .shp file. Unfortuanely that information has some characters
unrecorgnized by ascii. I tried to fix this adding an unicode sent
Modulok wrote:
List,
Forgive me if I don't describe this well, I'm new to it:
[snip description of a progress bar]
Here's one way:
import time, sys
f = sys.stdout
for i in range(20):
time.sleep(1) # do some work
f.write('=')
f.flush() # make the change visible immediately
else:
On Fri, Dec 10, 2010 at 9:38 PM, Corey Richardson wrote:
>
> Try that in the interactive interpreter, it doesn't work.
print "a" + chr(13)
> a
You forgot to print something after the carriage return. It works for me:
Python 2.6.6 (r266:84292, Sep 15 2010, 15:52:39)
[GCC 4.4.5] on linux2
Typ
This code produces a good run.
from tkinter import *
root = Tk()
class Application(Frame):
global sv, Ptype, PtypeI, sel_rate_label, label
label = Label(root)
Ptype = 999
PtypeI = IntVar()
W = 5
Y = 4
def sel(self):
global W
global Y
Ptype = P
Thanks again Alan. Much clearer now. One final part I don't understand.
>
"%d is the result of %d + %d" % (6+7,6,7)
>
>I understand (I think) the 6+7 part but why the ,6,7 after that. I could
>see how either '6+7' or '6,7' would be the correct format but not both.
The format string ha
"Modulok" wrote
Assume I'm working in a command shell on a terminal. Something like
tcsh on xterm, for example. I have a program which does *something*.
Let's say it counts down from 10. How do I print a value, and then
erase that value, replacing it with another value?
This is one of those
wrote
This code produces a good run.
Not sure what you mean by that. What is "a good run"?
from tkinter import *
root = Tk()
class Application(Frame):
global sv, Ptype, PtypeI, sel_rate_label, label
This is bizarre.
Globals are generally considered evil and to be avoided if possible.
Thanks all! I thought update() would add an item even if it would be a
duplicate, but apparently not. I also now better understand why I am
always passing around *args and **kwargs when calling super(). Very
interesting...
On 12/10/10, Hugo Arts wrote:
> On Fri, Dec 10, 2010 at 8:14 PM, Alex Hall
I'm using Python 2.6.5.
The following problem is coming from inside of a complex code base
and involves an implementation that I have used for years, and is
now failing to execute in certain conditions.
This problem occurs with either of the follow two classes, which are
'lifted' from 'Python Cookb
On 12/10/2010 12:14 PM Modulok said...
List,
Forgive me if I don't describe this well, I'm new to it:
Assume I'm working in a command shell on a terminal. Something like
tcsh on xterm, for example. I have a program which does *something*.
Let's say it counts down from 10. How do I print a value
On Sat, Dec 11, 2010 at 1:26 AM, Alex Hall wrote:
> Thanks all! I thought update() would add an item even if it would be a
> duplicate, but apparently not. I also now better understand why I am
> always passing around *args and **kwargs when calling super(). Very
> interesting...
>
Actually, it d
On Fri, 10 Dec 2010, Alan Gauld wrote:
"Ben Ganzfried" wrote
n = s.find('not')
b = s.find('bad')
if n != -1 and b != -1 and b > n:
s = s[:n] + 'good' + s[b+3:]
return s
It's clear that n!=-1 and b!=-1 means something like : "if in the
string 's' we find the word "not" and in string 's
Hi Steven
On 10 December 2010 03:50, Steven D'Aprano wrote:
> Some languages (Pascal comes to mind) doesn't have short-circuit behaviour
> at all.
>
Don't mean to nit pick, but in my experience it really depends on the
compiler implementation and which version of Pascal you're talking about.
Ce
This is somewhat non-Python specific I have an idea for a Python
application that I want to write at work. The application needs to have a
data file be available to multiple users for access, read and write. I
know that a typical database, such as mysql, would work ok. However, I am
trying t
This is a resend. I note that the original had an incorrect
`reply-to' ID attached to it. (sorry)
--
I'm using Python 2.6.5.
The following problem is coming from inside of a complex code base
and involves an implementation that I have
my tutorial.
t uses variables in the same way rather than literal values,
hat might make it more obvious. Maybe :-)
HTH,
Alan G.
- next part --
n HTML attachment was scrubbed...
RL:
<http://mail.python.org/pipermail/tutor/attachments/20101210/a7647551/attachment-0001.html
30 matches
Mail list logo