Re: Another question about pythonic syntax, yea!

2019-06-09 Thread AudioGames . net Forum — Developers room : pauliyobo via Audiogames-reflector
Re: Another question about pythonic syntax, yea! @28, I agree. URL: https://forum.audiogames.net/post/439873/#p439873 -- Audiogames-reflector mailing list Audiogames-reflector@sabahattin-gucukoglu.com https://sabahattin-gucukoglu.com/cgi-bin/mailman/listinfo/audiogames-reflector

Re: Another question about pythonic syntax, yea!

2019-06-09 Thread AudioGames . net Forum — Developers room : targor via Audiogames-reflector
Re: Another question about pythonic syntax, yea! @24 and 26, this is not true. Your for loop would only skip one index if you defined it like "for i in range(0, 10)". The syntax with "for item in list" never skips an index. URL: https://forum.audiogames.net/

Re: Another question about pythonic syntax, yea!

2019-06-08 Thread AudioGames . net Forum — Developers room : Ethin via Audiogames-reflector
Re: Another question about pythonic syntax, yea! @30, Ah. I see now. URL: https://forum.audiogames.net/post/439617/#p439617 -- Audiogames-reflector mailing list Audiogames-reflector@sabahattin-gucukoglu.com https://sabahattin-gucukoglu.com/cgi-bin/mailman/listinfo/audiogames

Re: Another question about pythonic syntax, yea!

2019-06-08 Thread AudioGames . net Forum — Developers room : The Dwarfer via Audiogames-reflector
Re: Another question about pythonic syntax, yea! @23noI got the following mixedx = [item for item in x if item!= 3]withx = (item for item in x if item!= 3)Put that in the console and you get a generator. URL: https://forum.audiogames.net/post/439605/#p439605 -- Audiogames-reflector

Re: Another question about pythonic syntax, yea!

2019-06-08 Thread AudioGames . net Forum — Developers room : Ethin via Audiogames-reflector
Re: Another question about pythonic syntax, yea! @28, agreed, but LCs are only useful in particular scenarios. They're also limited. URL: https://forum.audiogames.net/post/439593/#p439593 -- Audiogames-reflector mailing list Audiogames-reflector@sabahattin-gucukoglu.com

Re: Another question about pythonic syntax, yea!

2019-06-08 Thread AudioGames . net Forum — Developers room : Dragonlee via Audiogames-reflector
Re: Another question about pythonic syntax, yea! To all the people saying list comprehensions are bad because they are hard to understand, I beg to differ.The only reason you might think that is because you are used to the long form version and once you get used to  list comprehensions

Re: Another question about pythonic syntax, yea!

2019-06-07 Thread AudioGames . net Forum — Developers room : Ethin via Audiogames-reflector
Re: Another question about pythonic syntax, yea! @26, I'm not sure what your trying to convey here. An LC with a for loop is exactly the same as a normal for loop but more compact. You will get exactly the same results no matter how you do it. URL: https://forum.audiogames.net/post/4

Re: Another question about pythonic syntax, yea!

2019-06-07 Thread AudioGames . net Forum — Developers room : majno via Audiogames-reflector
Re: Another question about pythonic syntax, yea! Sorry.  mistake in post 24. instead of != it should be ==.Post edited.Not all items are checked when an item is removed because if item in index 1 is removed the item number 2 in index will replace item number 1. so loop index will continue

Re: Another question about pythonic syntax, yea!

2019-06-07 Thread AudioGames . net Forum — Developers room : majno via Audiogames-reflector
Re: Another question about pythonic syntax, yea! Sorry.  mistake in post 24. instead of != it should be ==.Post edited.Not all items are checked when an item is removed because if item in index 1 is removed the item number 2 in index will replace item number 1. so loop index will continue

Re: Another question about pythonic syntax, yea!

2019-06-07 Thread AudioGames . net Forum — Developers room : majno via Audiogames-reflector
Re: Another question about pythonic syntax, yea! Sorry.  mistake in post 24. instead of != it should be ==.Post edited.but yet is better use list comprehension for remove items from list. URL: https://forum.audiogames.net/post/439376/#p439376 -- Audiogames-reflector mailing list

Re: Another question about pythonic syntax, yea!

