Re: Python reduce function. Ever You needed it?

2021-03-15 Thread AudioGames . net Forum — Developers room : camlorn via Audiogames-reflector


  


Re: Python reduce function. Ever You needed it?

I don't know what you're asking.  My opinion about lambdas in general?

URL: https://forum.audiogames.net/post/623077/#p623077




-- 
Audiogames-reflector mailing list
Audiogames-reflector@sabahattin-gucukoglu.com
https://sabahattin-gucukoglu.com/cgi-bin/mailman/listinfo/audiogames-reflector


Re: Python reduce function. Ever You needed it?

2021-03-15 Thread AudioGames . net Forum — Developers room : Turkce_Rap via Audiogames-reflector


  


Re: Python reduce function. Ever You needed it?

@KamlornYea i use python3, it looks highly messy with lambdas imho. What is Your openion about that?

URL: https://forum.audiogames.net/post/623059/#p623059




-- 
Audiogames-reflector mailing list
Audiogames-reflector@sabahattin-gucukoglu.com
https://sabahattin-gucukoglu.com/cgi-bin/mailman/listinfo/audiogames-reflector


Re: Python reduce function. Ever You needed it?

2021-03-15 Thread AudioGames . net Forum — Developers room : camlorn via Audiogames-reflector


  


Re: Python reduce function. Ever You needed it?

You'll probably never use it.  It doesn't come up very often and, in Python, it doesn't look so nice as it does in languages with better iterator support.  Also, in Python 3 you have to use functools.reduce instead.Just use for loops.  Unless it's something incredibly, incredibly simple for loops are easier to figure out.

URL: https://forum.audiogames.net/post/623047/#p623047




-- 
Audiogames-reflector mailing list
Audiogames-reflector@sabahattin-gucukoglu.com
https://sabahattin-gucukoglu.com/cgi-bin/mailman/listinfo/audiogames-reflector


Re: python global dictionary not saving modifications

2021-03-12 Thread AudioGames . net Forum — Developers room : Dragonlee via Audiogames-reflector


  


Re: python global dictionary not saving modifications

@6 okay, it seems what I wrote just flew over your head. my whole point wasn't that your dict is being overwritten. that is what you think is happening, but I tried to point out that it is almost definitely not the case.I was arguing that the dict the function is modifying and the dict you are later using that you are surprised is empty are actually two different dict instances. however, you think they are the same dict instance, leading to your confusion.#8 pointed to the same thing I wrote about, essentially how locals can sneakily shadow globals in python and lead to weird bugs like this. but I agree with #8 in that you should just avoid using globals the way you are, since that is actually easier than explaining how this works. either just pass in all your dependencies to your function as arguments, or use a class where the state are fields and any functions that modify that state are methods of the class. Personally, I recommend the first function passing way, since it is simpler and doesn't require to learn OOP concepts.

URL: https://forum.audiogames.net/post/622280/#p622280




-- 
Audiogames-reflector mailing list
Audiogames-reflector@sabahattin-gucukoglu.com
https://sabahattin-gucukoglu.com/cgi-bin/mailman/listinfo/audiogames-reflector


Re: python global dictionary not saving modifications

2021-03-11 Thread AudioGames . net Forum — Developers room : camlorn via Audiogames-reflector


  


Re: python global dictionary not saving modifications

I am 99% sure that the problem here is that this code is trying to do something to the effect of modifying a dict in another module, but by importing the dict in the current module.  But it's a lot of very meh code and I don't ahve the energy to pick it apart.  But specifically:import mydict from mymodule

def modify():
# works
mydict["foo"]

def modify_broken():
# Doesn't work
mydict = dict()You should do this in the first place.  Please, please learn to just add functions to modules that do this.  But if you do need it to work, you have to:import mymodule

mymodule.mydict = dict()Python does not have globals in the fashion that you want.  Your programs should not have globals in this way either.  if you're importing global variables from other modules you have probably failed.  This may not be the bug, but it's usually the buig when people claim it's broken.  Why the latter works and the former doesn't is complicated, but if you don't do this then you don't need to know, so just don't do this.

URL: https://forum.audiogames.net/post/622044/#p622044




-- 
Audiogames-reflector mailing list
Audiogames-reflector@sabahattin-gucukoglu.com
https://sabahattin-gucukoglu.com/cgi-bin/mailman/listinfo/audiogames-reflector


Re: python global dictionary not saving modifications

2021-03-11 Thread AudioGames . net Forum — Developers room : mohamed via Audiogames-reflector


  


Re: python global dictionary not saving modifications

python sometimes gets access to a var by it own in a function and sometimes does not, So last i checked, You didn't add global varname in the function you said is not working, So maybe try doing that?

URL: https://forum.audiogames.net/post/622025/#p622025




-- 
Audiogames-reflector mailing list
Audiogames-reflector@sabahattin-gucukoglu.com
https://sabahattin-gucukoglu.com/cgi-bin/mailman/listinfo/audiogames-reflector


Re: python global dictionary not saving modifications

2021-03-11 Thread AudioGames . net Forum — Developers room : Zarvox via Audiogames-reflector


  


Re: python global dictionary not saving modifications

This function and this dictionary were both in base.py before, and there were no issues. So this doesn't have to do with overwriting. I think the issue is my sys.path is in the root of the folder instead of the commands folder where the madlib.py file is. I am able to access functions in madlib.py via the bot commands, but I do not think I have access to the dictionary variable, so it is creating one every time I run a function that refers to it. However, this doesn't make complete sense, since there is also a global string variable in madlib.py, and it is able to read the contents of that perfectly fine when I referenc it, which is only in 1 function.

URL: https://forum.audiogames.net/post/622023/#p622023




-- 
Audiogames-reflector mailing list
Audiogames-reflector@sabahattin-gucukoglu.com
https://sabahattin-gucukoglu.com/cgi-bin/mailman/listinfo/audiogames-reflector


Re: python global dictionary not saving modifications

2021-03-10 Thread AudioGames . net Forum — Developers room : Dragonlee via Audiogames-reflector


  


Re: python global dictionary not saving modifications

this code doesn't actually share what the problem is, since this function is confirmed to work. you would need to show what is the context where the function is called after which the dict is "emptied". it also realy helps if you can reproduce the issue as the minimal case, since other people have less code to look through and less of the code is noise. it is respectful to the people you are asking for help, it also makes finding the bug faster, and many times you will find that you figure it out yourself in the process.>>> d = {}>>> def f():...   d['foo'] = 42...>>> f()>>> d{'foo': 42}so the problem is obviously not in the function. there is something going on in the context you are calling it in. I suspect the problem is that the function refers to the right dictionary, but the context you are calling the function  in has a local variable set as the dict with the same name, so you aren't actually reffering to the right dict in the context where it is empty but you expect it to not be... maybe something like this:>>> def g():...   #trying to overwrite value of d...   d = {}...   f()...   print(d)...>>> g(){}>>> d{'foo': 42}

URL: https://forum.audiogames.net/post/621930/#p621930




-- 
Audiogames-reflector mailing list
Audiogames-reflector@sabahattin-gucukoglu.com
https://sabahattin-gucukoglu.com/cgi-bin/mailman/listinfo/audiogames-reflector


Re: python global dictionary not saving modifications

2021-03-10 Thread AudioGames . net Forum — Developers room : Zarvox via Audiogames-reflector


  


Re: python global dictionary not saving modifications

This is for my mad libs discord bot. I decided to move the mad libs and game_keys dictionaries out of base.py and put them in madlib.py. Now it is causing issues.in base.py, with the working servers and users dictionaryimport os
from pathlib import Path
import time
import asyncio
import shutil
import json
import pygan
import discord

#used to handle audio requests from servers
class Request:
 def __init__(self):
  self.list= []
  self.index=0

request= Request()
servers={}
users={}
#admins to perform global commands
global_admins=["my discord user id"]
#a list of events for the screen reader to speech when debugging
debug={}
def save_debug():
 f = open("debug.json", "w")
 json.dump(debug, f, indent=" ")
 f.close()
def load_debug():
 global debug
 with open("debug.json") as f:
  debug= json.load(f)
  f.close()

#server functions
"""when the bot connects to discord, it loops through each server and loads the data. If no data for the server is found, it creates data for it with this function."""
def create_server(guild, id, members):
 if debug["server create"] or debug["server all"]:
  pygan.speech.speak("creating server")
 with open("server template.json") as f:
  guild_data = json.load(f)
  f.close()
 guild_data.update({"name": guild})
 guild_data.update({"id": id})
 """notice how we can successfully use the global servers dictionary  to add a new key 
 value pair. THis also works with the users dictionary."""
 servers.update({id: guild_data})
 save_server(guild, id)
 #creates a folder to store user data
 os.makedirs(f"users/{guild}#{id}", exist_ok=True)
 """saves the server data, not relevant, as we are just showing the dictionary can be 
 modified."""
 save_server(guild, id)So no issues there. The issue is in madlib.py.import os
from pathlib import Path
import time
import asyncio
import shutil
import re
import json
import random
import pygan
import discord
from discord.ext import commands
import base

#the dictionary that holds each server's list of word types \
madlibs={}
#this dictionary is used to refer back to certain answers in earlier parts of the story
game_keys={}

#this function is suppose to refer to the global madlibs dictionary, but doesn't
def load_word_types(guild, id):
 #we check if the server is not in the madlibs dict yet
 if f"{id}" not in madlibs:
  madlibs.update({id: {}})
 word_types= os.listdir(os.getcwd()+f"\\mad lib\\{guild}#{id}\\word type")
 if base.debug["mad lib word types"] or base.debug["mad lib all"]:
  pygan.speech.speak(f"{len(word_types)}")
 if len(word_types)>0:
  #we get rid of the .txt extension. The word types are the filenames
  for type in word_types:
   type= type[:-4]
   if base.debug["mad lib word types"] or base.debug["mad lib all"]:
pygan.speech.speak(type)
   if type not in madlibs[id]:
madlibs[id].update({type: []})
if base.debug["mad lib update"] or base.debug["mad lib all"]:
 pygan.speech.speak("added type")I haven't gotten to test if th egame_keys dictionary has this issue, but I can't until this is fixed. I use to refer to madlibs[id] as base.madlibs[id], and it like that. But now it doesn't like the dictionary being in the same module.So here is the result. It adds the server id into the madlibs dictionary, and adds the word types, as it should. But as soon as the function is over, it empties the dictionary. Why? Something that I found that was odd is when looping through the servers with a for loop and running the load_word_types function, it doesn't delete the dictionary until after the for loop. I know this because I had it speak the length of the keys. The bot has 2 servers. So it reported 2 in the for loop. However, there is another place where the word_types are loaded, and when I run that function, it empties every time after running the load function. So my guess is it empties after the function it was called from, is finished. But again, why? It is a global variable. So any time i mention madlibs[id], it gives me a key error since the dictionary is empty.

URL: https://forum.audiogames.net/post/621907/#p621907




-- 
Audiogames-reflector mailing list
Audiogames-reflector@sabahattin-gucukoglu.com
https://sabahattin-gucukoglu.com/cgi-bin/mailman/listinfo/audiogames-reflector


Re: python global dictionary not saving modifications

