Re: (no subject)

2020-01-06 Thread Rob Gaddi

On 1/4/20 2:29 PM, William Johnsson wrote:

Hello! My name is William and im 14 years old and live in sweden.  Im pretty 
new to programing in python and i need some help with code, (That’s why i’m 
here). But i couldn’t really find what i was searching for on the internet. I’m 
trying to write code that can check only the first line in a .txt file and 
check if it’s the same as the int 1000.   I preferably want it to be an if 
satement but anything works, i just don’t know how i should write it. I’ve been 
browsing the internet for a solution but sadly can’t seem to find a solution to 
it.

I don’t really know if this is the right way to get help or even if this email 
is for something else. Hopefully i will get some kind of response.

Best regards, William



It won't be; it can't be.  A text file contains only text.  The line you read 
from it might be the string '1000' (or more likely '1000\n', which is 4 digits 
followed by a newline character), but it cannot be the int 1000 because data has 
types.


str(1000) gives you '1000', because ints can be converted to strings. 
int('1000') gives you 1000 because and strings consisting only of digits can be 
converted to ints.  So the two types are convertible into one another.  But 
that's a thing you need to do explicitly.  If x is a thing you just read from a 
text file then


if x == 1000:

can never be true.
--
https://mail.python.org/mailman/listinfo/python-list


Re: (no subject)

2019-05-31 Thread Alister via Python-list
On Wed, 29 May 2019 08:07:06 +0530, Sri Tharun wrote:

> Why I am unable to install packages

because you are doing it wrong
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: (no subject)

2019-04-19 Thread Luuk

On 19-4-2019 16:37, Tamara Berger wrote:

Hi Python-List,

What code can I use to break out of a program completely, and not just out
of a loop? I wrote code with 3 conditions for saving for a downpayment. The
first addresses cases that don't meet the minimum condition; i.e., enough
money to save for a downpayment within the allotted time. It has its own
print line, but also executes the irrelevant print lines for the other two
conditions.

Thanks,
Tamara



cond1 = 1;
cond2 = 1;
cond3 = 1;

if cond1:
  if cond2:
if cond3:
  print("All OK")
else:
  print("cond3 NOK")
  else:
print("cond2 NOK")
else:
  print("cond1 NOK")



--
Luuk
--
https://mail.python.org/mailman/listinfo/python-list


Re: (no subject)

2019-04-19 Thread Luuk

On 19-4-2019 16:37, Tamara Berger wrote:

Hi Python-List,

What code can I use to break out of a program completely, and not just out
of a loop? I wrote code with 3 conditions for saving for a downpayment. The
first addresses cases that don't meet the minimum condition; i.e., enough
money to save for a downpayment within the allotted time. It has its own
print line, but also executes the irrelevant print lines for the other two
conditions.

Thanks,
Tamara



cond1 = 1;
cond2 = 1;
cond3 = 1;

if cond1:
  if cond2:
if cond3:
  print("All OK")
else:
  print("cond3 NOK")
  else:
print("cond2 NOK")
else:
  print("cond1 NOK")



--
Luuk
--
https://mail.python.org/mailman/listinfo/python-list


Re: (no subject)

2018-06-10 Thread Rick Johnson
sagar daya wrote:
> Couldn't install any module from pip
> Plz help???

As with most actions, an algorithm is required. (shocking, i
know!)

What methodology have you implemented thus far to achieve
your goal of "installing modules from PIP"? Please enumerate
the steps you chose to take, and then we _might_ can offer
advice.

For instance, if someone is having trouble brushing their
teeth, the first question we might ask is: "Have you located
the toothbrush and toothpaste yet?". 

-- 
https://mail.python.org/mailman/listinfo/python-list


Re: (no subject)

2018-03-27 Thread Rick Johnson
On Tuesday, March 27, 2018 at 7:19:53 AM UTC-5, kevon harris wrote:
> Unable to pull up IDLE after downloading Python 3.6.4
> 
> Sent from Mail for Windows 10

What OS?

On Windows running Python2.X, IDLE is located @ '/Python2X/Lib/idlelib/idle.pyw'
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: No Subject

2005-07-02 Thread Andreas Kostyrka
Am Freitag, den 01.07.2005, 18:55 +0200 schrieb Harry George: 
> Tom Anderson <[EMAIL PROTECTED]> writes:
> 
> > On Fri, 1 Jul 2005, Adriaan Renting wrote:
> > 
> > > I'm not a very experienced Python programmer yet, so I might be
> > > mistaken, but there are a few things that would make me prefer C++
> > > over Python for large (over 500.000 LOC) projects.
> 
> Strictly in terms of software engineering and language design, Python
> may well be better suited to large projects than C++ or Java.  Code
> re-use, original coding and prototyping, unittests, and peer reviews
> are a lot easier with Python than with C++ or Java.
> 
> The problem is that large projects tend to have portions which are
> performance sensitive.  So a project might be 100K LOC of C with 200K
> LOC of Python.

In my personal opinion, one can often do lowlevel performance code in a
Python-ese way by using Pyrex. And it gets the additional benefit, that
you pay the "higher line count per feature" that C forces on the
developer only for the part that does this lowlevel manipulation.

> They serve the same purpose but are not 1:1 with a file.  I personally
> can't think of a situation where I'd want 2 or more namespaces in a
> physical file, or 2 or more files per namespace.  Therefore I don't
> see any advantage in the C++ approach.

