Great stuff AD!
Think about it, women can form a new human being, a God-like endeavor indeed. Men could help by doing some of the houshold chores at least.
Great stuff AD!
Think about it, women can form a new human being, a God-like endeavor indeed. Men could help by doing some of the houshold chores at least.
Hey vegaseat, thanks for the UliPad reference. I installed it on my Windows Vista machine, and I like it, particularly the snippet manager. Hopefully, it will work equally well for FreezeBlink on his/her Ubuntu machine! It works with a number of computer languages, and recognizes the code by its file extension.
Thanks for the help vegaseat now i know i need to practice Python more...but one more thing. When ever i put this in my elif statement
elif direction == '2':
The program stops from their. Any suggestions?
Thanks
I think you misunderstood vegaseat. It needs to be something like this:
print "Welcome to Adventure!"
print " "
print "Your options are: "
print "1) Play"
print "2) Quit"
choice = raw_input("Choose your option (1, 2): ")
if choice == '1':
#print "You can go: "
dir_list = ['N', 'S', 'E', 'W']
direction = raw_input("Where do you want to go (N, S, E, W)?: ").upper()
if direction in dir_list:
# do something here
pass # temporary action
elif choice == '2':
print "You find nothing.."
Another example is OpenOffice, it is written in Java but uses Python as an internal scripting language.
The nice thing about OpenOffice is that Sun makes it available for free (if you like it make a donation) and it competes very well with Microsoft Office. I have had no problems using my old MS Office files.
Conversely, please accept that some of us do not. Our simple request is that need be kept as a personal matter and out of our schools, laws, government, and international dealings. Simple enough from our point of view anyway, obviously not so for the majority.
Amen to that! For those of you who believe in God, in God's view we might just be an experiment gone wrong. There might only be one God, but many more experiments with mankind. Maybe some of them might be just a bit more perfect.
And just which variant of Cole's Law would that be?
I know only one variant, Cole's Law: "Thinly Sliced Cabbage"
I think women live longer than men because we were an upgraded model of the human being.
BTW, updating the display screen continuously will be the slowest part of your program.
I think you want module curses, that one has setsyx(y, x) that puts the cursor to where you want to print on the screen.
When I resize the frame it works just fine.
It might be these two lines that give you problems with a larger picture:
self.panel_1.SetMinSize((480, 272))
self.panel_1.SetMaxSize((480, 272))
When you draw your crosshairs, you have to reference the image height and width:
def lineaorizzontale(self, y):
self.dc.SetPen(wx.Pen('blue', 1))
w = self.image.GetWidth()
#print w
self.dc.DrawLine(0, y, w, y)
def lineaverticale(self, x):
self.dc.SetPen(wx.Pen('blue', 1))
h = self.image.GetHeight()
#print h
self.dc.DrawLine(x, 0, x, h)
What does not work properly?
What do you expect to happen?
You have to be careful not to create a list alias. Something you do inadvertantly with a nested list:
# make a true copy of a nested list
import copy
nested_list = [1, [2, 3], 4]
copied_list = copy.deepcopy(nested_list)
# a regular list copy looks alright at first
copied_list2 = nested_list[:]
print nested_list # [1, [2, 3], 4]
print copied_list # [1, [2, 3], 4]
print copied_list2 # [1, [2, 3], 4]
print '-'*20
# change the orignal list
nested_list[1][0] = 99
# but the test shows a surprise!
print nested_list # [1, [99, 3], 4]
print copied_list # [1, [2, 3], 4]
print copied_list2 # [1, [99, 3], 4] oops!
This works just fine for me using a Windows Vista machine:
lines = file('./simple-retrieval/file1.txt', 'r').readlines()
# show the first 10 lines for a test
print lines[:10]
del lines[0:4]
# now show the first 10 lines for a test
print lines[:10]
file('./simpleunwrapped/file2.txt', 'w').writelines(lines)
It looks like you are visualizing new line characters, actually empty lines. There is got to be an option setting somewhere in IDLE where you can turn this off.
I don't use IDLE, but mostly the PyScripter IDE.
I still say it's the syntax.
Do not use recursion as a loop, but use a while loop in the function itself. You also need to set a flag that the gold has been taken. Further note that a triple quoted string relaxes the indentation rule:
def prompt_house():
global gold
gold_taken = False
while True:
prompt_hou = raw_input('>')
if prompt_hou == 'examine table' and not gold_taken:
print \
'''There are a lot of car magazines here.
You flip through them and find 5 gold.
'''
gold = gold+5
gold_taken = True
elif prompt_hou == 'go west':
# this gets you out of the loop
go_west()
# more elif choices here ...
def go_west():
# just a dummy funk
global gold
print gold
pass
# test
gold = 0
prompt_house()
Java has been taught by college CS departments for many years. The typical inertia shown by CS staff makes certain that Java will be taught for many more years to come. There are hordes of Java programmers out there. Also Java, being more complex, ensures job security since development is slower and more programmers are needed to do the job.
Python, being easier and quicker to teach, would of course reduce the number of instructors too. Oh my!
Vested interest is hard to overcome! In the mean time, many students are wasting time with stuffy syntax.
I use Winpdb (recommended by our science prof) and like the way it follows variable values in real time as you step thrugh the code. You are right, using File/Launch to open a Python source file is not very intuitive.
It installs as a winpdb.py (also compiled optimized winpdb.pyo) in C:\Python25\Lib\site-packages on my Windows Vista computer. Also needs wxPython installed to run.
I don't think pyqt can handle animated gifs. You could use wxPython's wx.animate.GIFAnimationCtrl widget.
The way I understand it, C was developed to write the Unix operating system. C++ was a major improvement of C. Java was an improvement of C++ and C# was a MS ripoff of Java.
I started to read the book "How to teach yourself Java in ten years" :)
but I kept falling asleep.
I picked up Python that was used in my Biochemistry class in just about a day from the class handouts.
Thanks for the samples of C, C++, C# and Java they make Python code look alarmingly simple.
Paul, what C++ compiler are you using?
The open source g++ gives me lots of errors:
Compiler: Default compiler
Building Makefile: "C:\Dev-Cpp\AtestCON\NineOnes1\Makefile.win"
Executing make...
make.exe -f "C:\Dev-Cpp\testCON\NineOnes1\Makefile.win" all
g++.exe -c main.cpp -o main.o -I"C:/Dev-Cpp/lib/gcc/mingw32/3.4.2/include" -I"C:/Dev-Cpp/include/c++/3.4.2/backward" -I"C:/Dev-Cpp/include/c++/3.4.2/mingw32" -I"C:/Dev-Cpp/include/c++/3.4.2" -I"C:/Dev-Cpp/include"main.cpp:1: error: expected namespace-name before ';' token
main.cpp:1: error: `<type error>' is not a namespace
main.cpp:3: error: `array' was not declared in this scope
main.cpp:3: error: `System' has not been declared
main.cpp:3: error: `String' was not declared in this scopemain.cpp:3: error: expected primary-expression before '>' token
main.cpp:3: error: expected primary-expression before '^' token
main.cpp:3: error: `args' was not declared in this scope
main.cpp:4: error: expected `,' or `;' before '{' tokenmake.exe: *** [main.o] Error 1
Execution terminated
Do you really think that this C++ code:
using namespace System;
int main(array<System::String ^> ^args)
{
Int64 a = 111111111;
Console::WriteLine( Int64(a * a) );
return 0;
}
is easier to understand than Python:
a = 111111111
print a * a
You cannot use the line:
if sex == "M" or "m":
In Python you have to write it this way:
if sex == "M" or sex == "m":
Actually you might just use:
if sex in ["M", "m"]:
Look at the syntax of Java and Python. Which one would you rather use?
Also avoid using type, since that is a builtin Python function name.
You could keep track of your input in a dictionary:
d = {}
# input value and variable name
d[raw_input('Enter variable name: ')] = raw_input('Your value: ')
print d, d.keys(), d.values()
I am not quite sure where you want to go with this, it doesn't make much sense! If the user enters the variable name, and picks a Python keyword or function name, you get into all sorts of errors!
The simplest way, but maybe not the most efficient for large files, is this:
# sample text for testing
# could come from a text file read like this:
"""
infile = open("my_text.txt","r")
text = infile.read()
infile.close()
"""
text = """\
My name is Fred Flintstone and I am a famous TV
star. I have as much authority as the Pope, I
just don't have as many people who believe it.
"""
search = "Fred"
index = text.find(search)
print search, "found at index", index
"""
my ouput (index is zero based) -->
Fred found at index 11
"""
Note that find() only finds the first occurrence of the search word!
What you did will work if you are in IDLE's Python Shell (in the editor click on run then Python Shell), it's the one with the >>> prompt. If you are in the IDLE editor (no >>> prompts) you need to save your code first like 'linux' said. Then use key F5 to run it.
The PythonShell is for simple tests. If you have to type several lines of code, it is better to use the editor and save the code as something like mytest2.py so you can modify it easily.
Editors like IDLE are nice for beginners, since they highlight your code and help with builtin functions. For instance type int( in the editor, and a suggestion what this function expects as arguments and will return pops up.
If you instal Python from the source files, you need MS C++ on windows during installation. I recommend that on Windows you install from the ready made binary .msi file.
My guess would be coral too!
If you want to clear the whole canvas instance of all items on it, use:
canvas.delete('all')
Really not that much different than C:
# while statement to add spaces to string until lenght == 70
def right_just(s):
while len(s) < 70:
s = " " + s
return s
s = '1234567890'
# acts as ruler
print s * 7
print right_just(s)
"""
my result -->
1234567890123456789012345678901234567890123456789012345678901234567890
1234567890
"""
To make this more general:
def remove_uni(s):
"""remove the leading unicode designator from a string"""
if s.startswith("u'"):
s2 = s.replace("u'", "'", 1)
elif s.startswith('u"'):
s2 = s.replace('u"', '"', 1)
return s2
s = 'u"you\'re my favorite string"'
print remove_uni(s) # "you're my favorite string"
Tutorials for the wxPython GUI toolkit:
not bad ...
http://wiki.wxpython.org/AnotherTutorial
this is one I like ...
http://zetcode.com/wxpython/
The professor recommended that we use DrPython in class.
The free DrPython IDE lets you download a code completion plug in, set the default folder and many other things.
Simply extract the zip file into your Python folder. You can download it from:
(Windows and Linux)
http://sourceforge.net/projects/drpython/
I downloaded eg. drpython165.zip and extracted it to C:\Python25\lib
A note: you have to have the wxPython GUI toolkit installed first.