2021-03-10 Thread AudioGames . net Forum — Developers room : Zarvox via Audiogames-reflector


  


Re: python global dictionary not saving modifications

This is for my mad libs discord bot. I decided to move the mad libs and game_keys dictionaries out of base.py and put them in madlib.py. Now it is causing issues.in base.py, with the working servers and users dictionaryimport os
from pathlib import Path
import time
import asyncio
import shutil
import json
import pygan
import discord

#used to handle audio requests from servers
class Request:
 def __init__(self):
  self.list= []
  self.index=0

request= Request()
servers={}
users={}
#admins to perform global commands
global_admins=["my discord user id"]
#a list of events for the screen reader to speech when debugging
debug={}
def save_debug():
 f = open("debug.json", "w")
 json.dump(debug, f, indent=" ")
 f.close()
def load_debug():
 global debug
 with open("debug.json") as f:
  debug= json.load(f)
  f.close()

#server functions
"""when the bot connects to discord, it loops through each server and loads the data. If no data for the server is found, it creates data for it with this function."""
def create_server(guild, id, members):
 if debug["server create"] or debug["server all"]:
  pygan.speech.speak("creating server")
 with open("server template.json") as f:
  guild_data = json.load(f)
  f.close()
 guild_data.update({"name": guild})
 guild_data.update({"id": id})
 """notice how we can successfully use the global servers dictionary  to add a new key 
 value pair. THis also works with the users dictionary."""
 servers.update({id: guild_data})
 save_server(guild, id)
 #creates a folder to store user data
 os.makedirs(f"users/{guild}#{id}", exist_ok=True)
 """saves the server data, not relevant, as we are just showing the dictionary can be 
 modified."""
 save_server(guild, id)So no issues there. The issue is in madlib.py.import os
from pathlib import Path
import time
import asyncio
import shutil
import re
import json
import random
import pygan
import discord
from discord.ext import commands
import base

#the dictionary that holds each server's list of word types \
madlibs={}
#this dictionary is used to refer back to certain answers in earlier parts of the story
game_keys={}

#this function is suppose to refer to the global madlibs dictionary, but doesn't
def load_word_types(guild, id):
 #we check if the server is not in the madlibs dict yet
 if f"{id}" not in madlibs:
  madlibs.update({id: {}})
 word_types= os.listdir(os.getcwd()+f"\\mad lib\\{guild}#{id}\\word type")
 if base.debug["mad lib word types"] or base.debug["mad lib all"]:
  pygan.speech.speak(f"{len(word_types)}")
 if len(word_types)>0:
  #we get rid of the .txt extension. The word types are the filenames
  for type in word_types:
   type= type[:-4]
   if base.debug["mad lib word types"] or base.debug["mad lib all"]:
pygan.speech.speak(type)
   if type not in madlibs[id]:
madlibs[id].update({type: []})
if base.debug["mad lib update"] or base.debug["mad lib all"]:
 pygan.speech.speak("added type")I haven't gotten to test if th egame_keys dictionary has this issue, but I can't until this is fixed. I use to refer to madlibs[id] as base.madlibs[id], and it like that. But now it doesn't like the dictionary being in the same module.So here is the result. It adds the server id into the madlibs dictionary, and adds the word types, as it should. But as soon as the function is over, it empties the dictionary. Why? Something that I found that was odd is when looping through the servers with a for loop and running the load_word_types function, it doesn't delete the dictionary until after the for loop. I know this because I had it speak the length of the keys. The bot has 2 servers. So it reported 2 in the for loop. However, there is another place where the word_types are loaded, and when I run that function, it empties every time after running the load function. So my guess is it empties after the functio is was called from, is finished. But again, why? It is a global variable. So any time i mentin madlibs[id], it gives me a key error since the dictionary is empty.

URL: https://forum.audiogames.net/post/621907/#p621907




-- 
Audiogames-reflector mailing list
Audiogames-reflector@sabahattin-gucukoglu.com
https://sabahattin-gucukoglu.com/cgi-bin/mailman/listinfo/audiogames-reflector


Re: python global dictionary not saving modifications

2021-03-10 Thread AudioGames . net Forum — Developers room : Zarvox via Audiogames-reflector


  


Re: python global dictionary not saving modifications

This is for my mad libs discord bot. I decided to move the mad libs and game_keys dictionaries out of base.py and put them in madlib.py. Now it is causing issues.in base.py, with the working servers and users dictionaryimport os
from pathlib import Path
import time
import asyncio
import shutil
import json
import pygan
import discord

#used to handle audio requests from servers
class Request:
 def __init__(self):
  self.list= []
  self.index=0

request= Request()
servers={}
users={}
#admins to perform global commands
global_admins=["my discord user id"]
#a list of events for the screen reader to speech when debugging
debug={}
def save_debug():
 f = open("debug.json", "w")
 json.dump(debug, f, indent=" ")
 f.close()
def load_debug():
 global debug
 with open("debug.json") as f:
  debug= json.load(f)
  f.close()

#server functions
"""when the bot connects to discord, it loops through each server and loads the data. If no data for the server is found, it creates data for it with this function."""
def create_server(guild, id, members):
 if debug["server create"] or debug["server all"]:
  pygan.speech.speak("creating server")
 with open("server template.json") as f:
  guild_data = json.load(f)
  f.close()
 guild_data.update({"name": guild})
 guild_data.update({"id": id})
 """notice how we can successfully use the global servers dictionary  to add a new key 
 value pair. THis also works with the users dictionary."""
 servers.update({id: guild_data})
 save_server(guild, id)
 #creates a folder to store user data
 os.makedirs(f"users/{guild}#{id}", exist_ok=True)
 """saves the server data, not relevant, as we are just showing the dictionary can be 
 modified."""
 save_server(guild, id)So no issues there. The issue is in madlib.py.import os
from pathlib import Path
import time
import asyncio
import shutil
import re
import json
import random
import pygan
import discord
from discord.ext import commands
import base

#the dictionary that holds each server's list of word types \
madlibs={}
#this dictionary is used to refer back to certain answers in earlier parts of the story
game_keys={}

#this function is suppose to refer to the global madlibs dictionary, but doesn't
def load_word_types(guild, id):
 #we check if the server is not in the madlibs dict yet
 if f"{id}" not in madlibs:
  madlibs.update({id: {}})
 word_types= os.listdir(os.getcwd()+f"\\mad lib\\{guild}#{id}\\word type")
 if base.debug["mad lib word types"] or base.debug["mad lib all"]:
  pygan.speech.speak(f"{len(word_types)}")
 if len(word_types)>0:
  #we get rid of the .txt extension. The word types are the filenames
  for type in word_types:
   type= type[:-4]
   if base.debug["mad lib word types"] or base.debug["mad lib all"]:
pygan.speech.speak(type)
   if type not in madlibs[id]:
madlibs[id].update({type: []})
if base.debug["mad lib update"] or base.debug["mad lib all"]:
 pygan.speech.speak("added type")I haven't gotten to test if th egame_keys dictionary has this issue, but I can't until this is fixed. I use to refer to madlibs[id] as base.madlibs[id], and it like that. But now it doesn't like the dictionary being in the same module.So here is the result. It adds the server id into the madlibs dictionary, and adds the word types, as it should. But as soon as the function is over, it empties the dictionary. Why? Something that I found that was odd is when looping through the servers with a for loop and running the load_word_types function, it doesn't delete the dictionary until after the for loop. I know this because I had it speak the length of the keys. The bot has 3 servers. So it reported 2 in for loop. However, there is another place where the word_types are loaded, and when I run that function, it empties every time after running th eload function.

URL: https://forum.audiogames.net/post/621907/#p621907




-- 
Audiogames-reflector mailing list
Audiogames-reflector@sabahattin-gucukoglu.com
https://sabahattin-gucukoglu.com/cgi-bin/mailman/listinfo/audiogames-reflector


Re: python global dictionary not saving modifications

2021-03-10 Thread AudioGames . net Forum — Developers room : Zarvox via Audiogames-reflector


  


Re: python global dictionary not saving modifications

This is for my mad libs discord bot. I decided to move the mad libs and game_keys dictionaries out of base.py and put them in madlib.py. Now it is causing issues.in base.py, with the working servers and users dictionaryimport os
from pathlib import Path
import time
import asyncio
import shutil
import json
import pygan
import discord

#used to handle audio requests from servers
class Request:
 def __init__(self):
  self.list= []
  self.index=0

request= Request()
servers={}
users={}
#admins to perform global commands
global_admins=["my discord user id"]
#a list of events for the screen reader to speech when debugging
debug={}
def save_debug():
 f = open("debug.json", "w")
 json.dump(debug, f, indent=" ")
 f.close()
def load_debug():
 global debug
 with open("debug.json") as f:
  debug= json.load(f)
  f.close()

#server functions
"""when the bot connects to discord, it loops through each server and loads the data. If no data for the server is found, it creates data for it with this function."""
def create_server(guild, id, members):
 if debug["server create"] or debug["server all"]:
  pygan.speech.speak("creating server")
 with open("server template.json") as f:
  guild_data = json.load(f)
  f.close()
 guild_data.update({"name": guild})
 guild_data.update({"id": id})
 """notice how we can successfully use the global servers dictionary  to add a new key 
 value pair. THis also works with the users dictionary."""
 servers.update({id: guild_data})
 save_server(guild, id)
 #creates a folder to store user data
 os.makedirs(f"users/{guild}#{id}", exist_ok=True)
 """saves the server data, not relevant, as we are just showing the dictionary can be 
 modified."""
 save_server(guild, id)So no issues there. The issue is in madlib.py.import os
from pathlib import Path
import time
import asyncio
import shutil
import re
import json
import random
import pygan
import discord
from discord.ext import commands
import base

#the dictionary that holds each server's list of word types \
madlibs={}
#this dictionary is used to refer back to certain answers in earlier parts of the story
game_keys={}

#this function is suppose to refer to the global madlibs dictionary, but doesn't
def load_word_types(guild, id):
 #we check if the server is not in the madlibs dict yet
 if f"{id}" not in madlibs:
  madlibs.update({id: {}})
 word_types= os.listdir(os.getcwd()+f"\\mad lib\\{guild}#{id}\\word type")
 if base.debug["mad lib word types"] or base.debug["mad lib all"]:
  pygan.speech.speak(f"{len(word_types)}")
 if len(word_types)>0:
  #we get rid of the .txt extension. The word types are the filenames
  for type in word_types:
   type= type[:-4]
   if base.debug["mad lib word types"] or base.debug["mad lib all"]:
pygan.speech.speak(type)
   if type not in madlibs[id]:
madlibs[id].update({type: []})
if base.debug["mad lib update"] or base.debug["mad lib all"]:
 pygan.speech.speak("added type")I haven't gotten to test if th egame_keys dictionary has this issue, but I can't until this is fixed. I use to refer to madlibs[id] as base.madlibs[id], and it like that. But now it doesn't like the dictionary being in the same module.

URL: https://forum.audiogames.net/post/621907/#p621907




-- 
Audiogames-reflector mailing list
Audiogames-reflector@sabahattin-gucukoglu.com
https://sabahattin-gucukoglu.com/cgi-bin/mailman/listinfo/audiogames-reflector


Re: python global dictionary not saving modifications

