Programming, computers, etc. [Serious]

All things asdf (and anything else)
User avatar
Anonymously Famous
JKL; Assassin
JKL; Assassin
Posts: 11413
Joined: Thu Mar 03, 2011 6:52 pm
Location: Area ???, under Bermuda Triangle

Re: Programming, computers, etc. [Serious]

Post by Anonymously Famous » Thu Sep 27, 2012 5:36 pm

Internally it does it through tuples (a type of list or array), which can be unpacked to several variables.

Here's something I did in the Python interactive interpreter just now:

Code: Select all

>>> def someFunction(parameter):
	#Do some stuff
	return 1, 2

>>> a, b = someFunction(5)
>>> a
1
>>> b
2
You can use any list-like data structure.

Code: Select all

>>> def someFunction(parameter):
	#Do some stuff
	return "ab"

>>> a, b = someFunction(None)
>>> a
'a'
>>> b
'b'
There are also iterators, that return a series of items, one at a time:

Code: Select all

>>> def fibonacci(maxNumber):
	a = 0
	b = 1
	if maxNumber > a: yield a
	if maxNumber > b: yield b
	while b < maxNumber:
		a, b = b, a + b
		if b < maxNumber: yield b

		
>>> for i in fibonacci(15):
	print i,

	
0 1 1 2 3 5 8 13
There's a function that allows you to traverse a folder structure that uses an iterator of multiple return values.

Code: Select all

>>> import os
>>> for currentDirectory, directories, files in os.walk("folderPath"):
	for fileName in files:
		doStuff(os.path.join(currentDirectory, fileName))
BOTTOM TEXT
ThingerDudes wrote:The only reasonable amount of Nutella is infinity. Everything else is too little.
Proud poster of the 300kth post in General

User avatar
atomtengeralattjaro
Site Admin
Site Admin
Posts: 35622
Joined: Wed May 23, 2007 3:43 pm
Location: green
Contact:

Re: Programming, computers, etc. [Serious]

Post by atomtengeralattjaro » Thu Sep 27, 2012 6:59 pm

hey that's pretty cool.

This reminds me of Matlab. i have a course where we learn some basic stuff in Matlab.
Ivokyuftaf6666 wrote:
Sun Oct 20, 2019 5:22 pm
Awesome Site, Delivering Fun
Image

User avatar
Anonymously Famous
JKL; Assassin
JKL; Assassin
Posts: 11413
Joined: Thu Mar 03, 2011 6:52 pm
Location: Area ???, under Bermuda Triangle

Re: Programming, computers, etc. [Serious]

Post by Anonymously Famous » Thu Sep 27, 2012 9:54 pm

In Python 3, which is the current version (though most people still use Python 2), you can even designate a "throw away" variable, which is a list of the other values that you don't want to keep.

Code: Select all

>>> a,b,*c = 1,2,3,4,5
>>> c
[3, 4, 5]
BOTTOM TEXT
ThingerDudes wrote:The only reasonable amount of Nutella is infinity. Everything else is too little.
Proud poster of the 300kth post in General

User avatar
atomtengeralattjaro
Site Admin
Site Admin
Posts: 35622
Joined: Wed May 23, 2007 3:43 pm
Location: green
Contact:

Re: Programming, computers, etc. [Serious]

Post by atomtengeralattjaro » Thu Sep 27, 2012 10:10 pm

huh?
what are a and b in this case? you marked c with a star, that makes it an array so that 1 and 2 will be in a and b, and any subsequent values will be in c? what makes it "throw away" then?
Ivokyuftaf6666 wrote:
Sun Oct 20, 2019 5:22 pm
Awesome Site, Delivering Fun
Image

User avatar
Anonymously Famous
JKL; Assassin
JKL; Assassin
Posts: 11413
Joined: Thu Mar 03, 2011 6:52 pm
Location: Area ???, under Bermuda Triangle

Re: Programming, computers, etc. [Serious]

Post by Anonymously Famous » Fri Sep 28, 2012 12:26 am

I guess "throw away" is the wrong term. More like "the rest."

The star signifies that they should all be packed in an array, and you can have the array either at the beginning or the end. The first (or last) values will go into each variable until they run into the one with the star. Then the last (or first) several will be put into that variable as an array.

I called it "throw away" because in some cases you only want the first several, and you don't care what's in the rest. But you can definitely use it, too.

