Re: Recommendation for GUI lib?
Thanks everybody for your answers. I really appreciate your answers and I do have a few things to investigate later this summer (after finishing my current "excursion" into Java, and trying to learn KDB/Q). = jem -- https://mail.python.org/mailman/listinfo/python-list
Re: pytz and Python timezones
On 11-6-2016 13:37, Johannes Bauer wrote: > Hi there, > > first off, let me admit that I have a hard time comprehensively wrapping > my head around timezones. Everything around them is much more > complicated than it seems, IMO. They might not seem complicated, but actually they are. Mindbogglingly so: https://www.youtube.com/watch?v=-5wpm-gesOY > pytz.timezone("Europe/Berlin").localize(datetime.datetime(2016,1,1)) > > Gives me the expected result of: > > datetime.datetime(2016, 1, 1, 0, 0, tzinfo= CET+1:00:00 STD>) > > Can someone explain what's going on here and why I end up with the weird > "00:53" timezone? Is this a bug or am I doing things wrong? I ran into the same issue a while ago and have since accepted that "the right way to do it" is indeed not passing a tzinfo into the datetime constructor, but to always use the second form with tz.localize(datetime). I suppose it is a problem (not so much a bug) caused by the way timezones are done internally in pytz and/or datetime but haven't looked into the details. Mostly because of what is said the video I linked above :) Irmen -- https://mail.python.org/mailman/listinfo/python-list
Re: which library has map reduce and how to use it for this case
> > On Friday, June 10, 2016 at 10:04:09 PM UTC+8, Michael Selik wrote: > > You'll need to explain the problem in more detail. Instead of talking > about operators and columns, what is the actual, real-world problem? On Sat, Jun 11, 2016 at 2:21 AM meInvent bbird wrote: > there are six operator, and a logic table initial in b variable > I wasn't asking about the algorithm. I was asking what the task is. If you explain your research question that will help me (and I assume, the rest of the mailing list) understand your problem better. Maybe we can suggest a better algorithm. Give us some context: What data is being input? What is the desired output? What decision will be made based on this calculation? -- https://mail.python.org/mailman/listinfo/python-list
Re: movie from pictures
On 10/06/2016 23:31, alex wright wrote: I find shlex.split to be most useful to make my arguments a list in these cases. On Jun 9, 2016 3:28 PM, "MRAB" wrote: On 2016-06-09 19:58, Peter Otten wrote: Nev wrote: Thank you for your reply. I tried something like this in python code: from subprocess import call call(["ffmpeg -framerate 4/1 -start_number 1 -i C:\\Projects\\data2\\img_%05d.png -c:v libx264 -r 30 -pix_fmt yuv420p C:\\Projects\\data2\\movie.mp4"]) But it did not work. I get FileNotFoundError: [WinError 2] The system cannot find the file specified.. You have to pass the command-line arguments as separate items in the list: call(["ffmpeg", "-framerate", "4/1", "-start_number", "1", "-i", "C:\\Projects\\data2\\img_%05d.png", ... # and so on ]) You should also give it the full path of ffmpeg. On the other hand, in-loop solution would be more preferable since it lets me to use variable names of the images and paths.. -- https://mail.python.org/mailman/listinfo/python-list Why not use the split() method on the string of the command line. Karim -- https://mail.python.org/mailman/listinfo/python-list
Re: i'm a python newbie & wrote my first script, can someone critique it?
Thanks to everyone for your replies. I see my script was as horrific as I feared, but I read all the responses and made a few changes. I'm not 100% sold on not checking types, but took it out, because it made sense that other programmers might want to use some custom type with my functions for their own nefarious purposes. One question I have is, can someone point me to a full listing of all the error types I can trap for? It seems like a Pandora's box, trying to think of all the things that could go wrong, which is why I originally just printed the error #. Is it better to not trap errors, and let the stack trace tell what went wrong? Does it give all the information on the error type etc.? Anyway, for those charitable (or masochistic, or both) enough to critique my code again, here is the updated version: # For Python 3.x # This script creates multiple numbered empty folders # in the desired location. To change the folder names # or location, edit function get_default_options. ### # REFERENCE MODULES ### import datetime import os import errno import sys ### # SUPPORT FUNCTIONS ### # returns: dictionary containing options for this script def get_default_options(): dict = { "s_for_python_version": "3", "s_folder_path_template": "C:/temp/test/MP3 Disk {count:03}", "i_from_count": 3, "i_to_count": 7, } return dict # returns: string containing exact version #, eg "3.5.1" # TODO: update to use # sys.version_info[:3] by itself gives a three-element tuple. # Probably easier to use than thestring version. # A couple alternatives: # sys.version[:5] or perhaps a bit safer -- sys.version.split()[0] both directly give you the # string version. (Note this uses version not version_info.) def get_exact_python_version(): s_version = ".".join(map(str, sys.version_info[:3])) s_version = s_version.strip() return s_version # returns: string containing general version #, eg "3" # TODO: return to the left of first "." def get_general_python_version(): s_version = get_exact_python_version() return s_version[0] # checks python version # if it's wrong then gracefully exit before it blows up # (damn, python 2.x still complains with syntax errors!!) # # receives: # s_right_version (string) = python version # to check against # # TODO: more granular check, eg if version >= 3.5.0 def exit_if_wrong_python_version(s_right_version): s_current_version = get_general_python_version() if (s_current_version != s_right_version): print( "Wrong Python version ({}), " "this script should be run using " "Python {}.x, Exiting..." "".format(s_current_version, s_right_version)) sys.exit() # SAME AS os._exit(0) # assists in script readability # returns: string containing name of the current script def get_script_filename(): return sys.argv[0] # returns: string containing the current date/time in the format eg 2016-05-22 13:01:55 def get_timestamp(): return datetime.datetime.strftime(datetime.datetime.now(), '%Y-%m-%d %H:%M:%S') # creates a folder at the specified path # receives: # s_path (string) = full path of folder to create def create_folder(s_path): try: os.makedirs(s_path, exist_ok=True) except (FileExistsError, IsADirectoryError) as e: print("FileExistsError IN makedirs") raise return False except OSError as exception: print("ERROR #" + str(exception.errno) + "IN makedirs") raise return False print("" + get_timestamp() + " " + "Created folder: " + s_path + "") # creates multiple numbered folders named per template # receives: # s_folder_path_template (string) = template containing full path of folder to create, # where "{count:n}" is replaced by the folder count (n digits) # i_from_count (int) = number to begin counting at # i_to_count (int) = number to stop counting after # # returns: count of folders created, 0 if error or none def create_folders( s_folder_path_template:str="", i_from_count:int=1, i_to_count:int=0 ): i_count=0 for i_loop in range(i_from_count, i_to_count + 1): create_folder(s_folder_path_template.format(count=i_loop)) i_count += 1 return i_count ### # MAIN LOGIC ### def main(): options_dict = get_default_options() exit_if_wrong_python_version(options_dict["s_for_python_version"])
Re: i'm a python newbie & wrote my first script, can someone critique it?
For those who don't want to have to wade through comments, here is a version without so many comments: # For Python 3.x # This script creates multiple numbered empty folders # in the desired location. To change the folder names # or location, edit function get_default_options. import datetime import os import errno import sys ### # EDIT VALUES HERE TO CUSTOMIZE THE OUTPUT def get_default_options(): dict = { "s_for_python_version": "3", "s_folder_path_template": "C:/temp/test/MP3 Disk {count:03}", "i_from_count": 3, "i_to_count": 7, } return dict ### def get_exact_python_version(): s_version = ".".join(map(str, sys.version_info[:3])) s_version = s_version.strip() return s_version def get_general_python_version(): s_version = get_exact_python_version() return s_version[0] def exit_if_wrong_python_version(s_right_version): s_current_version = get_general_python_version() if (s_current_version != s_right_version): print( "Wrong Python version ({}), " "this script should be run using " "Python {}.x, Exiting..." "".format(s_current_version, s_right_version)) sys.exit() def get_script_filename(): return sys.argv[0] def get_timestamp(): return datetime.datetime.strftime(datetime.datetime.now(), '%Y-%m-%d %H:%M:%S') def create_folder(s_path): try: os.makedirs(s_path, exist_ok=True) except (FileExistsError, IsADirectoryError) as e: print("FileExistsError IN makedirs") raise return False except OSError as exception: print("ERROR #" + str(exception.errno) + "IN makedirs") raise return False print("" + get_timestamp() + " " + "Created folder: " + s_path + "") def create_folders( s_folder_path_template:str="", i_from_count:int=1, i_to_count:int=0 ): i_count=0 for i_loop in range(i_from_count, i_to_count + 1): create_folder(s_folder_path_template.format(count=i_loop)) i_count += 1 return i_count def main(): options_dict = get_default_options() exit_if_wrong_python_version(options_dict["s_for_python_version"]) print("+++") print("" + get_timestamp() + " " + get_script_filename() + " started.") i_total_created = create_folders( options_dict["s_folder_path_template"], options_dict["i_from_count"], options_dict["i_to_count"]) print("" + get_timestamp() + " " + str(i_total_created) + " folders created.") print("" + get_timestamp() + " " + get_script_filename() + " finished.") if __name__ == '__main__': main() -- https://mail.python.org/mailman/listinfo/python-list
Re: i'm a python newbie & wrote my first script, can someone critique it?
Look into docstrings. They will make your code much more readable to a Python reader. On Sat, Jun 11, 2016 at 2:16 PM mad scientist jr wrote: > For those who don't want to have to wade through comments, here is a > version without so many comments: > > # For Python 3.x > # This script creates multiple numbered empty folders > # in the desired location. To change the folder names > # or location, edit function get_default_options. > > import datetime > import os > import errno > import sys > > > ### > # EDIT VALUES HERE TO CUSTOMIZE THE OUTPUT > def get_default_options(): > dict = { > "s_for_python_version": "3", > "s_folder_path_template": "C:/temp/test/MP3 Disk {count:03}", > "i_from_count": 3, > "i_to_count": 7, > } > return dict > > ### > > def get_exact_python_version(): > s_version = ".".join(map(str, sys.version_info[:3])) > s_version = s_version.strip() > return s_version > > def get_general_python_version(): > s_version = get_exact_python_version() > return s_version[0] > > def exit_if_wrong_python_version(s_right_version): > s_current_version = get_general_python_version() > if (s_current_version != s_right_version): > print( > "Wrong Python version ({}), " > "this script should be run using " > "Python {}.x, Exiting..." > "".format(s_current_version, s_right_version)) > sys.exit() > > def get_script_filename(): > return sys.argv[0] > > def get_timestamp(): > return datetime.datetime.strftime(datetime.datetime.now(), '%Y-%m-%d > %H:%M:%S') > > def create_folder(s_path): > try: > os.makedirs(s_path, exist_ok=True) > except (FileExistsError, IsADirectoryError) as e: > print("FileExistsError IN makedirs") > raise > return False > except OSError as exception: > print("ERROR #" + str(exception.errno) + "IN makedirs") > raise > return False > print("" + get_timestamp() + " " + "Created folder: " + s_path + "") > > def create_folders( > s_folder_path_template:str="", > i_from_count:int=1, > i_to_count:int=0 > ): > i_count=0 > for i_loop in range(i_from_count, i_to_count + 1): > create_folder(s_folder_path_template.format(count=i_loop)) > i_count += 1 > > return i_count > > def main(): > options_dict = get_default_options() > exit_if_wrong_python_version(options_dict["s_for_python_version"]) > > > print("+++") > print("" + get_timestamp() + " " + get_script_filename() + " started.") > > i_total_created = create_folders( > options_dict["s_folder_path_template"], > options_dict["i_from_count"], > options_dict["i_to_count"]) > > print("" + get_timestamp() + " " + str(i_total_created) + " folders > created.") > print("" + get_timestamp() + " " + get_script_filename() + " > finished.") > > if __name__ == '__main__': > main() > -- > https://mail.python.org/mailman/listinfo/python-list > -- https://mail.python.org/mailman/listinfo/python-list
Re: i'm a python newbie & wrote my first script, can someone critique it?
On 2016-06-11 18:59, mad scientist jr wrote: Thanks to everyone for your replies. I see my script was as horrific as I feared, but I read all the responses and made a few changes. I'm not 100% sold on not checking types, but took it out, because it made sense that other programmers might want to use some custom type with my functions for their own nefarious purposes. One question I have is, can someone point me to a full listing of all the error types I can trap for? It seems like a Pandora's box, trying to think of all the things that could go wrong, which is why I originally just printed the error #. Is it better to not trap errors, and let the stack trace tell what went wrong? Does it give all the information on the error type etc.? Catch those exceptions that you can do something about. If, say, it complains that it can't create a folder, you'll need to decide what you should do about it. You might decide that the best way to handle it is to report it to the user and then continue, or report it to the user and then stop. Do whatever makes most sense. If it complains about something unexpected, it's probably best to report it and then just stop, i.e. let unknown exceptions propagate. As Python is an extensible language, there'll never be a complete list of exceptions; just catch what you're prepared to handle. Anyway, for those charitable (or masochistic, or both) enough to critique my code again, here is the updated version: # For Python 3.x # This script creates multiple numbered empty folders # in the desired location. To change the folder names # or location, edit function get_default_options. Drop the next 3 comment lines. They add visual clutter, and no useful info. ### # REFERENCE MODULES ### import datetime import os import errno import sys ### # SUPPORT FUNCTIONS ### # returns: dictionary containing options for this script def get_default_options(): dict = { "s_for_python_version": "3", "s_folder_path_template": "C:/temp/test/MP3 Disk {count:03}", "i_from_count": 3, "i_to_count": 7, } return dict # returns: string containing exact version #, eg "3.5.1" # TODO: update to use # sys.version_info[:3] by itself gives a three-element tuple. # Probably easier to use than thestring version. # A couple alternatives: # sys.version[:5] or perhaps a bit safer -- sys.version.split()[0] both directly give you the # string version. (Note this uses version not version_info.) def get_exact_python_version(): s_version = ".".join(map(str, sys.version_info[:3])) The string produced by the preceding line won't start or end with any whitespace, so the next line is pointless. s_version = s_version.strip() return s_version # returns: string containing general version #, eg "3" # TODO: return to the left of first "." def get_general_python_version(): It's called the "major" version. You're going the long way round! The simplest way to get it is directly from sys.version_info. s_version = get_exact_python_version() return s_version[0] # checks python version # if it's wrong then gracefully exit before it blows up # (damn, python 2.x still complains with syntax errors!!) # # receives: # s_right_version (string) = python version # to check against # # TODO: more granular check, eg if version >= 3.5.0 def exit_if_wrong_python_version(s_right_version): s_current_version = get_general_python_version() The conditions of 'if' statements don't need to be wrapped in (...). if (s_current_version != s_right_version): print( "Wrong Python version ({}), " "this script should be run using " "Python {}.x, Exiting..." "".format(s_current_version, s_right_version)) sys.exit() # SAME AS os._exit(0) # assists in script readability # returns: string containing name of the current script def get_script_filename(): return sys.argv[0] # returns: string containing the current date/time in the format eg 2016-05-22 13:01:55 def get_timestamp(): > return datetime.datetime.strftime(datetime.datetime.now(), '%Y-%m-%d %H:%M:%S') datetime instances have a .strftime method, so you can shorten that to: return datetime.datetime.now().strftime('%Y-%m-%d %H:%M:%S') # creates a folder at the specified path # receives: # s_path (string) = full path of folder to create def create_folder(s_path): try: os.makedirs(s_path, exist_ok=True) except (FileExistsError, IsADirectoryError) as e: There's little point in catching an exception, printing a message, and then re-raising the exception. The exception's traceback
pytz and Python timezones
Hi there, first off, let me admit that I have a hard time comprehensively wrapping my head around timezones. Everything around them is much more complicated than it seems, IMO. That said, I'm trying to do things the "right" way and stumbled upon some weird issue which I can't explain. I'm unsure what is happening here. I try to create a localized timestamp in the easiest possible way. So, intuitively, I did this: datetime.datetime(2016,1,1,0,0,0,tzinfo=pytz.timezone("Europe/Berlin")) Which gives me: datetime.datetime(2016, 1, 1, 0, 0, tzinfo=) Uh... what? This here: pytz.timezone("Europe/Berlin").localize(datetime.datetime(2016,1,1)) Gives me the expected result of: datetime.datetime(2016, 1, 1, 0, 0, tzinfo=) Can someone explain what's going on here and why I end up with the weird "00:53" timezone? Is this a bug or am I doing things wrong? Thanks, Cheers, Johannes -- >> Wo hattest Du das Beben nochmal GENAU vorhergesagt? > Zumindest nicht öffentlich! Ah, der neueste und bis heute genialste Streich unsere großen Kosmologen: Die Geheim-Vorhersage. - Karl Kaos über Rüdiger Thomas in dsa -- https://mail.python.org/mailman/listinfo/python-list
the global keyword:
Hi to all. I have the following file named Solver.py: * from Test import some_function, my_print from Test import test_var some_function() my_print() print(test_var) * and I have the following Test.py: * test_var = 5 def some_function(): global test_var test_var = 44 print("f {0}".format(test_var)) def my_print(): print(test_var) * Would you believe it that when I run Solver.py I get the following output: f 44 44 5 So my question is, how the heck is it possible that I get 5 as the last value printed? the global test_var (global to Test.py) I set to 44 when I ran some_function()??? does anyone have a clue they could throw my way? Much thanks -- https://mail.python.org/mailman/listinfo/python-list
Re: the global keyword:
On Sat, Jun 11, 2016, at 19:44, Marcin Rak wrote: > So my question is, how the heck is it possible that I get 5 as the last > value printed? the global test_var (global to Test.py) I set to 44 when I > ran some_function()??? does anyone have a clue they could throw my way? Importing a variable from a module copies its value into your own module's variable. Updates to the source module's variable will not be reflected in your module. -- https://mail.python.org/mailman/listinfo/python-list
Re: the global keyword:
On 2016-06-12 00:50, Random832 wrote: On Sat, Jun 11, 2016, at 19:44, Marcin Rak wrote: So my question is, how the heck is it possible that I get 5 as the last value printed? the global test_var (global to Test.py) I set to 44 when I ran some_function()??? does anyone have a clue they could throw my way? Importing a variable from a module copies its value into your own module's variable. Updates to the source module's variable will not be reflected in your module. Not true. Importing doesn't copy the value. Importing a name creates a new name in the local scope that refers to the same object that the imported name referred to. -- https://mail.python.org/mailman/listinfo/python-list
Re: the global keyword:
On Saturday, 11 June 2016 18:51:11 UTC-5, Random832 wrote: > On Sat, Jun 11, 2016, at 19:44, Marcin Rak wrote: > > So my question is, how the heck is it possible that I get 5 as the last > > value printed? the global test_var (global to Test.py) I set to 44 when I > > ran some_function()??? does anyone have a clue they could throw my way? > > Importing a variable from a module copies its value into your own > module's variable. Updates to the source module's variable will not be > reflected in your module. As I suspected. Nice to have it confirmed. So it copies any imported variable that is of simple type (string, int, float...) What about variables that are user defined classes? Are they referenced or copied? -- https://mail.python.org/mailman/listinfo/python-list
Re: the global keyword:
On Saturday, 11 June 2016 19:09:29 UTC-5, MRAB wrote: > On 2016-06-12 00:50, Random832 wrote: > > On Sat, Jun 11, 2016, at 19:44, Marcin Rak wrote: > >> So my question is, how the heck is it possible that I get 5 as the last > >> value printed? the global test_var (global to Test.py) I set to 44 when I > >> ran some_function()??? does anyone have a clue they could throw my way? > > > > Importing a variable from a module copies its value into your own > > module's variable. Updates to the source module's variable will not be > > reflected in your module. > > > Not true. Importing doesn't copy the value. > > Importing a name creates a new name in the local scope that refers to > the same object that the imported name referred to. If that's the case, how is it that I get 5 for test_var??? -- https://mail.python.org/mailman/listinfo/python-list
Re: the global keyword:
On Sat, Jun 11, 2016, at 20:09, MRAB wrote: > Not true. Importing doesn't copy the value. > > Importing a name creates a new name in the local scope that refers to > the same object that the imported name referred to. Yes, the value of a variable is a reference to an object. Can we not have another round of this right now? -- https://mail.python.org/mailman/listinfo/python-list
Re: the global keyword:
On Sat, Jun 11, 2016, at 20:12, Marcin Rak wrote: > What about variables that are user defined classes? Are they referenced > or copied? It will reference the same object, but if the variable is reassigned in the original module it will still not update the imported variable. -- https://mail.python.org/mailman/listinfo/python-list
how to record path in well format and easy to read?
https://gist.github.com/hoyeunglee/3fea29ed4aadb5dbc11c41f9a36070dc i discover my code can not record the path because i do recursive call at the end of function however, i want to do full combination at the end of function before calling recursive call, for seeing the result path, choose call recursive call in each else statement which means when it is not found yet, it will continue recursive call this time, i use binary for simple case, but final result show only 4 records, first two do not have ok, third and fourth can not see ok, it become [...] how to show this [...] ? is there any method to record the path in well format and easy to read ? because in 3 valued case, i do not know name of operators, i can only record the full column -- https://mail.python.org/mailman/listinfo/python-list
Re: the global keyword:
On Sun, 12 Jun 2016 11:26 am, Random832 wrote: > On Sat, Jun 11, 2016, at 20:09, MRAB wrote: >> Not true. Importing doesn't copy the value. >> >> Importing a name creates a new name in the local scope that refers to >> the same object that the imported name referred to. MRAB is correct here. > Yes, the value of a variable is a reference to an object. Can we not > have another round of this right now? Sure, if you stop spreading misinformation about variables in Python and cease the insanity of claiming that the value of a variable is not the value you assign to it, but some invisible, unreachable "reference". x = 999 The value of x is 999, not some invisible reference. x = [] The value of x is an empty list, not some invisible reference. -- Steven -- https://mail.python.org/mailman/listinfo/python-list
Re: the global keyword:
On Saturday, June 11, 2016 at 8:13:50 PM UTC-4, Marcin Rak wrote: > On Saturday, 11 June 2016 19:09:29 UTC-5, MRAB wrote: > > On 2016-06-12 00:50, Random832 wrote: > > > On Sat, Jun 11, 2016, at 19:44, Marcin Rak wrote: > > >> So my question is, how the heck is it possible that I get 5 as the last > > >> value printed? the global test_var (global to Test.py) I set to 44 when I > > >> ran some_function()??? does anyone have a clue they could throw my way? > > > > > > Importing a variable from a module copies its value into your own > > > module's variable. Updates to the source module's variable will not be > > > reflected in your module. > > > > > Not true. Importing doesn't copy the value. > > > > Importing a name creates a new name in the local scope that refers to > > the same object that the imported name referred to. > > If that's the case, how is it that I get 5 for test_var??? Assignment makes a name refer to a value: x = 12# Now x refers to 12 More than one name can refer to a value: x = 12 y = x # Now x and y both refer to 12 Re-assigning one name doesn't affect other names referring to the old value: x = 12 y = x x = 24# Now x refers to 24, and y still refers to 12 Each module has its own globals (this makes the name "global" a bit of a misnomer. Importing a name from a module is an assignment statement in disguise, and each module has its own names: # Test.py test_var = 5 # Solver.py from Test import test_var # This import is effectively: #Solver.test_var = Test.test_var # # Now Test.test_var and Solver.test_var both refer to 5 Reassigning one name doesn't affect other names referring to the old value: # Test.py global test_var test_var = 44 # Test.test_var refers to 44 # Solver.test_var still refers to 5 After all of your code is run, the test_var in Solver.py is still 5. A longer explanation is at http://bit.ly/pynames1 that may help. --Ned. -- https://mail.python.org/mailman/listinfo/python-list
Re: the global keyword:
On Saturday, June 11, 2016 at 11:38:33 PM UTC-4, Steven D'Aprano wrote: > On Sun, 12 Jun 2016 11:26 am, Random832 wrote: > > > On Sat, Jun 11, 2016, at 20:09, MRAB wrote: > >> Not true. Importing doesn't copy the value. > >> > >> Importing a name creates a new name in the local scope that refers to > >> the same object that the imported name referred to. > > MRAB is correct here. > > > > Yes, the value of a variable is a reference to an object. Can we not > > have another round of this right now? > > Sure, if you stop spreading misinformation about variables in Python and > cease the insanity of claiming that the value of a variable is not the > value you assign to it, but some invisible, unreachable "reference". > > x = 999 > > The value of x is 999, not some invisible reference. > > x = [] > > The value of x is an empty list, not some invisible reference. We just went through all this. It's clear to me that there are different ways of looking at these underlying mechanisms, and different people find truth in different ways of describing them. The virtual world we live in is complex because of the differing levels of abstraction that are possible. Some of this disagreement is really a matter of choosing different abstractions to focus on. Most importantly, it's clear to me that we aren't going to come to some simple consensus, certainly not by throwing around words like "insanity." Perhaps at least in this thread we can limit ourselves to addressing the OP and their question directly, rather than fighting with each other over which answer is correct? --Ned. -- https://mail.python.org/mailman/listinfo/python-list
Re: how to record path in well format and easy to read?
https://gist.github.com/hoyeunglee/350ac2dd496f7c1c95a428f847e6f2b1 then can not run deep 3 in python sagecloud >>> mresult = DFS(b, 3, 3, mylist, path) ('deep=', 3) ({'11': 1, '10': 1, '00': 0, '01': 1}, {'11': 1, '10': 0, '00': 0, '01': 0}) ({'11': 1, '10': 1, '00': 0, '01': 1}, {'11': 1, '10': 0, '00': 1, '01': 1}) ({'11': 1, '10': 0, '00': 0, '01': 0}, {'11': 1, '10': 0, '00': 1, '01': 1}) initlist= 18 path= 18 here is caseA ('deep=', 2) ({'11': 1, '10': 1, '00': 0, '01': 1}, {'11': 1, '10': 0, '00': 0, '01': 0}) ) ... retu({'11': 1, '10': 1, '00': 0, '01': 1}, {'11': 1, '10': 0, '00': 1, '01': 1}) ({'11': 1, '10': 0, '00': 0, '01': 0}, {'11': 1, '10': 0, '00': 1, '01': 1}) initlist= 790 path= 936 ('deep=', 1) ({'11': 1, '10': 1, '00': 0, '01': 1}, {'11': 1, '10': 0, '00': 0, '01': 0}) ({'11': 1, '10': 1, '00': 0, '01': 1}, {'11': 1, '10': 0, '00': 1, '01': 1}) ({'11': 1, '10': 0, '00': 0, '01': 0}, {'11': 1, '10': 0, '00': 1, '01': 1}) initlist= 1549682 path= 1870866 Killed On Sunday, June 12, 2016 at 9:38:51 AM UTC+8, meInvent bbird wrote: > https://gist.github.com/hoyeunglee/3fea29ed4aadb5dbc11c41f9a36070dc > > i discover my code can not record the path > > because i do recursive call at the end of function > however, i want to do full combination at the end of function before calling > recursive call, > > for seeing the result path, choose call recursive call in each else statement > which means when it is not found yet, it will continue recursive call > > this time, i use binary for simple case, > > but final result show only 4 records, first two do not have ok, > > third and fourth can not see ok, it become [...] > > how to show this [...] ? > > is there any method to record the path in well format and easy to read ? > > because in 3 valued case, i do not know name of operators, i can only record > the full column -- https://mail.python.org/mailman/listinfo/python-list
Re: how to record path in well format and easy to read?
i forget why i do combination of 2 operators now i change not to use combination of 2 operators https://gist.github.com/hoyeunglee/58df4c41a63a2f37e153cbdbc03c16bf i run mresult = DFS(b, 2, 2, mylist, path) it do not have deep 2 and deep 1 in the path they only separated in the list however, i had already assigned in this format path.append([caseA,path2]) before return path, what's wrong with it? On Sunday, June 12, 2016 at 12:55:17 PM UTC+8, meInvent bbird wrote: > https://gist.github.com/hoyeunglee/350ac2dd496f7c1c95a428f847e6f2b1 > > then can not run deep 3 in python sagecloud > > >>> mresult = DFS(b, 3, 3, mylist, path) > ('deep=', 3) > ({'11': 1, '10': 1, '00': 0, '01': 1}, {'11': 1, '10': 0, '00': 0, '01': 0}) > ({'11': 1, '10': 1, '00': 0, '01': 1}, {'11': 1, '10': 0, '00': 1, '01': 1}) > ({'11': 1, '10': 0, '00': 0, '01': 0}, {'11': 1, '10': 0, '00': 1, '01': 1}) > initlist= > 18 > path= > 18 > here is caseA > ('deep=', 2) > ({'11': 1, '10': 1, '00': 0, '01': 1}, {'11': 1, '10': 0, '00': 0, '01': 0}) > ) > ... retu({'11': 1, '10': 1, '00': 0, '01': 1}, {'11': 1, '10': 0, '00': > 1, '01': 1}) > ({'11': 1, '10': 0, '00': 0, '01': 0}, {'11': 1, '10': 0, '00': 1, '01': 1}) > initlist= > 790 > path= > 936 > ('deep=', 1) > ({'11': 1, '10': 1, '00': 0, '01': 1}, {'11': 1, '10': 0, '00': 0, '01': 0}) > ({'11': 1, '10': 1, '00': 0, '01': 1}, {'11': 1, '10': 0, '00': 1, '01': 1}) > ({'11': 1, '10': 0, '00': 0, '01': 0}, {'11': 1, '10': 0, '00': 1, '01': 1}) > initlist= > 1549682 > path= > 1870866 > Killed > > > On Sunday, June 12, 2016 at 9:38:51 AM UTC+8, meInvent bbird wrote: > > https://gist.github.com/hoyeunglee/3fea29ed4aadb5dbc11c41f9a36070dc > > > > i discover my code can not record the path > > > > because i do recursive call at the end of function > > however, i want to do full combination at the end of function before calling > > recursive call, > > > > for seeing the result path, choose call recursive call in each else > > statement > > which means when it is not found yet, it will continue recursive call > > > > this time, i use binary for simple case, > > > > but final result show only 4 records, first two do not have ok, > > > > third and fourth can not see ok, it become [...] > > > > how to show this [...] ? > > > > is there any method to record the path in well format and easy to read ? > > > > because in 3 valued case, i do not know name of operators, i can only > > record the full column -- https://mail.python.org/mailman/listinfo/python-list