2021-03-10 Thread AudioGames . net Forum — Developers room : Hijacker via Audiogames-reflector


  


Re: python global dictionary not saving modifications

Other than that, everything here is pure speculation unless you show us some code.

URL: https://forum.audiogames.net/post/621873/#p621873




-- 
Audiogames-reflector mailing list
Audiogames-reflector@sabahattin-gucukoglu.com
https://sabahattin-gucukoglu.com/cgi-bin/mailman/listinfo/audiogames-reflector


Re: python global dictionary not saving modifications

2021-03-10 Thread AudioGames . net Forum — Developers room : camlorn via Audiogames-reflector


  


Re: python global dictionary not saving modifications

I am going to assume that you're not importing it from the other file.  Remember that in Python different files are different modules, and you will need to import things from them.  BGT-style global variables don't exist.

URL: https://forum.audiogames.net/post/621870/#p621870




-- 
Audiogames-reflector mailing list
Audiogames-reflector@sabahattin-gucukoglu.com
https://sabahattin-gucukoglu.com/cgi-bin/mailman/listinfo/audiogames-reflector


Re: Python - changing the voice of a win32com SpVoice instance

2021-03-02 Thread AudioGames . net Forum — Developers room : cartertemm via Audiogames-reflector


  


Re: Python - changing the voice of a win32com SpVoice instance

I've ran into this before. It's due to a bug in the underlying SAPI implementation where voice parameters aren't re-initialized when the voice changes, only audio device.The solution I found was to reassign tts.AudioOutput to itself in your on_change_voice function:tts.AudioOutput = tts.AudioOutputHTH

URL: https://forum.audiogames.net/post/619445/#p619445




-- 
Audiogames-reflector mailing list
Audiogames-reflector@sabahattin-gucukoglu.com
https://sabahattin-gucukoglu.com/cgi-bin/mailman/listinfo/audiogames-reflector


Re: Python - changing the voice of a win32com SpVoice instance

2021-03-02 Thread AudioGames . net Forum — Developers room : cartertemm via Audiogames-reflector


  


Re: Python - changing the voice of a win32com SpVoice instance

I've ran into this before. It's due to a bug in the underlying SAPI implementation where audio parameters aren't re-initialized when the voice changes, only audio device.The solution I found was to reassign tts.AudioOutput to itself in your on_change_voice function:tts.AudioOutput = tts.AudioOutputHTH

URL: https://forum.audiogames.net/post/619445/#p619445




-- 
Audiogames-reflector mailing list
Audiogames-reflector@sabahattin-gucukoglu.com
https://sabahattin-gucukoglu.com/cgi-bin/mailman/listinfo/audiogames-reflector


Re: Python - changing the voice of a win32com SpVoice instance

2021-02-28 Thread AudioGames . net Forum — Developers room : vlajna95 via Audiogames-reflector


  


Re: Python - changing the voice of a win32com SpVoice instance

The problem here is that it doesn't throw an error. It simply continues speaking with the old voice. If I uncomment the comments to the print functions, it shows different values before and after the change, but that change isn't applied to the active speech.

URL: https://forum.audiogames.net/post/619153/#p619153




-- 
Audiogames-reflector mailing list
Audiogames-reflector@sabahattin-gucukoglu.com
https://sabahattin-gucukoglu.com/cgi-bin/mailman/listinfo/audiogames-reflector


Re: Python - changing the voice of a win32com SpVoice instance

2021-02-27 Thread AudioGames . net Forum — Developers room : Turret via Audiogames-reflector


  


Re: Python - changing the voice of a win32com SpVoice instance

Hm, haven't messed with win32com and SAPI much.  It's generally a bad practice to use a normal except without an error though, so that could be doing things.  Do you know what exception it raises?  Maybe like:except comtypes.com_error:

URL: https://forum.audiogames.net/post/618776/#p618776




-- 
Audiogames-reflector mailing list
Audiogames-reflector@sabahattin-gucukoglu.com
https://sabahattin-gucukoglu.com/cgi-bin/mailman/listinfo/audiogames-reflector


Re: Python and audiogame

2021-01-26 Thread AudioGames . net Forum — Developers room : Ethin via Audiogames-reflector


  


Re: Python and audiogame

You can always write your own engine for your particular game as well. If you come back later and believe that none of the engines suit your particular needs, writing the engine and using tools like pygame and cytolk themselves is a really good way of learning how all of this works under the hood (not to mention its an excellent learning device). Using these frameworks only gives you a slight edge; even with them there's still a lot of code you'll have to write, but these engines take a way all the boring stuff so you can get down to the good stuff. I'd encourage you to try writing your own sometime though if you really want to learn how it all works.

URL: https://forum.audiogames.net/post/610003/#p610003




-- 
Audiogames-reflector mailing list
Audiogames-reflector@sabahattin-gucukoglu.com
https://sabahattin-gucukoglu.com/cgi-bin/mailman/listinfo/audiogames-reflector


Re: Python and audiogame

2021-01-26 Thread AudioGames . net Forum — Developers room : JayJay via Audiogames-reflector


  


Re: Python and audiogame

It totally is, its just both libs offer different means of speech, keyboard handling, etc etc. Pygame and pyglet certainly are capable of 2d games.

URL: https://forum.audiogames.net/post/609989/#p609989




-- 
Audiogames-reflector mailing list
Audiogames-reflector@sabahattin-gucukoglu.com
https://sabahattin-gucukoglu.com/cgi-bin/mailman/listinfo/audiogames-reflector


Re: Python and audiogame

2021-01-26 Thread AudioGames . net Forum — Developers room : frescofm via Audiogames-reflector


  


Re: Python and audiogame

Thank you all for your explanations. While writing my first post, I forgot to add that I have been programming in python for several years now. Recently I decided to write my first game for the blind. Now I am looking for the right tools(libraries). After your answers I'm starting to wonder if pyglet or pygame won't be enough for a simple 2d game.

URL: https://forum.audiogames.net/post/609979/#p609979




-- 
Audiogames-reflector mailing list
Audiogames-reflector@sabahattin-gucukoglu.com
https://sabahattin-gucukoglu.com/cgi-bin/mailman/listinfo/audiogames-reflector


Re: Python and audiogame

2021-01-26 Thread AudioGames . net Forum — Developers room : chrisnorman7 via Audiogames-reflector


  


Re: Python and audiogame

OK, full disclosure: I'm the developer of Earwax, so I naturally know more about it than the others. That said, let me try to break down the pros and cons of Lucia too. I'll exclude Framework, because I know nothing about it.Lucia, from what I've seen, gives people an easy transition from BGT, which was kind of the de facto standard for audio gaming for however long.It has nice little things like the pack file which let you save all your assets in a single file, thus hiding them (albeit not permanently) from casual scrutiny.Other than that, it has some sound support, and - as others have mentioned - speech support with the excellent Cytolk library.In short, it doesn't have a lot to offer, but what it does have, will (hopefully) be well documented and tested.It's downfall I guess is that it doesn't have a huge amount to offer right now. Also, you have to write your own game loop I believe, which I'm not a huge fan of.Earwax, as stated, is my baby, so I'm possibly a bit more attached to it than is healthy, so if I seem a bit militant, that's why.So it relies on Pyglet, which handles the main loop for you. That means there's no "if key == down, do something", you just bind actions to "levels", and away you go.As others have pointed out, it is very decorator-heavy, which Pyglet is too. You don't need to use these decorators however, if you'd rather subclass, you can absolutely do that. What people seem to neglect to mention when they're complaining about my decorators is at the very base, they're just class methods, so you can happily subclass, override the requisite method, and not write a single at sign.It has little sound niceties, such as proper buffer caching (not battle tested admittedly), and the ability to change a sound from a 2d to a 3d with one line of code.In the tooling department, it has a story editor, a command for creating a basic game, and I am currently working on a map editor.If you want to read more about Earwax, check the documentation, and feel free to ask questions on the Earwax forum thread.Other than that, have yourself a great day, and whichever library you choose, have a good time with it, and enjoy yourself.

URL: https://forum.audiogames.net/post/609966/#p609966




-- 
Audiogames-reflector mailing list
Audiogames-reflector@sabahattin-gucukoglu.com
https://sabahattin-gucukoglu.com/cgi-bin/mailman/listinfo/audiogames-reflector


Re: Python and audiogame

2021-01-26 Thread AudioGames . net Forum — Developers room : amerikranian via Audiogames-reflector


  


Re: Python and audiogame