In some ways namespaces are even less flexible as Python modules.

> Templates address (I hesitate to say "solve") static typing by adding
> back the polymorphism that static typing eliminates.
> 
> Python avoids the fix-on-a-fix by doing dynamic strong typing in the
> first place.

Actually C++ templates are a fix. They are one way to avoid the type
system in C++. A template that takes a class argument takes any class
that has all needed "features and methods". Just as in Python. So it's a
crazy kind of compile-time late-binding. And guess, this static typing
in C++ is so sucessful, that many people consider modern C++ to be a
generics oriented language, and not an OO language.

> 
> > 
> > Not that this is necessarily a good thing. I have to say that my Java
> > roots do lead me to think that strong typing is a plus for big
> > projects, since it's a way of defining and enforcing interfaces
> > between bits of code written by different people (or by one person at
> > different times!). Optional static typing in python would be nice for
> > this.
> > 
> 
> Java has nothing on Modula-3.  Talk about strong static typing... It
Well, Java got a VM. And multiple interface "inheritance". And a huge
"standard" library. 

M3 OTOH does have partial type revealing, which allows for more levels
than private, protected and public.
And even more important, M3 has the concept of safe and unsafe
modules/interfaces. Safety in M3-like sense is one of the more important
things in Python. If something goes wrong, in Python you usually just
have to read a traceback. In C/C++ you'll get a core file if you are
lucky. (Or just corrupted data) And if you are even luckier, the stack
in the core file uncorrupted, and you get a sensible backtrace.

In Python OTOH hand, when the traceback is not enough, one can always
work with settrace and other introspection tools.

IMHO languages like Python (or even Java) are a much better approach for
90% of the commercial development. There is just no rational explanation
why an application developer should have to deal with memory allocation
and freeing, dangling pointers, corrupted heaps, and all the other
benefits that C/C++ provide. ;)

> used to take me 3 days to get the first compile to run on a new
> project.
> 
> Yet after years of Modula-3 (and repeatedly seeing strong static typing
> pay off) I found python quite comfortable.  Somehow the problems
> strong static typing addresses aren't a problem.

Yes and no. The problem is that static typing addresses certain
problems, and provides a 90-98% solution. But that makes the remaining
bugs much nastier, because nobody expects them in a "static type
checked" program. Especially the type system of C++ is not powerful
enough to express certain things. On the other hand it provides for
really obscure features. How many C++ developers do know that casting
can change the pointer value? (Hint: Multiple inheritence)

So static typing gives in practice:

a) more lines of code (because variables have to type declared)

b) catches most errors of type errors.

c) forces one sometimes to hack around the type system. (AFAIK void *
hasn't been removed from C++, nor all that ugly casts ;) )

d) makes it harder to find type errors when you get them, because nobody
expects them anymore.

> 
> > > - data hiding
> > 
> > Surely you can hide data in python?
> > 
> 
> You can't genuinely hide data in Python.  The best you can do is the
> "_" idiom.  
> 
> The question is why was data hiding invented in the first place.  It
> prevents attempts to get at the underlying mechanisms instead of
> sticking with the external API.  There are two reasons for this:

Actua

Re: (No subject)

2004-12-16 Thread Steven Bethard
Jeremy Jones wrote:
Mark Devine wrote:
I'm brand new to python and I was wondering if anybody knew of a easy 
[snip]
You could use string.lower (make sure you "import string"):
string.lower is deprecated in Python 2.4.  Better to go with str.lower 
as Diez B. Roggisch suggested:

commands = [c.lower() for c in commands]
Steve
--
http://mail.python.org/mailman/listinfo/python-list


Re: (No subject)

2004-12-16 Thread Jeremy Jones
Mark Devine wrote:
Hi
I'm brand new to python and I was wondering if anybody knew of a easy way to change every character in a list into its lower case form. 

The list is like so:
commands = ['CLASS-MAP MATCH-ALL cmap1', 'MaTch Ip AnY', 'CLASS-map Match-Any 
cmap2', 'MaTch AnY', 'Policy-map policy1', 'Class cmap1', 'policy-Map policy2', 
'Service-PoLicy policy1', 'claSS cmap2']
and what I want is:
commands = ['class-map match-all cmap1', 'match ip any', 'class-map match-any 
cmap2', 'match any', 'policy-map policy1', 'class cmap1', 'policy-map policy2', 
'service-policy policy1', 'class cmap2']
Are there any defined method within any known modules to do this in one go?
Thanks in advance

_
Sign up for eircom broadband now and get a free two month trial.*
Phone 1850 73 00 73 or visit http://home.eircom.net/broadbandoffer
 

You could use string.lower (make sure you "import string"):
In [14]: commands
Out[14]:
['CLASS-MAP MATCH-ALL cmap1',
'MaTch Ip AnY',
'CLASS-map Match-Any cmap2',
'MaTch AnY',
'Policy-map policy1',
'Class cmap1',
'policy-Map policy2',
'Service-PoLicy policy1',
'claSS cmap2']
In [15]: commands_lower = [string.lower(f) for f in commands]
In [16]: commands_lower
Out[16]:
['class-map match-all cmap1',
'match ip any',
'class-map match-any cmap2',
'match any',
'policy-map policy1',
'class cmap1',
'policy-map policy2',
'service-policy policy1',
'class cmap2']
Jeremy Jones
--
http://mail.python.org/mailman/listinfo/python-list