Code: Select all

>>> add = lambda x,y: x+y
>>> function, first, *theRest = add,1,2,3,4,5,6,7,8,9,10
>>> totals = [function(first, y) for y in theRest]
>>> totals
[3, 4, 5, 6, 7, 8, 9, 10, 11]
BOTTOM TEXT
ThingerDudes wrote:The only reasonable amount of Nutella is infinity. Everything else is too little.
Proud poster of the 300kth post in General

User avatar
atomtengeralattjaro
Site Admin
Site Admin
Posts: 35622
Joined: Wed May 23, 2007 3:43 pm
Location: green
Contact:

Re: Programming, computers, etc. [Serious]

Post by atomtengeralattjaro » Fri Sep 28, 2012 2:01 pm

a-ha! that's cool. i can't imagine where would I use such a thing, but i see it's not pointless.
Ivokyuftaf6666 wrote:
Sun Oct 20, 2019 5:22 pm
Awesome Site, Delivering Fun
Image

john123abc201
ASDF-ville inhabitant
ASDF-ville inhabitant
Posts: 7
Joined: Wed Sep 21, 2011 7:38 pm

Re: Programming, computers, etc. [Serious]

Post by john123abc201 » Sat Sep 29, 2012 2:21 pm

Does anybody know how to install a cursor pack with an ini file?

User avatar
atomtengeralattjaro
Site Admin
Site Admin
Posts: 35622
Joined: Wed May 23, 2007 3:43 pm
Location: green
Contact:

Re: Programming, computers, etc. [Serious]

Post by atomtengeralattjaro » Sat Sep 29, 2012 2:53 pm

depends on the OS i guess..
i have no idea about cursor packs, but if you happen to have the individual .cur or .ani files for the different cursors, you can change them one by one in control panel/mouse/pointers.
Ivokyuftaf6666 wrote:
Sun Oct 20, 2019 5:22 pm
Awesome Site, Delivering Fun
Image

User avatar
atomtengeralattjaro
Site Admin
Site Admin
Posts: 35622
Joined: Wed May 23, 2007 3:43 pm
Location: green
Contact:

Re: Programming, computers, etc. [Serious]

Post by atomtengeralattjaro » Fri Oct 05, 2012 4:43 pm

boo! double poast because i never ever do that. Thus, traditionally, I deserve to die.

Image
Ivokyuftaf6666 wrote:
Sun Oct 20, 2019 5:22 pm
Awesome Site, Delivering Fun
Image

User avatar
MTG09
ASDF High Priest
ASDF High Priest
Posts: 2622
Joined: Tue Jan 10, 2012 12:42 am
Location: Earth
Contact:

Re: Programming, computers, etc. [Serious]

Post by MTG09 » Fri Oct 05, 2012 6:22 pm

It is relative and on topic. Therefore, any kind of necroposting or double posing is excused.
The secrets of life:
Anonymously Famous wrote:Is is is. [source]
...
And it always will be. [source]

User avatar
klinscy
ASDF Worshipper
ASDF Worshipper
Posts: 445
Joined: Tue Jan 17, 2012 10:05 pm
Location: Morgues, graveyards, hospitals, post-apocalyptic L.A.

Re: Programming, computers, etc. [Serious]

Post by klinscy » Sat Oct 06, 2012 1:53 pm

Blasphemy?
Captain Kirk wrote:"Very funny, Scotty. Now beam down my clothes."
Zim wrote:Now, now, GIR. Movies don't create psychos. Movies make psychos more creative.
Best acronym EVER
atomtengeralattjaro wrote: Effectively removed. Again, simply, essentially deleted.

User avatar
Anonymously Famous
JKL; Assassin
JKL; Assassin
Posts: 11413
Joined: Thu Mar 03, 2011 6:52 pm
Location: Area ???, under Bermuda Triangle

Re: Programming, computers, etc. [Serious]

Post by Anonymously Famous » Sat Oct 06, 2012 1:59 pm

Not any kind, but on-topic kinds are.

The other day I finished a Python script that helps my department do stuff. That's cool and all, but the really cool part is:
I made it bilingual (kind of). It works with both Python 2 and Python 3! That's tricky, given some of the differences in standard module locations and the fact that strings are represented differently.
BOTTOM TEXT
ThingerDudes wrote:The only reasonable amount of Nutella is infinity. Everything else is too little.
Proud poster of the 300kth post in General