@frescofm, people are correct in the fact that there is no "best" library. You would just have to pick one and see if it works for you. Whatever you do, though, avoid Framework. I posted on its topic (I think it's still on the first page?) explaining why you shouldn't use it.Re, Lucia and bugs. Lucia has no groundbreaking issues apart from proper caching. It works, but it can be *a lot* better.Re, Earwax. While it offers a Synthizer wrapper, its employment of decorators is quite heavy-handed, and the funky keyboard system takes a bit to get used to. Also, don't be surprised when you are trying to figure out why one of your keys isn't working when you hold shift, Pyglet is picky about that sort of thing.They all come with their own advantages and poison, the choice is up to you

URL: https://forum.audiogames.net/post/609946/#p609946




-- 
Audiogames-reflector mailing list
Audiogames-reflector@sabahattin-gucukoglu.com
https://sabahattin-gucukoglu.com/cgi-bin/mailman/listinfo/audiogames-reflector


Re: Python and audiogame

2021-01-26 Thread AudioGames . net Forum — Developers room : Meatbag via Audiogames-reflector


  


Re: Python and audiogame

lucia currently isn't  so good when it comes to bugs, although I think that will be fixed in lucia 2.0, and until lucia 2.0 get released i'm not sure, framework, mostly, is built on top of lucia which I dont think is good because lucia is already there, only thing that framework gives you is synthizer rapper, and I think earwax does that too

URL: https://forum.audiogames.net/post/609879/#p609879




-- 
Audiogames-reflector mailing list
Audiogames-reflector@sabahattin-gucukoglu.com
https://sabahattin-gucukoglu.com/cgi-bin/mailman/listinfo/audiogames-reflector


Re: Python and audiogame

2021-01-26 Thread AudioGames . net Forum — Developers room : frescofm via Audiogames-reflector


  


Re: Python and audiogame

Meatbag wrote:EarwaxWhy?

URL: https://forum.audiogames.net/post/609876/#p609876




-- 
Audiogames-reflector mailing list
Audiogames-reflector@sabahattin-gucukoglu.com
https://sabahattin-gucukoglu.com/cgi-bin/mailman/listinfo/audiogames-reflector


Re: Python and audiogame

2021-01-26 Thread AudioGames . net Forum — Developers room : Meatbag via Audiogames-reflector


  


Re: Python and audiogame

Earwax

URL: https://forum.audiogames.net/post/609871/#p609871




-- 
Audiogames-reflector mailing list
Audiogames-reflector@sabahattin-gucukoglu.com
https://sabahattin-gucukoglu.com/cgi-bin/mailman/listinfo/audiogames-reflector


Re: Python and audiogame

2021-01-26 Thread AudioGames . net Forum — Developers room : frescofm via Audiogames-reflector


  


Re: Python and audiogame

Okay, then I have another question. Can you list the advantages or disadvantages of these libraries? Write which one is best developed, has good documentation, has no bugs.

URL: https://forum.audiogames.net/post/609865/#p609865




-- 
Audiogames-reflector mailing list
Audiogames-reflector@sabahattin-gucukoglu.com
https://sabahattin-gucukoglu.com/cgi-bin/mailman/listinfo/audiogames-reflector


Re: Python and audiogame

2021-01-26 Thread AudioGames . net Forum — Developers room : bhanuponguru via Audiogames-reflector


  


Re: Python and audiogame

if your comming from bgt, use lucia. or if your a pythoneer or switching to python or learning python without bgt knowledge, both are fine for you

URL: https://forum.audiogames.net/post/609843/#p609843




-- 
Audiogames-reflector mailing list
Audiogames-reflector@sabahattin-gucukoglu.com
https://sabahattin-gucukoglu.com/cgi-bin/mailman/listinfo/audiogames-reflector


Re: Python and audiogame

2021-01-26 Thread AudioGames . net Forum — Developers room : Hijacker via Audiogames-reflector


  


Re: Python and audiogame

There probably is no "better" library. Some of them have features that others don't, the one might suit your programming style better than the other. Its probably best to get into the documentation of each library, write some hello world examples and think about what is the most fun for you.

URL: https://forum.audiogames.net/post/609844/#p609844




-- 
Audiogames-reflector mailing list
Audiogames-reflector@sabahattin-gucukoglu.com
https://sabahattin-gucukoglu.com/cgi-bin/mailman/listinfo/audiogames-reflector


Re: python open.write insert's extra lines after any line after writing?

2021-01-10 Thread AudioGames . net Forum — Developers room : camlorn via Audiogames-reflector


  


Re: python open.write insert's extra lines after any line after writing?

My money is on the text editor is displaying \r as a newline, they're writing \n themselves, and it's getting converted to \r\n by Python.  Try this:open("myfile.txt", "wb")And see if it does what you want.

URL: https://forum.audiogames.net/post/605693/#p605693




-- 
Audiogames-reflector mailing list
Audiogames-reflector@sabahattin-gucukoglu.com
https://sabahattin-gucukoglu.com/cgi-bin/mailman/listinfo/audiogames-reflector


Re: python open.write insert's extra lines after any line after writing?

2021-01-10 Thread AudioGames . net Forum — Developers room : GrannyCheeseWheel via Audiogames-reflector


  


Re: python open.write insert's extra lines after any line after writing?

I don't get what you're trying to say. They are the same to me. Did you come up with something like this:with open("test.txt", mode="w") as f:
f.write("Hi, how are you \r\n")
for x in range(1, 11):
f.write(str(x ** 2) + "\r\n")

URL: https://forum.audiogames.net/post/605652/#p605652




-- 
Audiogames-reflector mailing list
Audiogames-reflector@sabahattin-gucukoglu.com
https://sabahattin-gucukoglu.com/cgi-bin/mailman/listinfo/audiogames-reflector


Re: python open.write insert's extra lines after any line after writing?

2021-01-10 Thread AudioGames . net Forum — Developers room : bhanuponguru via Audiogames-reflector


  


Re: python open.write insert's extra lines after any line after writing?

hmm, what? it looks like both are same

URL: https://forum.audiogames.net/post/605646/#p605646




-- 
Audiogames-reflector mailing list
Audiogames-reflector@sabahattin-gucukoglu.com
https://sabahattin-gucukoglu.com/cgi-bin/mailman/listinfo/audiogames-reflector


Re: Python: Usage for Joysticks and External Controllers?

2021-01-01 Thread AudioGames . net Forum — Developers room : chrisnorman7 via Audiogames-reflector


  


Re: Python: Usage for Joysticks and External Controllers?

@16Actually it was @12 who told me about it, so I can't take any credit.It's good stuff though.

URL: https://forum.audiogames.net/post/603573/#p603573




-- 
Audiogames-reflector mailing list
Audiogames-reflector@sabahattin-gucukoglu.com
https://sabahattin-gucukoglu.com/cgi-bin/mailman/listinfo/audiogames-reflector


Re: Python: Usage for Joysticks and External Controllers?

2021-01-01 Thread AudioGames . net Forum — Developers room : Ethin via Audiogames-reflector


  


Re: Python: Usage for Joysticks and External Controllers?

@15, oh, I didn't know that package even existed. Thanks for that tip!

URL: https://forum.audiogames.net/post/603550/#p603550




-- 
Audiogames-reflector mailing list
Audiogames-reflector@sabahattin-gucukoglu.com
https://sabahattin-gucukoglu.com/cgi-bin/mailman/listinfo/audiogames-reflector


Re: Python: Usage for Joysticks and External Controllers?

2020-12-31 Thread AudioGames . net Forum — Developers room : chrisnorman7 via Audiogames-reflector


  


Re: Python: Usage for Joysticks and External Controllers?

@13No worries mate, you just pip install pysdl2-dll and all is fixed. Got it working beautifully. Thanks all for your help and suggestions.

URL: https://forum.audiogames.net/post/603446/#p603446




-- 
Audiogames-reflector mailing list
Audiogames-reflector@sabahattin-gucukoglu.com
https://sabahattin-gucukoglu.com/cgi-bin/mailman/listinfo/audiogames-reflector


Re: Python: Usage for Joysticks and External Controllers?

2020-12-31 Thread AudioGames . net Forum — Developers room : amerikranian via Audiogames-reflector


  


Re: Python: Usage for Joysticks and External Controllers?

Would it be correct to assume that the majority of features of PySDL2 are aimed at ECS? See this for a possible explanation for this assumption

URL: https://forum.audiogames.net/post/603425/#p603425




-- 
Audiogames-reflector mailing list
Audiogames-reflector@sabahattin-gucukoglu.com
https://sabahattin-gucukoglu.com/cgi-bin/mailman/listinfo/audiogames-reflector


Re: Python: Usage for Joysticks and External Controllers?

2020-12-29 Thread AudioGames . net Forum — Developers room : Ethin via Audiogames-reflector


  


Re: Python: Usage for Joysticks and External Controllers?

Agreed with 12. Use PySDL2. (Note: I've had trouble using PySDL2 on Windows. In particular, I had to modify the source code to get it to find sdl2.dll... Its search path is kinda weird, though I don't remember it off the top of my head.)@11Its unlikely that Pygame/Piglet, if they do use SDL2 underneath, couldn't add force-feedback (or any other SDL2-based API that isn't obsoleted by something Python provides in its stdlib). Its more likely that they just don't want to. Assuming, mind, that both are powered by SDL2.

URL: https://forum.audiogames.net/post/603000/#p603000




-- 
Audiogames-reflector mailing list
Audiogames-reflector@sabahattin-gucukoglu.com
https://sabahattin-gucukoglu.com/cgi-bin/mailman/listinfo/audiogames-reflector


Re: Python: Usage for Joysticks and External Controllers?

2020-12-29 Thread AudioGames . net Forum — Developers room : Ethin via Audiogames-reflector


  


Re: Python: Usage for Joysticks and External Controllers?

Agreed with 12. Use PySDL2. (Note: I've had trouble using PySDL2 on Windows. In particular, I had to modify the source code to get it to find sdl2.dll... Its search path is kinda weird, though I don't remember it off the top of my head.)

URL: https://forum.audiogames.net/post/603000/#p603000




-- 
Audiogames-reflector mailing list
Audiogames-reflector@sabahattin-gucukoglu.com
https://sabahattin-gucukoglu.com/cgi-bin/mailman/listinfo/audiogames-reflector


Re: Python: Usage for Joysticks and External Controllers?

2020-12-29 Thread AudioGames . net Forum — Developers room : Ethin via Audiogames-reflector


  


Re: Python: Usage for Joysticks and External Controllers?

Agreed with 12. Use PySDL. (Note: I've had trouble using PySDL on Windows. In particular, I had to modify the source code to get it to find sdl2.dll... Its search path is kinda weird, though I don't remember it off the top of my head.)

URL: https://forum.audiogames.net/post/603000/#p603000




-- 
Audiogames-reflector mailing list
Audiogames-reflector@sabahattin-gucukoglu.com
https://sabahattin-gucukoglu.com/cgi-bin/mailman/listinfo/audiogames-reflector


Re: Python: Usage for Joysticks and External Controllers?

2020-12-29 Thread AudioGames . net Forum — Developers room : amerikranian via Audiogames-reflector


  


Re: Python: Usage for Joysticks and External Controllers?

You could try PySDL2, which is a binding to SDL in python. It should support your needs.

URL: https://forum.audiogames.net/post/602984/#p602984




-- 
Audiogames-reflector mailing list
Audiogames-reflector@sabahattin-gucukoglu.com
https://sabahattin-gucukoglu.com/cgi-bin/mailman/listinfo/audiogames-reflector


Re: Python: Usage for Joysticks and External Controllers?

2020-12-29 Thread AudioGames . net Forum — Developers room : chrisnorman7 via Audiogames-reflector


  


Re: Python: Usage for Joysticks and External Controllers?

@10Wow, OK, that's pretty cool.Does that mean force feedback works from Python, it's just not supported natively by either Pyglet or Pygame?

URL: https://forum.audiogames.net/post/602977/#p602977




-- 
Audiogames-reflector mailing list
Audiogames-reflector@sabahattin-gucukoglu.com
https://sabahattin-gucukoglu.com/cgi-bin/mailman/listinfo/audiogames-reflector


Re: Python: Usage for Joysticks and External Controllers?

2020-12-29 Thread AudioGames . net Forum — Developers room : Ethin via Audiogames-reflector


  


Re: Python: Usage for Joysticks and External Controllers?

SDL2's joystick support is wonderful. It needs a set of joystick button mappings to function, though. Such a mapping database is available here. To load it, use SDL_GameControllerAddMapping, SDL_GameControllerAddMappingsFromFile or SDL_GameControllerAddMappingsFromRW to load these. The game controller API is mapped on top of the joystick API. Once loaded, call SDL_NumJoysticks to check for joysticks/game controllers, then use SDL_GameControllerOpen to open one. Then you can use the other functions from either the Joystick and Game Controller APIs. For force feedback, use this API.

URL: https://forum.audiogames.net/post/602969/#p602969




-- 
Audiogames-reflector mailing list
Audiogames-reflector@sabahattin-gucukoglu.com
https://sabahattin-gucukoglu.com/cgi-bin/mailman/listinfo/audiogames-reflector


Re: Python: Usage for Joysticks and External Controllers?

2020-12-29 Thread AudioGames . net Forum — Developers room : GrannyCheeseWheel via Audiogames-reflector


  


Re: Python: Usage for Joysticks and External Controllers?

Well maybe digging into SDL2 can fix that, I don't know. I do know that if I play a game with a controller, and it doesn't have rumble support, I'd just as soon switch back to keyboard unless there's a really good reason knot to.

URL: https://forum.audiogames.net/post/602904/#p602904




-- 
Audiogames-reflector mailing list
Audiogames-reflector@sabahattin-gucukoglu.com
https://sabahattin-gucukoglu.com/cgi-bin/mailman/listinfo/audiogames-reflector


Re: Python: Usage for Joysticks and External Controllers?

2020-12-29 Thread AudioGames . net Forum — Developers room : chrisnorman7 via Audiogames-reflector


  