2019-06-07 Thread AudioGames . net Forum — Developers room : majno via Audiogames-reflector
Re: Another question about pythonic syntax, yea! Be careful when removing items using for loops.if you do some thing like this.x [1, 2, 3, 4, 5, 6, 7]for item in x:  if item == 3 x.remove(item)the index will skp the next element, so 4 will not be checked. if you havex = [1, 2, 3, 3, 4, 5

Re: Another question about pythonic syntax, yea!

2019-06-07 Thread AudioGames . net Forum — Developers room : Ethin via Audiogames-reflector
Re: Another question about pythonic syntax, yea! @24, this is not correct. Running this in my python environment:>>> x = [1, 2, 3, 4, 5, 6, 7]>>> for item in x:...  if item != 3:...   x.remove(item)...>>> x[2, 3, 5, 7]if I use your other list (x = [1, 2, 3, 3, 4,

Re: Another question about pythonic syntax, yea!

2019-06-07 Thread AudioGames . net Forum — Developers room : Ethin via Audiogames-reflector
Re: Another question about pythonic syntax, yea! @24, this is not correct. Running this in my python environment:>>> for item in x:...  if item != 3:...   x.remove(item)...>>> x[2, 3, 5, 7]if I use your other list (x = [1, 2, 3, 3, 4, 5]):>>> x = [1, 2, 3, 3, 4,

Re: Another question about pythonic syntax, yea!

2019-06-07 Thread AudioGames . net Forum — Developers room : majno via Audiogames-reflector
Re: Another question about pythonic syntax, yea! Be careful when removing items using for loops.if you do some thing like this.x [1, 2, 3, 4, 5, 6, 7]for item in x:  if item != 3 x.remove(item)the index will skp the next element, so 4 will not be checked. if you havex = [1, 2, 3, 3, 4, 5

Re: Another question about pythonic syntax, yea!

2019-06-05 Thread AudioGames . net Forum — Developers room : Ethin via Audiogames-reflector
Re: Another question about pythonic syntax, yea! @20, this is not an example of a generator at all. A generator is an actual class -- class Generator to be exact. A generator requires that you call next() on it repeatedly until you get a StopIteration exception, which is the generators way

Re: Another question about pythonic syntax, yea!

2019-06-05 Thread AudioGames . net Forum — Developers room : Ethin via Audiogames-reflector
Re: Another question about pythonic syntax, yea! @20, this is not an example of a generator at all. A generator is an actual class -- class Generator to be exact. A generator requires that you call next() on it repeatedly until you get a StopIteration exception, which is the generators way

Re: Another question about pythonic syntax, yea!

2019-06-05 Thread AudioGames . net Forum — Developers room : Ethin via Audiogames-reflector
Re: Another question about pythonic syntax, yea! @20, this is not an example of a generator at all. A generator is an actual class -- class Generator to be exact. A generator requires that you call next() on it repeatedly until you get a StopIteration exception, which is the generators way

Re: Another question about pythonic syntax, yea!

2019-06-05 Thread AudioGames . net Forum — Developers room : Ethin via Audiogames-reflector
Re: Another question about pythonic syntax, yea! @20, this is not an example of a generator at all. A generator is an actual class -- class Generator to be exact. A generator requires that you call next() on it repeatedly until you get a StopIteration exception, which is the generators way

Re: Another question about pythonic syntax, yea!

2019-06-05 Thread AudioGames . net Forum — Developers room : thggamer via Audiogames-reflector
Re: Another question about pythonic syntax, yea! Here's another way to generate the same list. It may be more useful if you have a big list or if you have a big function to filter the elements.x = [1,2,3,4,5,6,7,8,9,3,3,4,5,4,3]y = filter(lambda value: value != 3, x)The filter fun

Re: Another question about pythonic syntax, yea!

2019-06-05 Thread AudioGames . net Forum — Developers room : Turkce_Rap via Audiogames-reflector
Re: Another question about pythonic syntax, yea! why do you use loop inside brackets? URL: https://forum.audiogames.net/post/438818/#p438818 -- Audiogames-reflector mailing list Audiogames-reflector@sabahattin-gucukoglu.com https://sabahattin-gucukoglu.com/cgi-bin/mailman/listinfo

Re: Another question about pythonic syntax, yea!

2019-06-01 Thread AudioGames . net Forum — Developers room : The Dwarfer via Audiogames-reflector
Re: Another question about pythonic syntax, yea! @Post 1, that's because what you're doing is a generator.x = [item for item in x if item!= 3]Means:Give me a list wherein we iterate x. The iterator will be called item. So, let's put item in the list for items that do no

Re: Another question about pythonic syntax, yea!

2019-06-01 Thread AudioGames . net Forum — Developers room : sito via Audiogames-reflector
Re: Another question about pythonic syntax, yea! yeah. i noticed it while i was going through the python documentation. Honestly it seems that list comprehentions aren't that useful because you can only add and remove things in a list by making a new list. I think that if you'r

Re: Another question about pythonic syntax, yea!

2019-06-01 Thread AudioGames . net Forum — Developers room : targor via Audiogames-reflector
Re: Another question about pythonic syntax, yea! I think if you want to use nested list comprehensions, you should really write the longer versions with for and if. While it might seem very cool to create a list and then imediately create another out of that first list in one single line

Re: Another question about pythonic syntax, yea!

2019-05-30 Thread AudioGames . net Forum — Developers room : sito via Audiogames-reflector
Re: Another question about pythonic syntax, yea! ok. But what about nested list comprehentions?  do they have their uses? URL: https://forum.audiogames.net/post/437598/#p437598 -- Audiogames-reflector mailing list Audiogames-reflector@sabahattin-gucukoglu.com https://sabahattin

Re: Another question about pythonic syntax, yea!

2019-05-29 Thread AudioGames . net Forum — Developers room : pauliyobo via Audiogames-reflector
Re: Another question about pythonic syntax, yea! sam, Thanks. Yes you're damn right.Talk about reading your posts before posting. Hm. URL: https://forum.audiogames.net/post/437346/#p437346 -- Audiogames-reflector mailing list Audiogames-reflector@sabahattin-gucukoglu.com

Re: Another question about pythonic syntax, yea!

2019-05-29 Thread AudioGames . net Forum — Developers room : leibylucw via Audiogames-reflector
Re: Another question about pythonic syntax, yea! Oh, I understand what your signature means, but it was a little humorous to read "coding is not hard!" and then see a plethora of replies about how to do something with code. Lol. URL: https://forum.audiogames.net/post/43731

Re: Another question about pythonic syntax, yea!

2019-05-29 Thread AudioGames . net Forum — Developers room : amerikranian via Audiogames-reflector
Re: Another question about pythonic syntax, yea! My signature is half sarcasm, half truth. While coding it’s self is not hard, you can learn the syntax in just a couple of days, it takes skill to put it all together and understand how to apply the concepts to whatever you want to do

Re: Another question about pythonic syntax, yea!

2019-05-29 Thread AudioGames . net Forum — Developers room : leibylucw via Audiogames-reflector
Re: Another question about pythonic syntax, yea! @amerikranian: I think it may be okay to say coding can be hard at times. URL: https://forum.audiogames.net/post/437289/#p437289 -- Audiogames-reflector mailing list Audiogames-reflector@sabahattin-gucukoglu.com https://sabahattin

Re: Another question about pythonic syntax, yea!

2019-05-29 Thread AudioGames . net Forum — Developers room : Sam_Tupy via Audiogames-reflector
Re: Another question about pythonic syntax, yea! So paul, I just gotta give ya a friendly little poke here. Your examples are a bit broken, I figured you'd find it pretty amusing if I pointed it out So your first one, for item in x: if item>3: x.remove(item) will remove every ot

Re: Another question about pythonic syntax, yea!

2019-05-29 Thread AudioGames . net Forum — Developers room : Kyleman123 via Audiogames-reflector
Re: Another question about pythonic syntax, yea! Part of what bakes this tricky is that lists or arrays are actually pointers. Even though python touts the fact its a high level language that you don't have to worry about pointers and memory, in reality you kind of still do. persona

Re: Another question about pythonic syntax, yea!

2019-05-29 Thread AudioGames . net Forum — Developers room : zakc93 via Audiogames-reflector
Re: Another question about pythonic syntax, yea! List comprehension generates a new list, it doesn't modify the original. It's useful if you want a subset of an existing list without wanting to modify that list. If you assign the new list to the same variable though then you cou

Re: Another question about pythonic syntax, yea!

2019-05-28 Thread AudioGames . net Forum — Developers room : leibylucw via Audiogames-reflector
Re: Another question about pythonic syntax, yea! I think this question is less about syntax and more about fundamentals of programming.Whenever you create a list in memory, you assign it a reference variable. If you make a modification to that object in memory, what you're really doi

Re: Another question about pythonic syntax, yea!

2019-05-28 Thread AudioGames . net Forum — Developers room : pauliyobo via Audiogames-reflector
Re: Another question about pythonic syntax, yea! @4 is really a preference really.List compreensions are quick ways to create new lists from an other list in one line.Suppose we have this listx = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 12, 13, 14, 15, 16]Instead of spending more than 3 lines of

Re: Another question about pythonic syntax, yea!

2019-05-27 Thread AudioGames . net Forum — Developers room : amerikranian via Audiogames-reflector
Re: Another question about pythonic syntax, yea! So is that a bad thing? Why would I want to use some other  method?  When would you use list comprehension? URL: https://forum.audiogames.net/post/436890/#p436890 -- Audiogames-reflector mailing list Audiogames-reflector@sabahattin

Re: Another question about pythonic syntax, yea!

2019-05-27 Thread AudioGames . net Forum — Developers room : stewie via Audiogames-reflector
Re: Another question about pythonic syntax, yea! @5 That is what is happening@3 That code is a list comprehension, which is kind of a for loop. The original list is not being changed directly by the list comprehension at all. This should be clearer with a slightly modified example.x

Re: Another question about pythonic syntax, yea!

2019-05-27 Thread AudioGames . net Forum — Developers room : stewie via Audiogames-reflector
Re: Another question about pythonic syntax, yea! @5 That is what is happening@3 That code is a list comprehension, which is kind of a for loop. The original list is not being changed directly by the list comprehension at all. This should be clearer with a slightly modified example.x

Re: Another question about pythonic syntax, yea!

2019-05-27 Thread AudioGames . net Forum — Developers room : dardar via Audiogames-reflector
Re: Another question about pythonic syntax, yea! ok, sorry for the double post, but I really, still don't get what the purpose is.Like, I'm reading the code and... just not getting it.Maybe this is a learning thing for me.Are you saying list1 is this, and you want list2 to be

Re: Another question about pythonic syntax, yea!

2019-05-27 Thread AudioGames . net Forum — Developers room : dardar via Audiogames-reflector
Re: Another question about pythonic syntax, yea! So I have my own question here.The code above looks very, very compact.Why not use this?l=[1,2,3,4,5,6,7,8,9,8,7,6,5,4,3,2,1]for x in l: if(x==3):  l.remove(x)I mean you can also do:while(3 in l): l.remove(3)but eh whatever. Same difference

Re: Another question about pythonic syntax, yea!

2019-05-27 Thread AudioGames . net Forum — Developers room : amerikranian via Audiogames-reflector
Re: Another question about pythonic syntax, yea! Right, but what happens to all the elements that contain three? Are they simply gone?  To put it in another way, what is the difference between building a copy of a list and removing an item from it URL: https://forum.audiogames.net/post

Re: Another question about pythonic syntax, yea!

2019-05-27 Thread AudioGames . net Forum — Developers room : stewie via Audiogames-reflector
Re: Another question about pythonic syntax, yea! you use [a for item instead of [item for item. Think of it like a for loop, the variable being referred to has to be the one looping through the list. Also keep in mind that you aren't removing anything from the list when using a

Re: Another question about pythonic syntax, yea!

2019-05-27 Thread AudioGames . net Forum — Developers room : stewie via Audiogames-reflector
Re: Another question about pythonic syntax, yea! you use [a for item instead of [item for item. Think of it like a for loop, the variable being referred to has to be the one looping through the list. URL: https://forum.audiogames.net/post/436860/#p436860 -- Audiogames-reflector

Another question about pythonic syntax, yea!

2019-05-27 Thread AudioGames . net Forum — Developers room : amerikranian via Audiogames-reflector
Another question about pythonic syntax, yea! Suppose we have the following code.x=[1,2,3,4,5,6,7,8,9,3,3,4,5,4,3] x=[item for item in x if item!=3]Simple enough, right? We are removing an element from the list if it is equal to 3. However, this code will produce a traceback:x

Another question about pythonic syntax, yea!

2019-05-27 Thread AudioGames . net Forum — Developers room : amerikranian via Audiogames-reflector
Another question about pythonic syntax, yea! Suppose we have the following code.x=[1,2,3,4,5,6,7,8,9,3,3,4,5,4,3] x=[item for item in x if item!=3]Simple enough, right? We are removing an element from the list if it is equal to 3. However, this code will produce a traceback:x