Hi, my name is Ricardo and i'm learning to program in Python with
version 2.3.3, i'm also using the latest version of PythonWin(163) but
i'm trying to do it with a book (Written in Portuguese) that covers the
version 2.1, and of course i'm having a problem. The code in wich i'm
having problems is as follows:
class Gato:
"um felino domesticado"
def __init__(self, sexo, corPelo=None):
self.sexo = sexo
if corPelo != None
self.corPelo = corPelo
def miar(self):
if self.sexo == "m":
return "MIAU"
else:
return "miauuuu"
the book says that it should be done like this, but when i finnish the
5th line(if corPelo != None) and press ENTER, it gives me the error:
Traceback ( File "<interacti ve input>", line 5
if corPelo != None
^
SyntaxError: invalid syntax
I hope someone can help me?
Thanks in advance anyway.
Ricardo 3 1323
Ricardo wrote: The code in wich i'm having problems is as follows:
.... if corPelo != None self.corPelo = corPelo
....
Oi Ricardo, tudo bem?
I see at least two problems here. Python requires brackets around the 'if'
comparison, and a colon at the end of the if statement. Try re-writing
your statement as:
if (corPelo != None):
self.corPelo = corPelo
Boa sorte!
S
On Mon, 23 Feb 2004 06:15:32 GMT, stewart
<st*****@midtoa d.homelinux.org > declaimed the following in
comp.lang.pytho n: I see at least two problems here. Python requires brackets around the 'if' comparison, and a colon at the end of the if statement. Try re-writing
The colon is needed, yes... but not the parentheses...
-- =============== =============== =============== =============== == < wl*****@ix.netc om.com | Wulfraed Dennis Lee Bieber KD6MOG < wu******@dm.net | Bestiaria Support Staff < =============== =============== =============== =============== == < Home Page: <http://www.dm.net/~wulfraed/> < Overflow Page: <http://wlfraed.home.ne tcom.com/> <
stewart wrote: I see at least two problems here. Python requires brackets around the 'if' comparison, and a colon at the end of the if statement. Try re-writing your statement as: if (corPelo != None): self.corPelo = corPelo
No, Python doesn't require parenthesis or brackets around the
comparison. Any expression can have optional parenthesis.
if corPelo != None:
self.corPelo = corPelo
is enough.
Regards,
Nicolas This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics |
by: Ryan Walker |
last post by:
Hi,
I'm getting started with python and have almost zero programming experience.
I'm finding that there are tons of tutorials on the internet -- such as the
standard tutorial at python.org -- that tell you all about the language.
That is, what are the methods, functions, modules, syntax, punctuation, etc.
No problem there!
Meanwhile, I'm finding that there is very little (that I can find) about how
to do basic logistical things related...
|
by: post400 |
last post by:
Hi ,
I was just wondering ( yeah I know it's not the first time this
question pops up )
what would be the best 2 or 3 books for someone who wants to learn
Python , already experienced in other non-OOP languages .It takes time
to browse endlessly on the net , in a bookshop or a library for THOSE
books that are really useful !
Thanks ,
|
by: Phyrestang |
last post by:
Hi there. I've decided that my first real language I want to learn to
program in is Python. I've been using the Python tutorials at
Python.org, but I'm looking for something a little more in depth.
Can anyone recommend any good books for a someone new to python, and
to programming? I should mention that while I am new, I do catch on
quickly, so I'm not looking for a book that gives just the bare
basics.
Also, any good web...
|
by: Paul DiRezze |
last post by:
I'm spending the next two weeks off and I'm looking to take a crack at
learning how to program in Python. Here's a list of the places I've
bookmarked:
http://www.python.org/doc/ and more specifically
http://wiki.python.org/moin/
http://wiki.python.org/moin/BeginnersGuide
http://www.python.org/doc/Intros.html
http://www.python.org/topics/
|
by: John Salerno |
last post by:
After my last post, I thought of another question as a result of the
following:
------------------------------
Mike Meyer wrote:
> John Salerno <johnjsal@NOSPAMgmail.com> writes:
>
>
>>So my question is, is this feasible?
>
| |
by: Max |
last post by:
On monday I start a semester course in Python (the alternative was
Java). I was looking through the course outline and noticed the following:
1) UserDict is used. This is deprecated, right?
2) There is no mention of list comprehensions, but map and filter are
taught early and then revisited later. I don't think this is good: list
comprehensions are, IMO, one of Python's great features, Psyco prefers
them, they're more pythonic, and map...
|
by: jbchua |
last post by:
Hello everybody.
I am an Electrical Engineering major and have dabbled in several
languages such as Python, C, and Java in my spare time because of my
interest in programming. However, I have not done any practical
programming because I have no idea where to get started. I taught
myself these languages basically by e-tutorials and books. This makes
me feel as if I don't really know how to implement these languages.
Does anybody have any...
|
by: neptundancer |
last post by:
Hi,
to extend my skills, I am learning python. I have written small
program which computes math expression like "1+2*sin(y^10)/cos(x*y)"
and similar, so far only + - * / ^ sin con tan sqrt are supported. But
my program is quite inextensible, I have to change the code to add new
functions... Could some fellow experienced pythonista give me some
tips how to make my program shorter, and more extensible?
to use it, try something like...
|
by: John Salerno |
last post by:
Just something that crosses my mind every time I delve into "Learning
Python" each night. Does anyone see any value in learning Python when you
don't need to for school, work, or any other reason? I mean, sure, there's
value in learning anything at any time, but for something like a programming
language, I can't help but feel that I will be mostly unable to use what I
learn simply because I have no reason to use it.
The *process* of...
|
by: duli |
last post by:
Hi:
I would like recommendations for books (in any language, not
necessarily C++, C, python) which have walkthroughs for developing
a big software project ? So starting from inception, problem
definition, design, coding and final delivery on a single theme
or application.
Most of the code I have written and books that I have read deal with
toy programs and I am looking for something a bit more
comprehensive. For example, maybe a...
|
by: Hystou |
last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it.
First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
| |
by: Oralloy |
last post by:
Hello folks,
I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>".
The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed.
This is as boiled down as I can make it.
Here is my compilation command:
g++-12 -std=c++20 -Wnarrowing bit_field.cpp
Here is the code in...
|
by: jinu1996 |
last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth.
The Art of Business Website Design
Your website is...
|
by: agi2029 |
last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own....
Now, this would greatly impact the work of software developers. The idea...
|
by: isladogs |
last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM).
In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules.
He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms.
Adolph will...
|
by: conductexam |
last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one.
At the time of converting from word file to html my equations which are in the word document file was convert into image.
Globals.ThisAddIn.Application.ActiveDocument.Select();...
|
by: TSSRALBI |
last post by:
Hello
I'm a network technician in training and I need your help.
I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs.
The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols.
I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
| |
by: adsilva |
last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
|
by: bsmnconsultancy |
last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...
| |