Re: Python: Usage for Joysticks and External Controllers?

@5Neither does Pyglet, sadly.

URL: https://forum.audiogames.net/post/602838/#p602838




-- 
Audiogames-reflector mailing list
Audiogames-reflector@sabahattin-gucukoglu.com
https://sabahattin-gucukoglu.com/cgi-bin/mailman/listinfo/audiogames-reflector


Re: Python: Usage for Joysticks and External Controllers?

2020-12-29 Thread AudioGames . net Forum — Developers room : Alan via Audiogames-reflector


  


Re: Python: Usage for Joysticks and External Controllers?

HEY, just in case you are still interested, I added joystick support for pygame aplications on the past.Basically, you initialize an instance of pygame.joystick.joystick(id), and check the state of a button by myjoystick.get_button(buttonId). for axes, you get the current value with: myjoystick.get_axis(axisId). In this case, it returns a value from -1.0 to 1.0 representing the current state.of course, checking input this way is not optimal at all, so soon or later you'll need to write your own snipets. My aproach is a getState function that returns a state object with all current controller values for buttons and axes, so I can compare it with a previous joystick state.I can share some code if someone is interested, but it's not hard to write your own wrapper.Finally, there should be a lot of other options out there, but hopefully it could help you, at least for experimenting purposes.Happy codinn.Edit: I forgot to mention that you can listen for events such as pygame.JOYBUTTONDOWN or pygame.JOYBUTTONUP, etc. Event.button represents the button that has been pressed or released, I think. I am writing this topic from my phone, cannot test code or consult the documentation, but this is the main concept.I didn't use this last aproach because writing my own button_pressed funtion seemed easier checking and comparing an object representing the joystick state than dealing with different event types, JOYBUTTONDOWN, JOYAXISMOTION, etc.

URL: https://forum.audiogames.net/post/602794/#p602794




-- 
Audiogames-reflector mailing list
Audiogames-reflector@sabahattin-gucukoglu.com
https://sabahattin-gucukoglu.com/cgi-bin/mailman/listinfo/audiogames-reflector


Re: Python: Usage for Joysticks and External Controllers?

2020-12-28 Thread AudioGames . net Forum — Developers room : Alan via Audiogames-reflector


  


Re: Python: Usage for Joysticks and External Controllers?

HEY, just in case you are still interested, I added joystick support for pygame aplications on the past.Basically, you initialize an instance of pygame.joystick.joystick(id), and check the state of a button by myjoystick.get_button(buttonId). for axes, you get the current value with: myjoystick.get_axis(axisId). In this case, it returns a value from -1.0 to 1.0 representing the current state.of course, checking input this way is not optimal at all, so soon or later you'll need to write your own snipets. My aproach is a getState function that returns a state object with all current controller values for buttons and axes, so I can compare it with a previous joystick state.I can share some code if someone is interested, but it's not hard to write your own wrapper.Finally, there should be a lot of other options out there, but hopefully it could help you, at least for experimenting purposes.Happy coding.

URL: https://forum.audiogames.net/post/602794/#p602794




-- 
Audiogames-reflector mailing list
Audiogames-reflector@sabahattin-gucukoglu.com
https://sabahattin-gucukoglu.com/cgi-bin/mailman/listinfo/audiogames-reflector


Re: Python: Usage for Joysticks and External Controllers?

2020-12-28 Thread AudioGames . net Forum — Developers room : redfox via Audiogames-reflector


  


Re: Python: Usage for Joysticks and External Controllers?

Yeah, I've never liked Piglet. Optimally, I'd have rumble support as well.

URL: https://forum.audiogames.net/post/602777/#p602777




-- 
Audiogames-reflector mailing list
Audiogames-reflector@sabahattin-gucukoglu.com
https://sabahattin-gucukoglu.com/cgi-bin/mailman/listinfo/audiogames-reflector


Re: Python: Usage for Joysticks and External Controllers?

2020-12-28 Thread AudioGames . net Forum — Developers room : GrannyCheeseWheel via Audiogames-reflector


  


Re: Python: Usage for Joysticks and External Controllers?

Pygame's controller support doesn't give you rumble support though. I do not really like pyglet all that much.

URL: https://forum.audiogames.net/post/602773/#p602773




-- 
Audiogames-reflector mailing list
Audiogames-reflector@sabahattin-gucukoglu.com
https://sabahattin-gucukoglu.com/cgi-bin/mailman/listinfo/audiogames-reflector


Re: Python: Usage for Joysticks and External Controllers?

2020-12-28 Thread AudioGames . net Forum — Developers room : chrisnorman7 via Audiogames-reflector


  


Re: Python: Usage for Joysticks and External Controllers?

Pyglet has controller support too.Shameless plug here: Earwax lets you specify button numbers and hat directions when you define actions, along with keyboard and mouse buttons.

URL: https://forum.audiogames.net/post/602757/#p602757




-- 
Audiogames-reflector mailing list
Audiogames-reflector@sabahattin-gucukoglu.com
https://sabahattin-gucukoglu.com/cgi-bin/mailman/listinfo/audiogames-reflector


Re: Python: Usage for Joysticks and External Controllers?

2020-12-28 Thread AudioGames . net Forum — Developers room : Turret via Audiogames-reflector


  


Re: Python: Usage for Joysticks and External Controllers?

@2 is correct. Look up SDL2, though, not sure if it changed between versions.

URL: https://forum.audiogames.net/post/602746/#p602746




-- 
Audiogames-reflector mailing list
Audiogames-reflector@sabahattin-gucukoglu.com
https://sabahattin-gucukoglu.com/cgi-bin/mailman/listinfo/audiogames-reflector


Re: Python: Usage for Joysticks and External Controllers?

2020-12-28 Thread AudioGames . net Forum — Developers room : Hijacker via Audiogames-reflector


  


Re: Python: Usage for Joysticks and External Controllers?

Just look up SDL2 and joysticks/gamepads in general, that will explain everything you need to know, since pygame is just a wrapper for SDL/SDL2.

URL: https://forum.audiogames.net/post/602732/#p602732




-- 
Audiogames-reflector mailing list
Audiogames-reflector@sabahattin-gucukoglu.com
https://sabahattin-gucukoglu.com/cgi-bin/mailman/listinfo/audiogames-reflector


Re: Python: Confusion on the Way I Might Pull This List Comprehention Off

2020-11-28 Thread AudioGames . net Forum — Developers room : redfox via Audiogames-reflector


  


Re: Python: Confusion on the Way I Might Pull This List Comprehention Off

It's not that I'm flattening the inventory for the player visibility, I was just talking about how I thinking of flattening it temporarily for the searching. Either way, these definitely help.

URL: https://forum.audiogames.net/post/593600/#p593600




-- 
Audiogames-reflector mailing list
Audiogames-reflector@sabahattin-gucukoglu.com
https://sabahattin-gucukoglu.com/cgi-bin/mailman/listinfo/audiogames-reflector


Re: Python: Confusion on the Way I Might Pull This List Comprehention Off

2020-11-28 Thread AudioGames . net Forum — Developers room : camlorn via Audiogames-reflector


  


Re: Python: Confusion on the Way I Might Pull This List Comprehention Off

@7For what it's worth, knowing them generalizes to JS, C#, C++, and several other languages.

URL: https://forum.audiogames.net/post/593596/#p593596




-- 
Audiogames-reflector mailing list
Audiogames-reflector@sabahattin-gucukoglu.com
https://sabahattin-gucukoglu.com/cgi-bin/mailman/listinfo/audiogames-reflector


Re: Python: Confusion on the Way I Might Pull This List Comprehention Off

2020-11-28 Thread AudioGames . net Forum — Developers room : amerikranian via Audiogames-reflector


  


Re: Python: Confusion on the Way I Might Pull This List Comprehention Off

That’s it. Looking at generators next.

URL: https://forum.audiogames.net/post/593580/#p593580




-- 
Audiogames-reflector mailing list
Audiogames-reflector@sabahattin-gucukoglu.com
https://sabahattin-gucukoglu.com/cgi-bin/mailman/listinfo/audiogames-reflector


Re: Python: Confusion on the Way I Might Pull This List Comprehention Off

2020-11-28 Thread AudioGames . net Forum — Developers room : camlorn via Audiogames-reflector


  


Re: Python: Confusion on the Way I Might Pull This List Comprehention Off

Actually, to modify Amerikranian's code slightly (untested, but should be correct):def recursive_search(chunk):
for key in chunk:
if isinstance(chunk[key], dict):
yield from recursive_search(chunk[key])
else:
yield (key, chunk[key])Then you can do a few things with that, for example:aggregated = {}
for k, v in recursive_search(inventory):
aggregated[k] = aggregated.get(k, 0) + vWhich is probably the cleanest way you're going to be able to do this, and also doesn't allocate/create any intermediate objects save for the final aggregated dict.  I haven't measured but I would expect this to be roughly the fastest implementation.Everyone always overlooks generators, in other words.

URL: https://forum.audiogames.net/post/593569/#p593569




-- 
Audiogames-reflector mailing list
Audiogames-reflector@sabahattin-gucukoglu.com
https://sabahattin-gucukoglu.com/cgi-bin/mailman/listinfo/audiogames-reflector


Re: Python: Confusion on the Way I Might Pull This List Comprehention Off

2020-11-28 Thread AudioGames . net Forum — Developers room : camlorn via Audiogames-reflector


  


Re: Python: Confusion on the Way I Might Pull This List Comprehention Off

If you wanted nested containers you either end up doing something like what I suggested in post 2, or you do post 4, which is 90% or so of what I suggested in post 2, just minus some of the data model.What 4 is suggesting should be fine in terms of performance, and can be easily modified to accumulate results in a dict that you pass down as a second parameter to the recursive function.  If you pass an accumulation dict down as the second parameter, then you can avoid the intermediate dicts as well.But to be honest, I suspect you're modeling this wrong.  If containers are an important enough concept that you want them to hold items, then you're basically saying that it doesn't matter if I put things in the bag, you'll just show them at the top level anyway.  If you're going to do that, you might as well just let containers upgrade inventory capacity, like how other upgrades might increase max hp, and not bother with the complexity at all.  Perhaps we're misunderstanding what you want to do.

URL: https://forum.audiogames.net/post/593541/#p593541




-- 
Audiogames-reflector mailing list
Audiogames-reflector@sabahattin-gucukoglu.com
https://sabahattin-gucukoglu.com/cgi-bin/mailman/listinfo/audiogames-reflector


Re: Python: Confusion on the Way I Might Pull This List Comprehention Off

2020-11-28 Thread AudioGames . net Forum — Developers room : amerikranian via Audiogames-reflector


  


Re: Python: Confusion on the Way I Might Pull This List Comprehention Off

Right. Playing with recursion for 10 or so minutes yields this for expanding all the dictionariesdef recursive_search(chunk):
full_data = {}
for key in chunk:
if isinstance(chunk[key], dict):
full_data = {**full_data, **recursive_search(chunk[key])}
else:
full_data[key] = chunk[key]
return full_data


#Driver code
test_dict = {
"a": 0,
"b": {
"c": 1,
"d": {
"e": 2,
},
"f": 3,
},
"g": 4,
}