User avatar
atomtengeralattjaro
Site Admin
Site Admin
Posts: 35622
Joined: Wed May 23, 2007 3:43 pm
Location: green
Contact:

Re: Programming, computers, etc. [Serious]

Post by atomtengeralattjaro » Sat Oct 06, 2012 2:23 pm

why not just make a python2 version and a python3 version?
Ivokyuftaf6666 wrote:
Sun Oct 20, 2019 5:22 pm
Awesome Site, Delivering Fun
Image

User avatar
Anonymously Famous
JKL; Assassin
JKL; Assassin
Posts: 11413
Joined: Thu Mar 03, 2011 6:52 pm
Location: Area ???, under Bermuda Triangle

Re: Programming, computers, etc. [Serious]

Post by Anonymously Famous » Sun Oct 07, 2012 2:07 pm

Because I wanted to see if I could make one version that worked on both.
BOTTOM TEXT
ThingerDudes wrote:The only reasonable amount of Nutella is infinity. Everything else is too little.
Proud poster of the 300kth post in General

User avatar
atomtengeralattjaro
Site Admin
Site Admin
Posts: 35622
Joined: Wed May 23, 2007 3:43 pm
Location: green
Contact:

Re: Programming, computers, etc. [Serious]

Post by atomtengeralattjaro » Sun Oct 07, 2012 2:15 pm

And you won!

btw, here is a contest that I'm probably not going to participate in.
Ivokyuftaf6666 wrote:
Sun Oct 20, 2019 5:22 pm
Awesome Site, Delivering Fun
Image

User avatar
Anonymously Famous
JKL; Assassin
JKL; Assassin
Posts: 11413
Joined: Thu Mar 03, 2011 6:52 pm
Location: Area ???, under Bermuda Triangle

Re: Programming, computers, etc. [Serious]

Post by Anonymously Famous » Sun Oct 07, 2012 6:27 pm

Probably not.
BOTTOM TEXT
ThingerDudes wrote:The only reasonable amount of Nutella is infinity. Everything else is too little.
Proud poster of the 300kth post in General

User avatar
Anonymously Famous
JKL; Assassin
JKL; Assassin
Posts: 11413
Joined: Thu Mar 03, 2011 6:52 pm
Location: Area ???, under Bermuda Triangle

Re: Programming, computers, etc. [Serious]

Post by Anonymously Famous » Wed Oct 10, 2012 5:43 pm

I'm officially registered for PyCon. This makes me happy.
BOTTOM TEXT
ThingerDudes wrote:The only reasonable amount of Nutella is infinity. Everything else is too little.
Proud poster of the 300kth post in General

User avatar
atomtengeralattjaro
Site Admin
Site Admin
Posts: 35622
Joined: Wed May 23, 2007 3:43 pm
Location: green
Contact:

Re: Programming, computers, etc. [Serious]

Post by atomtengeralattjaro » Wed Oct 10, 2012 6:04 pm

have fun gathering.

this looks intriguing.
Ivokyuftaf6666 wrote:
Sun Oct 20, 2019 5:22 pm
Awesome Site, Delivering Fun
Image

User avatar
Anonymously Famous
JKL; Assassin
JKL; Assassin
Posts: 11413
Joined: Thu Mar 03, 2011 6:52 pm
Location: Area ???, under Bermuda Triangle

Re: Programming, computers, etc. [Serious]

Post by Anonymously Famous » Wed Oct 10, 2012 10:28 pm

That it does. I'll have to look into it.

Edit: That's it: I'm going to start learning it. I was going to go for a Lisp language for my next endeavor, but Haxe has me intrigued.
BOTTOM TEXT
ThingerDudes wrote:The only reasonable amount of Nutella is infinity. Everything else is too little.
Proud poster of the 300kth post in General

User avatar
atomtengeralattjaro
Site Admin
Site Admin
Posts: 35622
Joined: Wed May 23, 2007 3:43 pm
Location: green
Contact:

Re: Programming, computers, etc. [Serious]

Post by atomtengeralattjaro » Thu Oct 11, 2012 10:22 am

i thought you might like it. i don't think i'll start learning anything else until i've finished the university.
Ivokyuftaf6666 wrote:
Sun Oct 20, 2019 5:22 pm
Awesome Site, Delivering Fun
Image

Post Reply