@python.org
Subject: Re: [Tutor] Python function
On 13/12/2018 17:21, Sammy Lee wrote:
> How do I create a python function that opens a CSV file and determines
> how many columns of data are in the file? The CSV files have been
> randomly generated from https://www.mockaroo.com/
On 13/12/2018 17:21, Sammy Lee wrote:
> How do I create a python function that opens a CSV file and determines how
> many columns
> of data are in the file? The CSV files have been randomly generated from
> https://www.mockaroo.com/
>
> def csv_column_count(openfile):
You will find a bunch of
On Dec 13, 2018 1:55 PM, "Sammy Lee" wrote:
>
> How do I create a python function that opens a CSV file and determines
how many columns
> of data are in the file? The CSV files have been randomly generated from
https://www.mockaroo.com/
>
> def csv_column_count(openfile):
Same comments as I made
How do I create a python function that opens a CSV file and determines how many
columns
of data are in the file? The CSV files have been randomly generated from
https://www.mockaroo.com/
def csv_column_count(openfile):
___
Tutor maillist -
On 27/11/17 20:47, Howard Lawrence wrote:
> import turtle
> # this part draws a square
> def square():
>
> my_turtle = turtle.Turtle()
Note that this creates my_turtle as a local
variable inside the function. It will not
be visible outside the function.
> my_turtle.forward(100)
>
import turtle
# this part draws a square
def square():
my_turtle = turtle.Turtle()
my_turtle.forward(100)
my_turtle.left(90)
my_turtle.forward(100)
my_turtle.left(90)
my_turtle.forward(100)
my_turtle.left(90)
my_turtle.forward(100)
square()
my_turtle.forward(100)
Thankyou. got it.
On Sat, Apr 15, 2017 at 5:44 AM, Steven D'Aprano
wrote:
> On Fri, Apr 14, 2017 at 11:59:25PM +0530, shubham goyal wrote:
>
> > sorted(ls)
> > sorted(ls1)
>
> Here you sort ls and throw the result away, then you do the same to ls1.
>
> sorted() makes a
On Fri, Apr 14, 2017 at 11:59:25PM +0530, shubham goyal wrote:
> sorted(ls)
> sorted(ls1)
Here you sort ls and throw the result away, then you do the same to ls1.
sorted() makes a copy of the list and sorts it. You need to write:
ls = sorted(ls)
ls1 = sorted(ls1)
but even better would be
Change your code to
def front_x(words):
# +++your code here+++
ls=[]
ls1=[]
for str in words:
if str[0]=='x':
ls.append(str)
else:
ls1.append(str);
print ls
print ls1
ls = sorted(ls)
ls1 = sorted(ls1)
ls.extend(ls1)
return ls
regards,
Sarma.
On 14/04/17 19:29, shubham goyal wrote:
> sorted function is not working when i am trying to sort the list of strings
> but list.sort() is working. can you please help me understand.
sort() sorts the list "in place". That is it sorts itself.
sorted() returns a sorted copy of the list. It does
Dear mentors,
sorted function is not working when i am trying to sort the list of strings
but list.sort() is working. can you please help me understand.In this
question i was trying to sort the list but first sorting the letter
starting from x and taking them first.
def front_x(words):
#
On 13/04/17 17:10, marcus lütolf wrote:
> Dear experts, Mats
> I have found the solution, I put the counting variable at the wrong place:
I don;t think so, what you have done now is count the times
through the loop, but thats not (always) the same as the
number of times the function gets called,
rdInterrupt:
> print('PIR deaktiviert')
Marcus.
-Ursprüngliche Nachricht-
Von: Mats Wichmann [mailto:m...@wichmann.us]
Gesendet: Montag, 10. April 2017 15:15
An: marcus lütolf <marcus.luet...@bluewin.ch>; tutor@python.org
Be
On 04/10/2017 01:55 AM, marcus lütolf wrote:
> Dear experts,
> I have written the following code for motion detection with a PIR sensor
> with a function and
> I need to count how many times the funtion is called, but I get a traceback:
>
> #!/usr/bin/python3
> import sys, time
> import RPi.GPIO
On 10/04/17 08:55, marcus lütolf wrote:
> Dear experts,
> I have written the following code for motion detection with a PIR sensor
> with a function and
> I need to count how many times the funtion is called, but I get a traceback:
>
> #!/usr/bin/python3
> import sys, time
> import RPi.GPIO as
Dear experts,
I have written the following code for motion detection with a PIR sensor
with a function and
I need to count how many times the funtion is called, but I get a traceback:
#!/usr/bin/python3
import sys, time
import RPi.GPIO as gpio
gpio.setmode(gpio.BOARD)
gpio.setup(23, gpio.IN)
On 15/02/17 04:43, eryk sun wrote:
>> value = 1e5 # or 3e7 or whatever...
>
> 10**5 is an int and 1e5 is a float.
Good point, I'd forgotten about that distinction.
> Replacing 10**5 with 10 is a compile-time optimization
And didn't know about that one.
Thanks for the clarification.
--
On Tue, Feb 14, 2017 at 11:01 PM, Alan Gauld via Tutor wrote:
> To compute it if you don't know x in advance then yes,
> use something like
>
> value = 10**x
>
> But if you know the value in advance you can write it in
> a more compact form as:
>
> value = 1e5 # or 3e7 or
On 14/02/17 12:03, Aaliyah Ebrahim wrote:
> For the function 1*10^x, is there a specific way of computing *10^x or will
> it just be the following :
>
> 1*10**x
To compute it if you don't know x in advance then yes,
use something like
value = 10**x
But if you know the value in advance you can
Hi
For the function 1*10^x, is there a specific way of computing *10^x or will
it just be the following :
1*10**x
Thank you.
___
Tutor maillist - Tutor@python.org
To unsubscribe or change subscription options:
On Mon, Dec 12, 2016 at 2:29 PM, Bryon Adams wrote:
> Is there a way to force my argument to always be a string before entering
> the function?
You could do the following:
1. Use `def ip_checker(ip_address: str):` to make it more clear that
you're expecting a str,
>---
>Error from interpreter: (looks like it's taking issue with it being a
>number it doesn't know how to deal with)
>
ip_checker(169.254.0.1)
> File "", line 1
> ip_checker(169.254.0.1)
>^
>SyntaxError: invalid syntax
Use the str() function.
M
On Thu, 15 Dec 2016, 07:56 Bryon Adams, wrote:
> Is there a way to force my argument to always be a string before
> entering the function? Else, is there a better way to go about this? In
> whatever program I write, I could change what I
2016-12-12 17:29 GMT+01:00 Bryon Adams :
> Is there a way to force my argument to always be a string before entering
> the function? Else, is there a better way to go about this? In whatever
> program I write, I could change what I want as input to be a string prior
>
Am 12.12.2016 um 17:29 schrieb Bryon Adams:
Is there a way to force my argument to always be a string before
entering the function? Else, is there a better way to go about this? In
whatever program I write, I could change what I want as input to be a
string prior to tossing it into the function
Is there a way to force my argument to always be a string before
entering the function? Else, is there a better way to go about this? In
whatever program I write, I could change what I want as input to be a
string prior to tossing it into the function but I think it would make
more sense for
On 05/11/16 12:07, Peter Otten wrote:
> sum_highest = lambda items, n: sum(sorted(items, reverse=True)[:max(n, 0)])
>
> or better:
>
> import heapq
>
> def sum_highest(items, n):
> return sum(heapq.nlargest(n, items))
No, the first solution is "better" because it used lambda
and slicing
Lloyd Francis wrote:
> I want to write a function that will calculate and return the sum of the
> *n* highest value in a list *a. *Also, when n is less than 0, the answer
> should be zero, and if n is greater than the number of elements in the
> list, all elements should be included in the sum.
>
Interesting. Tracey Jones has a very similar question...
- Cameron Simpson
On 04Nov2016 16:44, Lloyd Francis wrote:
Hi,
I want to write a function that will calculate and return the sum of the *n*
highest value in a list *a. *Also, when n is less than
On 04/11/16 16:44, Lloyd Francis wrote:
It looks suspiciously like you posted this same message
from two addresses with different subjects, please don't
do that as it splits the responses and makes searching
archives more difficult.
> I want to write a function that will calculate and return the
Hi,
I want to write a function that will calculate and return the sum of the *n*
highest value in a list *a. *Also, when n is less than 0, the answer should
be zero, and if n is greater than the number of elements in the list, all
elements should be included in the sum.
In addition i want to
On Fri, Jan 15, 2016 at 05:07:58PM +, Chad Perry wrote:
> I need to know how to substitute for the drive letter for the following
> drives.
>
> sad-sdp
> also will need to wipe data from /dev/md1
>
> I believe that the script is sound just sub's
I don't understand your question.
#The function for writing random data to the disk.
def random():
print ""
os.system("/sbin/fdisk -l")
print ""
print "Please choose a device to kill. Remember if you want to"
print "wipe the whole drive and not just a partition, you can"
print "remove the number appended.
On 15/01/16 17:07, Chad Perry wrote:
> #The function for writing random data to the disk.
> def random():
>os.system("/sbin/fdisk -l")
>device=raw_input("Enter device: ")
>count=input("How many times would you like to wipe the device? ")
>raw_input("Press Enter to continue, or
Hello,
Thank you for your response. I went back and updated encoding to utf-8 and
ASCII but I still experienced issues with the output.
The part that is interesting is that the output for each of the following
fields is the (should be) the same 1.Search by City
2.Search by Region (State
On 21/10/15 01:18, Nym City via Tutor wrote:
def zip_search(query):
api_key = locu_api
url = 'https://api.locu.com/v1_0/venue/search/?api_key=' + api_key
zip = query.replace(' ', '%20')
final_url = url + '=' + zip + "=restaurant"
jason_obj = urllib2.urlopen(final_url)
Hello,
Thank you for your feedback. Sorry it took me a while to revise my code but
here is my code with the changes:
import urllib2
import json
locu_api = 'redacted'
def locu_search(query):
api_key = locu_api
url = 'https://api.locu.com/v1_0/venue/search/?api_key=' + api_key
Peter Otten wrote:
> The use of {...} makes this a set literal, and the order of the items in a
> set is undefined. To prevent a class of attacks on web applications it may
> even change between invocations:
Sorry, I forgot to include the source of setdemo.py. It contains just one
line:
print
Hi,
I started with python web module and i have no experience with web.
I used the example which is on the web.py site -
--
import web
urls = {
'/', 'index'
}
class index:
def GET(self):
return "Hello World"
if __name__ ==
Rahul Pathak wrote:
> Hi,
>
> I started with python web module and i have no experience with web.
>
> I used the example which is on the web.py site -
>
> --
> import web
>
> urls = {
> '/', 'index'
> }
>
> class index:
> def GET(self):
>
On 18/10/15 06:09, Rahul Pathak wrote:
Hi,
I started with python web module and i have no experience with web.
OK, web.py is not part of the standard library and I have no
experience with that specific framework. I also see Peter Otten
has picked up an issue about the urls set. But there's
Thank you for your response. I updated the first portion of my code to include
breaks:
import urllib2
import json
locu_api = 'redacted'
ans=True
while ans:
print ("""
1.Search by City
2.Search by Region (State Abbreviation)
3.Search by Zip
4.Exit/Quit
""")
On 13/10/15 00:32, Nym City wrote:
ans=raw_input("What would you like to do? ")
if ans=="1":
locality = raw_input("\nEnter City ")
break
elif ans=="2":
region = raw_input("\n Search by State ")
break
elif ans=="3":
zip = raw_input("\n Search by
On 11/10/15 22:22, Nym City wrote:
import urllib2
import json
locu_api = 'redacted'
ans=True
while ans:
print ("""
1.Search by City
2.Search by State
3.Search by Zip
4.Exit/Quit
""")
ans=raw_input("What would you like to do? ")
if ans=="1":
print("\n Enter
Thank you for your feedback. I modified the code to reflect your suggestion and
it worked. Now, I want to take it to the next level when I prompt the user to
make a selection from a list of options and based on their input certain part
of the code would execute. Here is the revised code:(site:
Hello,
I am learning how to create custom functions and watched the tutorial online
that uses API for locu to do cool stuff. I wanted to go little bit beyond the
tutorial and add my own features. The problem that I am running into is that I
cannot figure out how to prompt a user to input their
On 29/09/15 00:45, Nym City via Tutor wrote:
I am learning how to create custom functions and watched the
> tutorial online that uses API for locu
Since most folks here probably don't know locu you should
maybe give us a URL. Then we can know what it is you are
talking about.
I cannot
On 8/4/2015 3:16 PM, Michael Roberts via Tutor wrote:
I'm having a few problems defining a Schecter function in python. Without going
into too much detail I need to add a +0j factor for matplotlib to plot the
function in real and imaginary space. I know that this is not what should be
Sure, but let me include the full working program after fixup
On 29 April 2015 at 19:09, Cameron Simpson c...@zip.com.au wrote:
These could all do with docstrings. add() is pretty obvious, but the
distinction between minus() and subtract() could do with elaboration.
etc, etc.
Thanks.
On 28 April 2015 at 22:40, Cameron Simpson c...@zip.com.au wrote:
As with all things, sometimes that cannot be reasonably achieved, but it
is usually so.
We can pick over your code as well if you like. Should we?
Cheers,
Cameron Simpson c...@zip.com.au
Sure, but let me include the full
On 29Apr2015 08:34, Jim Mooney Py3.4.3winXP cybervigila...@gmail.com wrote:
On 28 April 2015 at 22:40, Cameron Simpson c...@zip.com.au wrote:
We can pick over your code as well if you like. Should we?
Sure, but let me include the full working program after fixup. Although I
still have to
I am a beginner at python programming and right now we have to write the text
to design a program that will make a histogram for Benford's law which says
that in a natural set of data 1 will appear more than 2 which will appear more
than 3 and so on. So given a set of data I want a list
Since I'm new to python and don't really know how to write programs yet, my
first question would be what exactly is the main function, because we did a
similar assignment before this one that included it, and I'm not sure what
exactly it does.
When you write a program, you write a collection
On 09/01/14 00:33, Manoj Rout wrote:
I have been working with python from last couple of weeks. As I am new
to python I have a problem with my work. So can you please look into the
below code.
with open('C:\\Users\\Manoj\\Desktop\\XMC1100_rm_v1.0.6_SVD.xml','r') as
xmlfile:
to multiply the arguments
How in the original def mult(a, b) . . .,
does mult(a, b-1) say return the product of a and b-1?
-Original Message-
From: Alan Gauld alan.ga...@btinternet.com
To: tutor@python.org
Sent: Thu, 12 Dec 2013 0:27
Subject: Re: [Tutor] recursive function example
On 12/12/13 04:18, uga...@talktalk.net wrote:
In a way,it may help to identify the issue
def multiply(a,b)
return a*b
clearly returns the product of the two arguments, a and b
I presume it returns a+a rather than b+b+b
It depends on how multiplication is implemented in the CPU microcode.
Oops, I got this slightly wrong.
On 12/12/13 08:50, Alan Gauld wrote:
mult(3,0)
It returns zero because b is zero, right?
Now consider what it does for
mult(3,1)
It checks if b is zero, it's not, so it executes
rest = 3 + mult(3,0)
Sorry, it actually does:
rest = mult(3,0)
So rest
On 12/12/2013 04:18, uga...@talktalk.net wrote:
I don't mind you asking if you don't understand something, but please
don't top post on this list, it makes following discussions such as this
more difficult than it need be.
--
My fellow Pythonistas, ask not what our language can do for you,
-Original Message-
From: Alan Gauld alan.ga...@btinternet.com
To: tutor@python.org
Sent: Wed, 11 Dec 2013 0:29
Subject: Re: [Tutor] recursive function example
On 10/12/13 14:48, uga...@talktalk.net wrote:
Here is original code:
def mult(a, b):
if b == 0
On 10/12/13 14:48, uga...@talktalk.net wrote:
OK, I'll try again, this time just walking through the code from the top.
def mult(a, b):
if b == 0:
return 0
rest = mult(a, b - 1)
value = a + rest
return value
print 3 * 2 = , mult(3, 2)
We print 3 * 2 = and
On 12/10/2013 03:48 PM, uga...@talktalk.net wrote:
[...]
Recursivity is hard to get really, meaning intuitively with your guts so-to-say.
Maybe using another example may help. Lets us say you want a function that sums
numbers from 1 up to n, the only input variable. (The result should thus
On 12/11/2013 09:50 AM, Alan Gauld wrote:
Remember that each time mult() is called it creates
its own mini-world of variables independent of the
previous calls.
That, is a key point.
Denis
___
Tutor maillist - Tutor@python.org
To unsubscribe or
+, is it a typo perhaps?
Many thanks.
-A
-Original Message-
From: Alan Gauld alan.ga...@btinternet.com
To: tutor@python.org
Sent: Wed, 11 Dec 2013 9:05
Subject: Re: [Tutor] recursive function example
On 10/12/13 14:48, uga...@talktalk.net wrote:
OK, I'll try again, this time just
-
From: spir denis.s...@gmail.com
To: tutor@python.org
Sent: Wed, 11 Dec 2013 13:15
Subject: Re: [Tutor] recursive function example
On 12/10/2013 03:48 PM, uga...@talktalk.net wrote:
[...]
Recursivity is hard to get really, meaning intuitively with your guts
so-to-say. Maybe using another
On 10/12/2013 14:48, uga...@talktalk.net wrote:
[snipped]
As you're clearly struggling here's my attempt at showing you what is
happening.
c:\Users\Mark\MyPythontype mytest.py
level = 0
def mult(a, b):
global level
level += 1
print('level now', level, 'a =', a, 'b =', b)
if
On 11/12/13 12:36, uga...@talktalk.net wrote:
What I do not see is how?
Clearly, a = 3, it is constant throughout each iteration, and
if rest is equal to 3, then a + rest must be equal to 6.
Correct and the return value from the second invocation of mul() is 3.
You spoke of drilling down,
On 12/11/2013 03:56 PM, uga...@talktalk.net wrote:
Self-similar (fractal) recursion, sounds complex, I am guessing this is like
linear recursion but simultaneously in more than one dimension?
Curious business really. Wonders, if I may be a closet programmer, or something,
It is not complex,
On 12/11/2013 07:15 PM, Alan Gauld wrote:
Remember we are calling mul() several times, each with a new set of values.
So mul(3,2) calls mul(3,1)
and mul(3,1) calls mul(3,0)
mul(3.0) returns 0 to mul(3,1)
mul(3,1) then returns 3+0 = 3 to mul(3,2)
mul(3,2) returns 3+3 = 6.
This is a very
This is a pretty good clarification! (debug prints well designed and well
placed)
Congrats, Mark!
denis
On 12/11/2013 06:37 PM, Mark Lawrence wrote:
On 10/12/2013 14:48, uga...@talktalk.net wrote:
[snipped]
As you're clearly struggling here's my attempt at showing you what is happening.
Dec 2013 17:38
Subject: Re: [Tutor] recursive function example
On 10/12/2013 14:48, uga...@talktalk.net wrote:
[snipped]
As you're clearly struggling here's my attempt at showing you what is
happening.
c:\Users\Mark\MyPythontype mytest.py
level = 0
def mult(a, b):
global level
On 11/12/13 18:09, uga...@talktalk.net wrote:
No, not really.
mutl(3, 2) has two arguments
rest = mult(a, b - 1) also has two arguments
rest does not have any arguments.
arguments are the values you pass *into* a function.
The function in turn passes back a return value.
In this case rest is
I am looking at a simple recursive function, and oxymoron aside, I am having
difficulty in seeing what occurs. I have tried adding some debug print commands
to help break the thing down. This helps a lot, but I still have a question
that I need help with.
Here is original code:
def mult(a, b):
On 10/12/13 14:48, uga...@talktalk.net wrote:
Here is original code:
def mult(a, b):
if b == 0:
return 0
rest = mult(a, b - 1)
value = a + rest
return value
print 3 * 2 = , mult(3, 2)
I see how python outputs the string mult(3,2) before running the
function,
No
Too bad that doesn't work.
On Nov 16, 2013, at 11:16 PM, Alex Kleider wrote:
On 2013-11-16 13:20, Byron Ruffin wrote:
def main(x, y, z):
print (x, y, z)
def funct():
x = 1
y = 2
z = 3
return x, y, z
main()
Can someone tell me why main is not being given any
On 17/11/13 05:16, Alex Kleider wrote:
On 2013-11-16 13:20, Byron Ruffin wrote:
def main(x, y, z):
print (x, y, z)
def funct():
x = 1
y = 2
z = 3
return x, y, z
main()
Can someone tell me why main is not being given any arguments?
Because you didn't give it any.
Try
On 17/11/2013 06:31, John Aten wrote:
Too bad that doesn't work.
On Nov 16, 2013, at 11:16 PM, Alex Kleider wrote:
On 2013-11-16 13:20, Byron Ruffin wrote:
def main(x, y, z):
print (x, y, z)
def funct():
x = 1
y = 2
z = 3
return x, y, z
main()
Can someone tell me why
On 2013-11-17 00:47, Alan Gauld wrote:
On 17/11/13 05:16, Alex Kleider wrote:
On 2013-11-16 13:20, Byron Ruffin wrote:
def main(x, y, z):
print (x, y, z)
def funct():
x = 1
y = 2
z = 3
return x, y, z
main()
Can someone tell me why main is not being given any arguments?
On 2013-11-16 22:31, John Aten wrote:
Too bad that doesn't work.
No, it doesn't. Can you see why?
Attached is a version that does work but you'd be better served looking
at the two versions you already have and studying the error messages you
get when you run them.
On Nov 16, 2013, at
def main(x, y, z):
print (x, y, z)
def funct():
x = 1
y = 2
z = 3
return x, y, z
main()
Can someone tell me why main is not being given any arguments?
___
Tutor maillist - Tutor@python.org
To unsubscribe or change
main()
Can someone tell me why main is not being given any arguments?
Because you didn't write any there.
-nik
--
Wer den Grünkohl nicht ehrt, ist der Mettwurst nicht wert!
PGP-Fingerprint: 3C9D 54A4 7575 C026 FB17 FD26 B79A 3C16 A0C4 F296
signature.asc
Description: Digital signature
On 16/11/13 21:20, Byron Ruffin wrote:
def main(x, y, z):
print (x, y, z)
def funct():
x = 1
y = 2
z = 3
return x, y, z
main()
Can someone tell me why main is not being given any arguments?
Because somebody made a mistake.
I don't know if this is your code or
Hello!I´m using Idle (Python 2.7,5 version). I´m trying to write a program of
compare function that returns 1 if a b , 0 if a == b , and -1
if a b . In which I´m want to get the user to prompt for the values of a and
b. For some reason I can´t run it. The follwing is what I have written on
On 14/10/13 15:41, Sammy Cornet wrote:
. In which I´m want to get the user to prompt for the values of a and b.
So where is the code where you prompt the user and read input.
All we can see is a single function?
For some reason I can´t run it. The follwing is what I have written on
my
Hi, I am taking a class in order to learn Python. One of the exercises I need
to do is write function definitions. I cannot figure out how to do one of them.
To show you an example here is a similar problem:
If m is an integer, then isPrime(m) iff m is prime.The code:
# Prompts the user for an
Hi Connor,
On 2013-10-08 17:50, Connor Hood wrote:
Hi, I am taking a class in order to learn Python. One of the exercises I need
to do is write function definitions. I cannot figure out how to do one of
them. To show you an example here is a similar problem:
If m is an integer, then
On 08/10/13 23:50, Connor Hood wrote:
# isPrime(m): I - Bool
# If m is an integer, then isPrime(m) if and only if m is prime.
def isPrime(m):
return False if m = 1 else isPrimeItr(1,0,m)
# isPrimeItr(i,a,m): I x I x I - Bool
def isPrimeItr(i,a,m):
return False if a 2 else True if a
On 8/10/2013 18:50, Connor Hood wrote:
Hi, I am taking a class in order to learn Python.
Welcome to Python, and to Python-tutor.
One of the exercises I need to do is write function definitions. I
cannot figure out how to do one of them. To show you an example here is a
similar problem:
On 2013-10-09 11:28, Dave Angel wrote:
Alan's suggestions pretty much cover mine. Make your code readable,
rather than clever while you're learning.
s/while you're learning//
pgpjKcnwi1MeE.pgp
Description: PGP signature
___
Tutor maillist -
On 9/10/2013 07:35, Chris Down wrote:
On 2013-10-09 11:28, Dave Angel wrote:
Alan's suggestions pretty much cover mine. Make your code readable,
rather than clever while you're learning.
s/while you're learning//
But by the time you learn enough, you realize that when you stop
learning
Hi,
I have a class and I want it's initializer to be able to take both byte strings
(python 3: byte objects) and unicode strings (python 3: strings). So it's
foward compatible Python 2 code (or backward compatible Python 3 code, if you
like). If needed, the arguments of __init__ are converted
On 7/9/2013 15:45, Albert-Jan Roskam wrote:
Hi,
I have a class and I want it's initializer to be able to take both byte
strings (python 3: byte objects) and unicode strings (python 3: strings). So
it's foward compatible Python 2 code (or backward compatible Python 3 code,
if you like).
On Sat, Sep 07, 2013 at 12:45:02PM -0700, Albert-Jan Roskam wrote:
Hi,
I have a class and I want it's initializer to be able to take both
byte strings (python 3: byte objects) and unicode strings (python 3:
strings). [...] I need bytes because I am
working with binary data.
Consider
Hi Phil,
On 2013-08-10 16:45, Phil wrote:
The Arduino has a map function named map which looks like this:
map(value, 0, 1023, 0, 100)
The function, in this case, takes an integer value between 0 and
1023 and returns a number between 0 and 100. Is there a Python
equivalent?
The Arduino
On 28/06/13 05:18, Jim Mooney wrote:
What's the Pythonic standard on multiple returns from a function?
There is no standard.
Multiple returns are quite common but they come with all the usual
caveats for using them, they can introduce complexity and hard
to find bugs so use them sensibly.
On 28/06/13 14:18, Jim Mooney wrote:
What's the Pythonic standard on multiple returns from a function? It
seems easiest to just return from the point where the function fails
or succeeds, even it that's multiple points. Or is it considered best
to defer everything to one return at the end?
On 06/28/2013 12:06 PM, Jim Mooney wrote:
def foo(x):
... if x:
... return True
... return False
I'll leave it to you to work out why that works. It's very handy!
Hey, it saves typing an else and as you know, I'm the Lazy Typist.
My program to make dicts, lists, etc from a
On 28/06/13 19:51, Jim Mooney wrote:
Now you'll make me learn what lambda is.
Ah, it's like an anonymous function in jQuery,
That's the idea but Python lambdas are a bit crippled
so its really an anonymous expression... :-(
But if you know JQuery then lambdas should be
easy to pick up. And
Hi everyone, trying to write a program that has the user enter a password,
checks if it contains any vowels, and if it does prints ' It is false that
password(whatever the user enters) has no vowels,' and if it has no vowels
prints it is True that password has no vowels...
Here is what I have
On Wed, Feb 6, 2013 at 1:44 PM, Mara Kelly schooluse1...@yahoo.com wrote:
Hi everyone, trying to write a program that has the user enter a password,
checks if it contains any vowels, and if it does prints ' It is false that
password(whatever the user enters) has no vowels,' and if it has no
On Wed, Feb 6, 2013 at 9:44 PM, Mara Kelly schooluse1...@yahoo.com wrote:
Hi everyone, trying to write a program that has the user enter a password,
checks if it contains any vowels, and if it does prints ' It is false that
password(whatever the user enters) has no vowels,' and if it has no
1 - 100 of 292 matches
Mail list logo