print(recursive_search(test_dict))Running this produces the following output:{'a': 0, 'c': 1, 'e': 2, 'f': 3, 'g': 4}This does not handle duplicate keys. I.e, consider your player having this inventory:Healing_potion: 8,
bag_of_holding:
healing_potion: 2Running this function does not guarantee that your player will have 10 healing potions. They will either have eight or two, depending upon how Python sorts the dict. It is possible to fix this, but I'll leave it up to you to do so.Also note that I can't imagine this being too friendly in terms of speed. You're basically creating a new dictionary based on the original chunk with expanded containers, or other dicts. Still, I can't think of a better approach.Hope this helps.

URL: https://forum.audiogames.net/post/593505/#p593505




-- 
Audiogames-reflector mailing list
Audiogames-reflector@sabahattin-gucukoglu.com
https://sabahattin-gucukoglu.com/cgi-bin/mailman/listinfo/audiogames-reflector


Re: Python: Confusion on the Way I Might Pull This List Comprehention Off

2020-11-27 Thread AudioGames . net Forum — Developers room : redfox via Audiogames-reflector


  


Re: Python: Confusion on the Way I Might Pull This List Comprehention Off

The order of items is unimportant. If at some point items need to be sorted, such as if I have a filterable Inventory Menu, there is another player method, sort_inventory, that handles that.The issue is not putting things inside of items that aren't containers. The issue is that of the possibility of there being containers inside containers, and so on.The game won't be very complex, probably not even worth a release of any kind, maybe a Github Repo, but even that's iffy.Any simpler solutions pop into your brain that can be easily listed off?

URL: https://forum.audiogames.net/post/593433/#p593433




-- 
Audiogames-reflector mailing list
Audiogames-reflector@sabahattin-gucukoglu.com
https://sabahattin-gucukoglu.com/cgi-bin/mailman/listinfo/audiogames-reflector


Re: Python: Confusion on the Way I Might Pull This List Comprehention Off

2020-11-27 Thread AudioGames . net Forum — Developers room : camlorn via Audiogames-reflector


  


Re: Python: Confusion on the Way I Might Pull This List Comprehention Off

You won't have much luck with list comprehensions here.  It's technically possible to use them but isn't worth it and will be an unreadable mess.You're inventing trees, if that's helpful.  If you just say that all objects have inventories whether or not they're containers, then just write your code so that it's never possible to put something in something that's not a container, you can write a straightforward recursive function that'll search starting at a specific object moving down until it either finds the thing or reaches the end.Objects as keys in a Python dict will work until it doesn't.  Doesn't starts at overriding special methods like __eq__ and __hash__.  The bigger problem, though, is that items won't necessarily stay in the same order in the player's inventory, particularly when restarting the game.I'm not offering solutions because they all have tradeoffs of one sort or another here and there's not a right answer, only answers that fit your project.

URL: https://forum.audiogames.net/post/593431/#p593431




-- 
Audiogames-reflector mailing list
Audiogames-reflector@sabahattin-gucukoglu.com
https://sabahattin-gucukoglu.com/cgi-bin/mailman/listinfo/audiogames-reflector


Re: python users please save me

2020-11-04 Thread AudioGames . net Forum — Developers room : cartertemm via Audiogames-reflector


  


Re: python users please save me

Are you sure it's not the run dialog or something else that's blocked? Try making a file called cmd.bat with the following:@echo off
%systemroot%\system32\cmd.exeOtherwise it may be worth asking for an accommodation, as without a command prompt you aren't going to get far unfortunately.

URL: https://forum.audiogames.net/post/586501/#p586501




-- 
Audiogames-reflector mailing list
Audiogames-reflector@sabahattin-gucukoglu.com
https://sabahattin-gucukoglu.com/cgi-bin/mailman/listinfo/audiogames-reflector


Re: python users please save me

2020-11-04 Thread AudioGames . net Forum — Developers room : Dragonlee via Audiogames-reflector


  


Re: python users please save me

you are blocked from opening up  cmd.exe? but I thought you were using the python interpreter on command line since the online repl wasn't accessible. how are you working with the python interpreter then?also on a unrelated note. have you asked your teacher what they expect you to complete the lab? i.e. are you just supposed to use things in the standard library or to use some other library like PIL?also unrelated, to the others here that recommended numpy and other data science libraries to to a complete programming beginner, instead of pil: WAT

URL: https://forum.audiogames.net/post/586486/#p586486




-- 
Audiogames-reflector mailing list
Audiogames-reflector@sabahattin-gucukoglu.com
https://sabahattin-gucukoglu.com/cgi-bin/mailman/listinfo/audiogames-reflector


Re: python users please save me

2020-11-04 Thread AudioGames . net Forum — Developers room : Blue-Eyed Demon via Audiogames-reflector


  


Re: python users please save me

Alright everyone hello again. So I have appreciated everything that you guys have suggested. Unfortunately however, I must ask another question about the topic. So you guys have suggested opencv and pillow and pil and all of those, but there is just one problem. From what I have found, you require the command terminal in order to install any of those. The problem with that is that I don't have access to cmd because my school has blocked it on their computers. Is there any other way to install these without cmd?

URL: https://forum.audiogames.net/post/586476/#p586476




-- 
Audiogames-reflector mailing list
Audiogames-reflector@sabahattin-gucukoglu.com
https://sabahattin-gucukoglu.com/cgi-bin/mailman/listinfo/audiogames-reflector


Re: python users please save me

2020-11-03 Thread AudioGames . net Forum — Developers room : chrisnorman7 via Audiogames-reflector


  


Re: python users please save me

@15As far as I know, pillow is a better version of pil, and the API is still the same.

URL: https://forum.audiogames.net/post/586021/#p586021




-- 
Audiogames-reflector mailing list
Audiogames-reflector@sabahattin-gucukoglu.com
https://sabahattin-gucukoglu.com/cgi-bin/mailman/listinfo/audiogames-reflector


Re: python users please save me

2020-11-02 Thread AudioGames . net Forum — Developers room : visualstudio via Audiogames-reflector


  


Re: python users please save me

hi,you can use pillow, OpenCV, imageIO, scikit-image and so on.for OpenCV (which I use myself), you call imread with the name of your image as the first parameter, and what it gives you back is a numpy.ndarray which you can obtain it's shapeto install OpenCV, execute this command in your cmd:pip install opencv_python

URL: https://forum.audiogames.net/post/585875/#p585875




-- 
Audiogames-reflector mailing list
Audiogames-reflector@sabahattin-gucukoglu.com
https://sabahattin-gucukoglu.com/cgi-bin/mailman/listinfo/audiogames-reflector


Re: python users please save me

2020-11-02 Thread AudioGames . net Forum — Developers room : Ethin via Audiogames-reflector


  


Re: python users please save me

@14, I suspect what you meant to say was that you couldn't get your code to open the file. You can parse the image manually, but that's not going to be an easy task at all and I wouldn't do that if your just starting out. There are rare times when you do need to manually parse an image, and this isn't one of them. Use pil/imageio to do it. A google search should guide you. (Don't use the method outlined in@6; that'll just give you a headache and confuse you a lot more.)

URL: https://forum.audiogames.net/post/585819/#p585819




-- 
Audiogames-reflector mailing list
Audiogames-reflector@sabahattin-gucukoglu.com
https://sabahattin-gucukoglu.com/cgi-bin/mailman/listinfo/audiogames-reflector


Re: python users please save me

2020-11-02 Thread AudioGames . net Forum — Developers room : Blue-Eyed Demon via Audiogames-reflector


  


Re: python users please save me

Hi all. I am sorry for being so unclear up to this point. As I said I am just getting into python and coding in general for that matter, so I don't really know how to word what exactly I need properly. Also, the lab I am doing was supposed to be done through the repl.it website but I am trying to do it through the command line version since repl.it doesn't really seem to be accessible enough to use.

URL: https://forum.audiogames.net/post/585804/#p585804




-- 
Audiogames-reflector mailing list
Audiogames-reflector@sabahattin-gucukoglu.com
https://sabahattin-gucukoglu.com/cgi-bin/mailman/listinfo/audiogames-reflector


Re: python users please save me

2020-11-02 Thread AudioGames . net Forum — Developers room : magurp244 via Audiogames-reflector


  


Re: python users please save me

@12I'm not sure its a specific bias towards JPEG, so much as the Python dev's clearing out redundant code. There was an update about it [here], much of their rationalization is that the code is dated, unmaintained, and third parties like PIL provide better support.

URL: https://forum.audiogames.net/post/585801/#p585801




-- 
Audiogames-reflector mailing list
Audiogames-reflector@sabahattin-gucukoglu.com
https://sabahattin-gucukoglu.com/cgi-bin/mailman/listinfo/audiogames-reflector


Re: python users please save me

2020-11-02 Thread AudioGames . net Forum — Developers room : magurp244 via Audiogames-reflector


  


Re: python users please save me

@12I'm not sure its a specific bias towards JPEG, so much as the Python dev's clearing out unmaintained/outdated code. There was an update about it [here] about it, much of their rationalization is that the code is dated, unmaintained, and third parties like PIL provide better support.

URL: https://forum.audiogames.net/post/585801/#p585801




-- 
Audiogames-reflector mailing list
Audiogames-reflector@sabahattin-gucukoglu.com
https://sabahattin-gucukoglu.com/cgi-bin/mailman/listinfo/audiogames-reflector


Re: python users please save me

2020-11-02 Thread AudioGames . net Forum — Developers room : CAE_Jones via Audiogames-reflector


  


Re: python users please save me

Pygame uses imageio, doesn't it? I'd've gone with the same as 6, on the grounds that 1 was rather nonspecific about what all will be needed when, so I'd just load the whole thing and be done with it. That said, I had no idea they'd dropped jpg support.  ... Why did they do that? That's weird. I wasn't aware that jpg was the XP of image formats, or whatever.

URL: https://forum.audiogames.net/post/585799/#p585799




-- 
Audiogames-reflector mailing list
Audiogames-reflector@sabahattin-gucukoglu.com
https://sabahattin-gucukoglu.com/cgi-bin/mailman/listinfo/audiogames-reflector


Re: python users please save me

2020-11-02 Thread AudioGames . net Forum — Developers room : camlorn via Audiogames-reflector


  


Re: python users please save me

@8I did read your entire post.  My point stands.  Posting solutions that are the worst way to do something then saying "so this is kind of bad" when the things that are better than it are at the same level of difficulty is counterproductive.  If this was collision or something and it was "use this really slow 10 line algorithm" vs "learn about several data structures, then use them together", okay.  But this isn't that in the slightest.

URL: https://forum.audiogames.net/post/585780/#p585780




-- 
Audiogames-reflector mailing list
Audiogames-reflector@sabahattin-gucukoglu.com
https://sabahattin-gucukoglu.com/cgi-bin/mailman/listinfo/audiogames-reflector


Re: python users please save me

2020-11-02 Thread AudioGames . net Forum — Developers room : Blue-Eyed Demon via Audiogames-reflector


  


Re: python users please save me

As for what info I need. I need to get the height and width of the image to start out with.

URL: https://forum.audiogames.net/post/585698/#p585698




-- 
Audiogames-reflector mailing list
Audiogames-reflector@sabahattin-gucukoglu.com
https://sabahattin-gucukoglu.com/cgi-bin/mailman/listinfo/audiogames-reflector


Re: python users please save me

2020-11-02 Thread AudioGames . net Forum — Developers room : Rastislav Kish via Audiogames-reflector


  


Re: python users please save me

Hi there,@7: I recommend reading the post to the end, that's a good practice in general. Best regardsRastislav

URL: https://forum.audiogames.net/post/585766/#p585766




-- 
Audiogames-reflector mailing list
Audiogames-reflector@sabahattin-gucukoglu.com
https://sabahattin-gucukoglu.com/cgi-bin/mailman/listinfo/audiogames-reflector


Re: python users please save me

2020-11-02 Thread AudioGames . net Forum — Developers room : cartertemm via Audiogames-reflector


  


Re: python users please save me

moderation:Nothing to see here, just moving the topic to a place that would better befit the subject.

URL: https://forum.audiogames.net/post/585777/#p585777




-- 
Audiogames-reflector mailing list
Audiogames-reflector@sabahattin-gucukoglu.com
https://sabahattin-gucukoglu.com/cgi-bin/mailman/listinfo/audiogames-reflector


Re: python users please save me

2020-11-02 Thread AudioGames . net Forum — Developers room : Turkce_Rap via Audiogames-reflector


  


Re: python users please save me

This thread belongs to developper section.Also You should put more details on what are You aiming to do, what kinda info You want to pick etc.

URL: https://forum.audiogames.net/post/585697/#p585697




-- 
Audiogames-reflector mailing list
Audiogames-reflector@sabahattin-gucukoglu.com
https://sabahattin-gucukoglu.com/cgi-bin/mailman/listinfo/audiogames-reflector


Re: python users please save me

2020-11-02 Thread AudioGames . net Forum — Developers room : camlorn via Audiogames-reflector


  


Re: python users please save me

@6That's the least efficient way to do it that possibly exists.  Use pil, or an ffmpeg wrapper, or any of several other things that know how to get this efficiently.  You can almost always get it from encoded headers/metadata or, failing that, by only partly decoding the file.  What you're proposing technically answers the question but is very much in the category of "all I had was a hammer", if you're familiar with the English idiom.  Since the dedicated image libraries aren't actually more code, why not use them?Numpy/Scipy also only support a very limited set of formats out of the box anyway, unless something has changed.  I'm not actually sure if jpg is on that list or not.Unfortunately it looks like the built-in Jpeg module was removed in Python 3.

URL: https://forum.audiogames.net/post/585732/#p585732




-- 
Audiogames-reflector mailing list
Audiogames-reflector@sabahattin-gucukoglu.com
https://sabahattin-gucukoglu.com/cgi-bin/mailman/listinfo/audiogames-reflector


Re: python users please save me

2020-11-02 Thread AudioGames . net Forum — Developers room : camlorn via Audiogames-reflector


  


Re: python users please save me

You say "focus on".  What does this mean?A lot of people end up using a library called pil in order to extract image metadata, but there might be something built into the standard library for it.  This isn't a hard problem, though.  You should have been able to find solutions via Google.  What have you tried and how has it broken?  Is there a more specific question or problem that's stopping you?

URL: https://forum.audiogames.net/post/585711/#p585711




-- 
Audiogames-reflector mailing list
Audiogames-reflector@sabahattin-gucukoglu.com
https://sabahattin-gucukoglu.com/cgi-bin/mailman/listinfo/audiogames-reflector


Re: python users please save me

2020-11-02 Thread AudioGames . net Forum — Developers room : magurp244 via Audiogames-reflector


  


Re: python users please save me

Considering your goal is to get the metadata and alter the image data, you'll likely require an image handling library like some of those mentioned. Other's could include Pyglet, wxPython, or Pygame as well.

URL: https://forum.audiogames.net/post/585774/#p585774




-- 
Audiogames-reflector mailing list
Audiogames-reflector@sabahattin-gucukoglu.com
https://sabahattin-gucukoglu.com/cgi-bin/mailman/listinfo/audiogames-reflector


Re: python users please save me

2020-11-02 Thread AudioGames . net Forum — Developers room : Rastislav Kish via Audiogames-reflector


  


Re: python users please save me

Hi there,@1: hmm, under the term focus something, we usually understand moving the keyboard focus to a particular place in the environment. This is quite rarely done outside your own app, so I guess you probably meaned something else?As for getting width and height of a particular image, well, this is not that simple. An image is a bunch of bytes, which you need to decode first to a matrix of pixels i.e. three dimensional array in order to work with it. As you wrote, that you're just starting in Python, make sure you know this concept, as doing this stuff without it is... kind of difficult. Then, you most likely don't want to write your own JpG decoder, as there is plenty of them already available and it would be a waste of time. My favorite is ImageIO. You can install it along numpy like:pip install numpy imageioYou can then load an image into a numpy array like so:import numpy as np
from imageio import imread

image=np.asarray(imread("image.jpg"))
print(f"Dymensions of the image are {image.shape}")Here image.shape returns a tuple containing array dymensions i.e. if the array is 3D, it will contain three items, usually x, y and 3.Now, the question is, which of the two first elements is width and whichone height.If I remember right, the firstone was height and secondone width, but I recommend checking it out either in imageio's documentation or by comparing with a viewer, i've worked with few libraries for handling images including ImageIO, PIL and OpenCV, and they use various formats for this.PIL and OpenCV also have various functions for shifting, rotating, zooming and other functions, which you may be interested in. There are plenty of tutorials especially for OpenCV, btw the loading syntax is very similar to thatone of ImageIO.Also note that the sample above decompresses and loads the whole image to memory, as finding its shape is usually not the only thing you want to do. There are also cases when however it's the only required information, and you don't need to load the whole thing in that case. OpenCV has a function to get the dimensions only, so you can use it as well when necessary.Best regardsRastislav

URL: https://forum.audiogames.net/post/585717/#p585717




-- 
Audiogames-reflector mailing list
Audiogames-reflector@sabahattin-gucukoglu.com
https://sabahattin-gucukoglu.com/cgi-bin/mailman/listinfo/audiogames-reflector


Re: python users please save me

2020-11-02 Thread AudioGames . net Forum — Developers room : Meatbag via Audiogames-reflector


  


Re: python users please save me

dont know what you exactly need, do you want to navegate to the file from a command line? just, cd , please be a bit more clear

URL: https://forum.audiogames.net/post/585688/#p585688




-- 
Audiogames-reflector mailing list
Audiogames-reflector@sabahattin-gucukoglu.com
https://sabahattin-gucukoglu.com/cgi-bin/mailman/listinfo/audiogames-reflector


Re: python users please save me

2020-11-02 Thread AudioGames . net Forum — Off-topic room : magurp244 via Audiogames-reflector


  


Re: python users please save me

Considering your goal is to get the metadata and alter the image data, you'll likely require an image handling library like some of those mentioned. Other's could include Pyglet, wxPython, or Pygame as well.

URL: https://forum.audiogames.net/post/585774/#p585774




-- 
Audiogames-reflector mailing list
Audiogames-reflector@sabahattin-gucukoglu.com
https://sabahattin-gucukoglu.com/cgi-bin/mailman/listinfo/audiogames-reflector


Re: python users please save me

2020-11-02 Thread AudioGames . net Forum — Off-topic room : Rastislav Kish via Audiogames-reflector


  


Re: python users please save me

Hi there,@7: I recommend reading the post to the end, that's a good practice in general. Best regardsRastislav

URL: https://forum.audiogames.net/post/585766/#p585766




-- 
Audiogames-reflector mailing list
Audiogames-reflector@sabahattin-gucukoglu.com
https://sabahattin-gucukoglu.com/cgi-bin/mailman/listinfo/audiogames-reflector


Re: python users please save me

2020-11-02 Thread AudioGames . net Forum — Off-topic room : Rastislav Kish via Audiogames-reflector


  


Re: python users please save me

Hi there,@7: read the post to the end, that's a good practice in general. best regardsRastislav

URL: https://forum.audiogames.net/post/585766/#p585766




-- 
Audiogames-reflector mailing list
Audiogames-reflector@sabahattin-gucukoglu.com
https://sabahattin-gucukoglu.com/cgi-bin/mailman/listinfo/audiogames-reflector


Re: python users please save me

2020-11-02 Thread AudioGames . net Forum — Off-topic room : camlorn via Audiogames-reflector


  


Re: python users please save me

@6That's the least efficient way to do it that possibly exists.  Use pil, or an ffmpeg wrapper, or any of several other things that know how to get this efficiently.  You can almost always get it from encoded headers/metadata or, failing that, by only partly decoding the file.  What you're proposing technically answers the question but is very much in the category of "all I had was a hammer", if you're familiar with the English idiom.  Since the dedicated image libraries aren't actually more code, why not use them?Numpy/Scipy also only support a very limited set of formats out of the box anyway, unless something has changed.  I'm not actually sure if jpg is on that list or not.Unfortunately it looks like the built-in Jpeg module was removed in Python 3.

URL: https://forum.audiogames.net/post/585732/#p585732




-- 
Audiogames-reflector mailing list
Audiogames-reflector@sabahattin-gucukoglu.com
https://sabahattin-gucukoglu.com/cgi-bin/mailman/listinfo/audiogames-reflector


Re: python users please save me

2020-11-02 Thread AudioGames . net Forum — Off-topic room : Rastislav Kish via Audiogames-reflector


  


Re: python users please save me

Hi there,@1: hmm, under the term focus something, we usually understand moving the keyboard focus to a particular place in the environment. This is quite rarely done outside your own app, so I guess you probably meaned something else?As for getting width and height of a particular image, well, this is not that simple. An image is a bunch of bytes, which you need to decode first to a matrix of pixels i.e. three dimensional array in order to work with it. As you wrote, that you're just starting in Python, make sure you know this concept, as doing this stuff without it is... kind of difficult. Then, you most likely don't want to write your own JpG decoder, as there is plenty of them already available and it would be a waste of time. My favorite is ImageIO. You can install it along numpy like:pip install numpy imageioYou can then load an image into a numpy array like so:import numpy as np
from imageio import imread

image=np.asarray(imread("image.jpg"))
print(f"Dymensions of the image are {image.shape}")Here image.shape returns a tuple containing array dymensions i.e. if the array is 3D, it will contain three items, usually x, y and 3.Now, the question is, which of the two first elements is width and whichone height.If I remember right, the firstone was height and secondone width, but I recommend checking it out either in imageio's documentation or by comparing with a viewer, i've worked with few libraries for handling images including ImageIO, PIL and OpenCV, and they use various formats for this.PIL and OpenCV also have various functions for shifting, rotating, zooming and other functions, which you may be interested in. There are plenty of tutorials especially for OpenCV, btw the loading syntax is very similar to thatone of ImageIO.Also note that the sample above decompresses and loads the whole image to memory, as finding its shape is usually not the only thing you want to do. There are also cases when however it's the only required information, and you don't need to load the whole thing in that case. OpenCV has a function to get the dimensions only, so you can use it as well when necessary.Best regardsRastislav

URL: https://forum.audiogames.net/post/585717/#p585717




-- 
Audiogames-reflector mailing list
Audiogames-reflector@sabahattin-gucukoglu.com
https://sabahattin-gucukoglu.com/cgi-bin/mailman/listinfo/audiogames-reflector


Re: python users please save me

2020-11-02 Thread AudioGames . net Forum — Off-topic room : Rastislav Kish via Audiogames-reflector


  


Re: python users please save me

Hi there,@1: hmm, under the term focus something, we usually understand moving the keyboard focus to a particular place in the environment. This is quite rarely done outside your own app, so I guess you probably meaned something else?As for getting width and height of a particular image, well, this is not that simple. An image is a bunch of bytes, which you need to decode first to a matrix of pixels i.e. three dimensional array in order to work with it. As you wrote, that you're just starting in Python, make sure you know this concept, as doing this stuff without it is... kind of difficult. Then, you most likely don't want to write your own JpG decoder, as there is plenty of them already available and it would be a waste of time. My favorite is ImageIO. You can install it along numpy like:pip install numpy imageioYou can then load an image into a numpy array like so:import numpy as np
from imageio import imread

image=np.asarray(imread("image.jpg"))
print(f"Dymensions of the image are {image.shape}")Here image.shape returns a tuple containing array dymensions i.e. if the array is 3D, it will contain three items, usually x, y and 3.Now, the question is, which of the two first elements is width and whichone height.If I remember right, the firstone was height and secondone width, but I recommend checking it out either in imageio's documentation or by comparing with a viewer, i've worked with few libraries for handling images including ImageIO, PIL and OpenCV, and they use various formats for this.PIL and OpenCV also have various functions for shifting, rotating, zooming and other functions, which you may be interested in. There are plenty of tutorials especially for OpenCV, btw the loading syntax is very similar to thatone of ImageIO.Also note that the sample above decompresses and loads the whole image to memory, as finding its shape is usually not the only thing you want to do. There are also cases when however it's the only required information, and you don't need to load the whole thing in that case. OpenCV has a functions to get the dimensions only, so you can use it as well when necessary.Best regardsRastislav

URL: https://forum.audiogames.net/post/585717/#p585717




-- 
Audiogames-reflector mailing list
Audiogames-reflector@sabahattin-gucukoglu.com
https://sabahattin-gucukoglu.com/cgi-bin/mailman/listinfo/audiogames-reflector


Re: python users please save me

2020-11-02 Thread AudioGames . net Forum — Off-topic room : camlorn via Audiogames-reflector


  


Re: python users please save me

You say "focus on".  What does this mean?A lot of people end up using a library called pil in order to extract image metadata, but there might be something built into the standard library for it.  This isn't a hard problem, though.  You should have been able to find solutions via Google.  What have you tried and how has it broken?  Is there a more specific question or problem that's stopping you?

URL: https://forum.audiogames.net/post/585711/#p585711




-- 
Audiogames-reflector mailing list
Audiogames-reflector@sabahattin-gucukoglu.com
https://sabahattin-gucukoglu.com/cgi-bin/mailman/listinfo/audiogames-reflector


Re: python users please save me

2020-11-02 Thread AudioGames . net Forum — Off-topic room : Blue-Eyed Demon via Audiogames-reflector


  


Re: python users please save me

As for what info I need. I need to get the height and width of the image to start out with.

URL: https://forum.audiogames.net/post/585698/#p585698




-- 
Audiogames-reflector mailing list
Audiogames-reflector@sabahattin-gucukoglu.com
https://sabahattin-gucukoglu.com/cgi-bin/mailman/listinfo/audiogames-reflector


Re: python users please save me

2020-11-02 Thread AudioGames . net Forum — Off-topic room : Turkce_Rap via Audiogames-reflector


  


Re: python users please save me

This thread belongs to developper section.Also You should put more details on what are You aiming to do, what kinda info You want to pick etc.

URL: https://forum.audiogames.net/post/585697/#p585697




-- 
Audiogames-reflector mailing list
Audiogames-reflector@sabahattin-gucukoglu.com
https://sabahattin-gucukoglu.com/cgi-bin/mailman/listinfo/audiogames-reflector


Re: python users please save me

2020-11-02 Thread AudioGames . net Forum — Off-topic room : Meatbag via Audiogames-reflector


  


Re: python users please save me

dont know what you exactly need, do you want to navegate to the file from a command line? just, cd , please be a bit more clear

URL: https://forum.audiogames.net/post/585688/#p585688




-- 
Audiogames-reflector mailing list
Audiogames-reflector@sabahattin-gucukoglu.com
https://sabahattin-gucukoglu.com/cgi-bin/mailman/listinfo/audiogames-reflector


Re: Python how to extract archive

2020-10-20 Thread AudioGames . net Forum — Developers room : zywek via Audiogames-reflector


  


Re: Python how to extract archive

@11I want to try this, I mean download the updater from server, run the updater, download all necessary files, then close the app, extract data and run updated app again. But i have a problem with extraction, as mentioned in first post.

URL: https://forum.audiogames.net/post/581715/#p581715




-- 
Audiogames-reflector mailing list
Audiogames-reflector@sabahattin-gucukoglu.com
https://sabahattin-gucukoglu.com/cgi-bin/mailman/listinfo/audiogames-reflector


Re: Python how to extract archive

2020-10-20 Thread AudioGames . net Forum — Developers room : magurp244 via Audiogames-reflector


  


Re: Python how to extract archive

@5Part of the problem may be how your packing the zip file. If you select a folder and compress it into a zip, it will extract all the files into that same folder. You could try entering the folder, and selecting all the files and subdirectories to compress it into whatever zipfile name you like and it should provide better results.Alternatively, you could check out [pyupdater].

URL: https://forum.audiogames.net/post/581644/#p581644




-- 
Audiogames-reflector mailing list
Audiogames-reflector@sabahattin-gucukoglu.com
https://sabahattin-gucukoglu.com/cgi-bin/mailman/listinfo/audiogames-reflector


Re: Python how to extract archive

2020-10-20 Thread AudioGames . net Forum — Developers room : camlorn via Audiogames-reflector


  


Re: Python how to extract archive

@10You should use one of the ones that already exists. I believe there's a couple open source ones by people here, but I don't remember details.I thought you had to use a second executable, but this stack overflow is giving you a procedure that's simpler, if it works: https://stackoverflow.com/questions/719 … in-windowsBut just use someone else's if at all possible.

URL: https://forum.audiogames.net/post/581610/#p581610




-- 
Audiogames-reflector mailing list
Audiogames-reflector@sabahattin-gucukoglu.com
https://sabahattin-gucukoglu.com/cgi-bin/mailman/listinfo/audiogames-reflector


Re: Python how to extract archive

2020-10-20 Thread AudioGames . net Forum — Developers room : zywek via Audiogames-reflector


  


Re: Python how to extract archive

@camlorn yep, I'm trying to build an autoupdater. So probably i should use os.walk over all subdirectories located in archive, ofcourse, after extracting it, then move all subdirectories with it's files inside to the directory, where replacer is located? Nobody never want to add some extra function to ZIpFile library, which can extract all files and directories located in archive without any combinations?

URL: https://forum.audiogames.net/post/581606/#p581606




-- 
Audiogames-reflector mailing list
Audiogames-reflector@sabahattin-gucukoglu.com
https://sabahattin-gucukoglu.com/cgi-bin/mailman/listinfo/audiogames-reflector


Re: Python how to extract archive

2020-10-20 Thread AudioGames . net Forum — Developers room : camlorn via Audiogames-reflector


  


Re: Python how to extract archive

I think the issue is that they're trying to copy the executable over itself. Are you trying to build an autoupdater?If shutil isn't working you can use glob instead and manually move the files yourself. But you cannot copy a running executable on top of itself on Windows.

URL: https://forum.audiogames.net/post/581585/#p581585




-- 
Audiogames-reflector mailing list
Audiogames-reflector@sabahattin-gucukoglu.com
https://sabahattin-gucukoglu.com/cgi-bin/mailman/listinfo/audiogames-reflector


Re: Python how to extract archive

2020-10-20 Thread AudioGames . net Forum — Developers room : Dragonlee via Audiogames-reflector


  


Re: Python how to extract archive

also this kind of question might be better for stack overflow

URL: https://forum.audiogames.net/post/581577/#p581577




-- 
Audiogames-reflector mailing list
Audiogames-reflector@sabahattin-gucukoglu.com
https://sabahattin-gucukoglu.com/cgi-bin/mailman/listinfo/audiogames-reflector


Re: Python how to extract archive

2020-10-20 Thread AudioGames . net Forum — Developers room : zywek via Audiogames-reflector


  


Re: Python how to extract archive

Yep, googled. I can't find anything, maybe because english is not my native language.

URL: https://forum.audiogames.net/post/581535/#p581535




-- 
Audiogames-reflector mailing list
Audiogames-reflector@sabahattin-gucukoglu.com
https://sabahattin-gucukoglu.com/cgi-bin/mailman/listinfo/audiogames-reflector


Re: Python how to extract archive

2020-10-20 Thread AudioGames . net Forum — Developers room : chrisnorman7 via Audiogames-reflector


  


Re: Python how to extract archive

@1Have you googled?

URL: https://forum.audiogames.net/post/581531/#p581531




-- 
Audiogames-reflector mailing list
Audiogames-reflector@sabahattin-gucukoglu.com
https://sabahattin-gucukoglu.com/cgi-bin/mailman/listinfo/audiogames-reflector


Re: Python how to extract archive

2020-10-20 Thread AudioGames . net Forum — Developers room : zywek via Audiogames-reflector


  


Re: Python how to extract archive

I told you, that when i'm using extractall method, and namelist() method, Archive extracts into the subdirectory called archivename.

URL: https://forum.audiogames.net/post/581528/#p581528




-- 
Audiogames-reflector mailing list
Audiogames-reflector@sabahattin-gucukoglu.com
https://sabahattin-gucukoglu.com/cgi-bin/mailman/listinfo/audiogames-reflector


Re: Python how to extract archive

2020-10-20 Thread AudioGames . net Forum — Developers room : magurp244 via Audiogames-reflector


  


Re: Python how to extract archive

Using zipfile, it will extract to the current working directory. If you want to preserve the internal directory structure, you should also include the name list. Example:import zipfile
box = zipfile.ZipFile('archive.zip')
box.extractall(members=box.namelist())

URL: https://forum.audiogames.net/post/581520/#p581520




-- 
Audiogames-reflector mailing list
Audiogames-reflector@sabahattin-gucukoglu.com
https://sabahattin-gucukoglu.com/cgi-bin/mailman/listinfo/audiogames-reflector


Re: Python how to extract archive

2020-10-20 Thread AudioGames . net Forum — Developers room : zywek via Audiogames-reflector


  


Re: Python how to extract archive

But it extracts all content inside parent directory. e.g. Archive called "cat.zip" and zip.extractall extract alll it's content to the cat\ Directory. I need to extract all content with keeping directory structure inside a folder where extract.exe is located.

URL: https://forum.audiogames.net/post/581517/#p581517




-- 
Audiogames-reflector mailing list
Audiogames-reflector@sabahattin-gucukoglu.com
https://sabahattin-gucukoglu.com/cgi-bin/mailman/listinfo/audiogames-reflector


  1   2   3   4   5   6   7   8   9   >