Re: Template language for random string generation
On Friday, 8 August 2014 23:03:18 UTC+1, Ian wrote: On Fri, Aug 8, 2014 at 3:01 AM, Paul Wolf paulwolf...@gmail.com wrote: * Uses SystemRandom class (if available, or falls back to Random) A simple improvement would be to also allow the user to pass in a Random object That is not a bad idea. I'll create an issue for it. It is a design goal to use the standard library within the implementation so users have a guarantee about exactly how the data is generated. But your suggestion is not inconsistent with that. Have you given any thought to adding a validation mode, where the user provides a template and a string and wants to know if the string matches the template? Isn't that what regular expressions are? Or do you have a clarifying use case? strgen is provided as the converse of regular expressions. -- https://mail.python.org/mailman/listinfo/python-list
Re: more simple to split the string?
elearn wrote: str='(\\HasNoChildren \\Junk) / [Gmail]/V4NXPpCuTvY-' x=str.split(' ') [i.replace('','') for i in x] ['(\\HasNoChildren \\Junk)', '/', '[Gmail]/V4NXPpCuTvY-'] x.strip( ) will create four parts. is there more simple to do that ? Here's another way: s = '(\\HasNoChildren \\Junk) / [Gmail]/V4NXPpCuTvY-' s.replace((, '').replace(), '').split('')[1::2] ['\\HasNoChildren \\Junk', '/', '[Gmail]/V4NXPpCuTvY-'] But you should rather worry about correctness. Can '' occur inside the parentheses and vice versa? Is there a way to escape ''? Can parentheses be nested? Etc. The example is not sufficient to specify the problem. -- https://mail.python.org/mailman/listinfo/python-list
Re: Template language for random string generation
On Sat, Aug 9, 2014 at 12:52 AM, Paul Wolf paulwolf...@gmail.com wrote: On Friday, 8 August 2014 23:03:18 UTC+1, Ian wrote: Have you given any thought to adding a validation mode, where the user provides a template and a string and wants to know if the string matches the template? Isn't that what regular expressions are? Or do you have a clarifying use case? strgen is provided as the converse of regular expressions. The syntax is not equivalent though. You can't take a strgen template, pass it into the re module, and just expect it to work. Also, I'm not sure how best to go about writing a regular expression for, e.g. 12 or more letters, digits, and punctuation, including at least one each of uppercase letter, lowercase letter, digit, and punctuation. I'm fairly certain that language is regular, but actually matching it with a regular expression would be a nightmare. -- https://mail.python.org/mailman/listinfo/python-list
Re: Template language for random string generation
On Sat, Aug 9, 2014 at 1:49 AM, Ian Kelly ian.g.ke...@gmail.com wrote: On Sat, Aug 9, 2014 at 12:52 AM, Paul Wolf paulwolf...@gmail.com wrote: On Friday, 8 August 2014 23:03:18 UTC+1, Ian wrote: Have you given any thought to adding a validation mode, where the user provides a template and a string and wants to know if the string matches the template? Isn't that what regular expressions are? Or do you have a clarifying use case? strgen is provided as the converse of regular expressions. The syntax is not equivalent though. You can't take a strgen template, pass it into the re module, and just expect it to work. Also, I'm not sure how best to go about writing a regular expression for, e.g. 12 or more letters, digits, and punctuation, including at least one each of uppercase letter, lowercase letter, digit, and punctuation. I'm fairly certain that language is regular, but actually matching it with a regular expression would be a nightmare. To clarify further, validating that *without* using a regular expression is not too terribly difficult, but the value that I see in validating it with a strgen is that one could then be sure that one's string generation and validation were equivalent. In contrast, if you have a strgen for generation and a series of string manipulations for validation, then it's hard to be certain there aren't any differences. -- https://mail.python.org/mailman/listinfo/python-list
Re: how to write file into my android phone?
On Sat, Aug 9, 2014 at 7:56 PM, luofeiyu elearn2...@gmail.com wrote: When i input usb line with my android phone into the pc , there are two disks j: and k: (type :removable disk) displayed in win7. i can get my android phone bluetooth mac address . import bluetooth nearby_devices = bluetooth.discover_devices(lookup_names = True) for addr, phoneName in nearby_devices: print(addr) it is 6C:8B:2F:CE:5B:59 Now how can i write a file into the disk j: of my android phone(bluetooth mac is 6C:8B:2F:CE:5B:59 )? -- https://mail.python.org/mailman/listinfo/python-list You mixed up two very different interfaces. Bluetooth and USB are completely separate. If you want to write a file to the USB drive, you can just open a file, using the regular open() function (specify a path somewhere benath J:\): https://docs.python.org/2/tutorial/inputoutput.html#reading-and-writing-files However, if you want to do it via Bluetooth for some reason, you need to find a library that does OBEX — Google hints at http://lightblue.sourceforge.net/ . -- Chris “Kwpolska” Warrick http://chriswarrick.com/ PGP: 5EAAEA16 stop html mail | always bottom-post | only UTF-8 makes sense -- https://mail.python.org/mailman/listinfo/python-list
attendance system in pybluez
I want to write a program to help my teacher to take attendence. There are 300 students in a big room,everyone has android phone. I have matched them with my pc in win7 . when all of them seated on the classroom, import bluetooth nearby_devices = bluetooth.discover_devices(lookup_names = True) print(found %d devices % len(nearby_devices)) The function can discover all of them ? 300 bluetooth mac address? can i search for a given bluetooth mac? blue_mac=[] (i can write it in a list in advance,it is not blank,full of strings) for add in blue_mac: print(bluetooth.seacrh_given_mac) #result is true or false Is there a function to run? -- https://mail.python.org/mailman/listinfo/python-list
The right way to use config files
Folks, I am not a computer scientist (just a scientist) and I'd like to ask your opinion about a design problem I have. It's not that I can't get my program to work, but rather that I have trouble to find an elegant solution to the problem of passing information to my program's elements. I have trouble to be clear in my request so my apologies for the long text... The tool I am developing is a classical data-analysis workflow. Ideally, all the program's configurations are located in a single .cfg file which I parse with ConfigObg. The file contains I/O informations (path_to_input, path_to_output) as well as internal options (use_this_function, dont_use_this_one, function1_paramx = y), etc... Currently, my program is a super-object which is initialized once and work schematically as follows: main(): obj = init_superobj(config file) obj.preprocess() obj.process() obj.write() the superobj init routine parses the config files and reads the input data. and a processing step can be, for example: def process(): if self.configfile.as_bool('do_funcion1'): params = config.parse_function1_params() call_function1(self.data, params) if self.configfile.as_bool('do_funcion2'): params = config.parse_function2_params() call_function2(self.data2, params) The functions themselves do not know about the superobject or about the configfile. They are standalone functions which take data and parameters as input and produce output with it. I thought that the standalone functions will be clearer and easier to maintain, since they do not rely on some external data structure such as the configobj or anything. BUT, my problem is that several options really are universal options to the program, such as the output directory for example. This information (where to write their results) is given to most of the functions as parameter. So I had the idea to define a super-object which parses the config file and input data and is given as a single parameter to the processing functions, and the functions take the information they need from it. This is tempting because there is no need for refactoring when I decide to change something in the config, but I am afraid that the program may become unmaintainable by someone else than myself. Another possibility would be at least to give all the functions access to the configfile. To get to the point: is it good practice to give all elements of a program access to the configfile and if yes, how is it done properly? I hope at least someone will understand what I mean ;-) Cheers and thanks, Fabien -- https://mail.python.org/mailman/listinfo/python-list
Re: attendance system in pybluez
luofeiyu wrote: I want to write a program to help my teacher to take attendence. There are 300 students in a big room,everyone has android phone. If your students allow strange devices to connect to their android phones, then they won't remain their android phones for very long. They will belong to whatever hacker takes control of them first. http://blog.kaspersky.com/bluetooth-security/ I have matched them with my pc in win7 . when all of them seated on the classroom, import bluetooth nearby_devices = bluetooth.discover_devices(lookup_names = True) print(found %d devices % len(nearby_devices)) The function can discover all of them ? 300 bluetooth mac address? You will have to ask the author of the bluetooth module. Where did you find it? Does it come with documentation? Did you read it? -- Steven -- https://mail.python.org/mailman/listinfo/python-list
Re: attendance system in pybluez
in the http://homepages.ius.edu/rwisman/C490/html/PythonandBluetooth.htm *Discovery* The address and name of enabled devices within range can be discovered by other Bluetooth devices. Discovery can take some time to complete, given that radio communications is unreliable. The following displays address and name of all enabled devices nearby. from bluetooth import * print performing inquiry... *nearby_devices = discover_devices(lookup_names = True)* print found %d devices % len(nearby_devices) for name, addr in nearby_devices: print %s - %s % (addr, name) performing inquiry... found 2 devices Ray's Nokia - 00:12:D2:5A:BD:E4 Ray's MacBook - 00:1E:C2:93:DA:6F On 8/9/2014 4:53 AM, Steven D'Aprano wrote: luofeiyu wrote: I want to write a program to help my teacher to take attendence. There are 300 students in a big room,everyone has android phone. If your students allow strange devices to connect to their android phones, then they won't remain their android phones for very long. They will belong to whatever hacker takes control of them first. http://blog.kaspersky.com/bluetooth-security/ I have matched them with my pc in win7 . when all of them seated on the classroom, import bluetooth nearby_devices = bluetooth.discover_devices(lookup_names = True) print(found %d devices % len(nearby_devices)) The function can discover all of them ? 300 bluetooth mac address? You will have to ask the author of the bluetooth module. Where did you find it? Does it come with documentation? Did you read it? -- https://mail.python.org/mailman/listinfo/python-list
Re: how to get the ordinal number in list
On 09.08.2014 19:22, luofeiyu wrote: x=[x1,x3,x7,x5] y=x3 how can i get the ordinal number by some codes? for id ,value in enumerate(x): if y==value : print(id) Is more simple way to do that? print(x.index(y)) HTH, 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 hidbv3$om2$1...@speranza.aioe.org -- https://mail.python.org/mailman/listinfo/python-list
Re: how to get the ordinal number in list
On 8/9/14 1:35 PM, luofeiyu wrote: x=[x1,x3,x7,x5,x3] x.index(x3) 1 if i want the result of 1 and 4 ? If you tell us more about your problem, and what you will do with the 1 and 4, there might be an even better way to do what you want. On 8/8/2014 7:25 PM, Larry Martell wrote: On Sat, Aug 9, 2014 at 1:22 PM, luofeiyu elearn2...@gmail.com wrote: x=[x1,x3,x7,x5] y=x3 how can i get the ordinal number by some codes? for id ,value in enumerate(x): if y==value : print(id) Is more simple way to do that? print x.index(y) -- Ned Batchelder, http://nedbatchelder.com -- https://mail.python.org/mailman/listinfo/python-list
Re: The right way to use config files
Fabien fabien.mauss...@gmail.com writes: So I had the idea to define a super-object which parses the config file and input data and is given as a single parameter to the processing functions, and the functions take the information they need from it. That's not a bad idea, you could do that without embarrassment. A better technique, though, is to make use of modules as namespaces. Have one module of your application be responsible for the configuration of the application:: # app/config.py import configparser parser = configparser.ConfigParser() parser.read(app.conf) and import that module everywhere else that needs it:: # app/wibble.py from . import config def frobnicate(): do_something_with(config.foo) By using an imported module, the functions don't need to be parameterised by application-wide configuration; they can simply access the module from the global scope and thereby get access to that module's attributes. To get to the point: is it good practice to give all elements of a program access to the configfile and if yes, how is it done properly? There should be an encapsulation of the responsibility for parsing and organising the configuration options, and the rest of the application should access it only via that encapsulation. Putting that encapsuation in a module is an appropriately Pythonic technique. -- \ “Now Maggie, I’ll be watching you too, in case God is busy | `\ creating tornadoes or not existing.” —Homer, _The Simpsons_ | _o__) | Ben Finney -- https://mail.python.org/mailman/listinfo/python-list
Re: The right way to use config files
Hi Ben, On 09.08.2014 14:17, Ben Finney wrote: Have one module of your application be responsible for the configuration of the application:: # app/config.py import configparser parser = configparser.ConfigParser() parser.read(app.conf) Thanks for the suggestion. This way to do is new to me, and I didn't come to the idea myself. It seems like a good way to do this. But how to give an argument to this config namespace? i.e I want app.conf to be given as argument. Currently my program starts like this: def main(): # See if the user gave a configfile if len(sys.argv) == 2: # file was given as argument cfg = str(sys.argv[1]) else: # default file taken in the resource directory cfg = os.path.abspath(os.path.join(os.path.dirname(__file__), os.pardir,'res','default.cfg')) obj = superobj(cfg) obj.preprocess() obj.process() obj.write() -- https://mail.python.org/mailman/listinfo/python-list
Re: Tkinter frame reset
2014-08-09 2:38 GMT+02:00 Nicholas Cannon nicholascann...@gmail.com: Ok so I am working on a little project and I cant seem to solve something with it. I have a label and then a clear button and I want all the numbers in the label to clear when I push the button. This button is on a separate frame to the buttons. I would like to clear the frame and then set all the widgits back to how they were one you first open the app(Label being blank). ... -- https://mail.python.org/mailman/listinfo/python-list Hi, I haven't been doing anything more complex for some time now with tkinter, but could you maybe just associate the appropriate variables, keep them in a list and change the values in a loop as appropriate - without recreating the gui? cf. the basic recipe: http://effbot.org/tkinterbook/label.htm v = StringVar() Label(master, textvariable=v).pack() v.set(New Text!) hth, vbr -- https://mail.python.org/mailman/listinfo/python-list
Re: how to get the ordinal number in list
In article 338e8fb0-c9ec-462a-b560-1c1ff77de...@googlegroups.com, Rustom Mody rustompm...@gmail.com wrote: [To the OP] Yeah I am in the minority at least out here in considering comprehensions simpler than loops. Take your pick When comprehensions first came out, I stubbornly refused to get my head around them. Now, I'm totally addicted. To the extent that I consider dict comprehensions to the THE killer feature of 2.7 :-) But, putting on my instructor's hat, I think it's important to answer questions at a level that can be understood by the student. Painting with a broad brush, there's three or four kinds of people asking questions on this list: 1) People who are totally new to programming, and are learning Python as their first language. These are the people who are still struggling to understand fundamental concepts. They haven't figured out yet that the first step to solving a problem is to decide what algorithms you're going to use, and only then can you start translating that into code. They need to be led in small steps towards basic knowledge. 2) People who are (at least somewhat) experienced programmers, and are learning Python as a second language. Their experiential background is limited to one way of doing things (i.e. the Java way, or the PHP way, or whatever language way they learned first). They mostly should be shown how translate the things they already know into familiar feeling constructs. You already know how to write a loop, this is how we do it in Python. You already know how build a data structure that maps keys to values, this is how we do it in Python. Only after they've become comfortable with that, should they start exploring the really cool features of Python. 3) People who already know many languages, and are learning Python as their n-th. These folks have seen multiple ways of doing things, and can understand concepts at a higher level. Oh, Python dicts are more like C++ STL maps than PHP arrays. Oh, variables have function scope and don't have to be explicitly declared. Oh, RAII is spelled with in this language. Oh, functions are first-class objects, but code blocks are not. 4) People who are already proficient Python programmers and are looking to explore deeper topics. I think suggesting comprehensions in an answer should be reserved for people at levels 3 and 4. Maybe level 2-1/2. Certainly not level 1. -- https://mail.python.org/mailman/listinfo/python-list
Re: The right way to use config files
On 2014-08-09 13:48, Fabien wrote: So I had the idea to define a super-object which parses the config file and input data and is given as a single parameter to the processing functions, and the functions take the information they need from it. This is tempting because there is no need for refactoring when I decide to change something in the config, but I am afraid that the program may become unmaintainable by someone else than myself. Another possibility would be at least to give all the functions access to the configfile. To get to the point: is it good practice to give all elements of a program access to the configfile and if yes, how is it done properly? Though I don't like how it looks/feels to pass around the config in just about any function-call that needs it, I've found that doing so allows me to test more readily. The alternative (putting it in a global or some module) usually means that it's harder for me to test in isolation. -tkc -- https://mail.python.org/mailman/listinfo/python-list
Re: The right way to use config files
Hi, On 09.08.2014 18:16, Dennis Lee Bieber wrote: Better, in my view, is to have the import module set up default values for everything, AND have a function at the bottom of the form def initialize(fid=None): if fid: # parse file fid replacing the module level items # this may require making a them all globals since # assignments inside this function would be locals And then your main program import myconfig ... myconfig.initialize(sys.argv[1]) Yes ok I think got it. Thanks! I like the idea and will implement it, this will avoid the useless superobject and allow to have to configfile available to anyone. Fabien -- https://mail.python.org/mailman/listinfo/python-list
Re: The right way to use config files
On 8/9/2014 7:48 AM, Fabien wrote: BUT, my problem is that several options really are universal options to the program, such as the output directory for example. This information (where to write their results) is given to most of the functions as parameter. If possible, functions should *return* their results, or yield their results in chunks (as generators). Let the driver function decide where to put results. Aside from separating concerns, this makes testing much easier. -- Terry Jan Reedy -- https://mail.python.org/mailman/listinfo/python-list
Re: attendance system in pybluez
On 8/9/2014 12:26 PM, Dennis Lee Bieber wrote: On Sat, 09 Aug 2014 14:01:53 -0700, luofeiyu elearn2...@gmail.com declaimed the following: I want to write a program to help my teacher to take attendence. There are 300 students in a big room,everyone has android phone. I have matched them with my pc in win7 . when all of them seated on the classroom, As soon as I learned someone was using bluetooth presence to determine I was in such a class -- I'd turn the bluetooth feature off! And if attendance was part of your grade? Actually, I agree with you and Steven that the premise that all have an android phone, with battery charge, turned on, with bluetooth enabled, is a bit dubious. At the Univesity of Delaware, students buy a 'clicker', about $20, with an ID (I presume) and a few buttons for answering pop quizzes. I can only guess that they use bluetooth, but with extremely limited function and probably no writable memory, power draw is minimal and hijacking not an issue. -- Terry Jan Reedy -- https://mail.python.org/mailman/listinfo/python-list
Python Brasil [10] - Call for papers
Hi all, You have until tomorrow to submit your talk to Python Brasil [10]. http://2014.pythonbrasil.org.br/dashboard/proposals/ The conference will be amazing! See why: Our Keynotes - http://2014.pythonbrasil.org.br/speakers/ Our Venue - http://2014.pythonbrasil.org.br/news/the-conference-venue/ And on November 9th were going to have some activities (TBA) like scuba diving, standup paddle https://www.google.com.br/search?q=standup+paddlesafe=offes_sm=93source=lnmstbm=ischsa=Xei=qC7mU-PGKKq-sQTC3oKgDQved=0CAgQ_AUoAQbiw=1325bih=659 and others! Thanks and see you in Porto de Galinhas! Renato Oliveira @_renatooliveira http://twitter.com/_renatooliveira Labcodes - www.labcodes.com.br -- https://mail.python.org/mailman/listinfo/python-list
Re: The right way to use config files
On 09.08.2014 19:29, Terry Reedy wrote: If possible, functions should *return* their results, or yield their results in chunks (as generators). Let the driver function decide where to put results. Aside from separating concerns, this makes testing much easier. I see. But then this is also true for parameters, right? And yet we return to my original question ;-) Let's say my configfile looks like this: - ### app/config.cfg # General params output_dir = '..' input_file = '..' # Func 1 params [func1] enable = True threshold = 0.1 maxite = 1 - And I have a myconfig module which looks like: - ### app/myconfig.py import ConfigObj parser = obj() # parser will be instanciated by initialize def initialize(cfgfile=None): global parser parser = ConfigObj(cfgfile, file_error=True) - My main program could look like this: - ### app/mainprogram_1.py import myconfig def func1(): # the params are in the cfg threshold = myconfig.parser['func1'].as_float('threshold') maxite = myconfig.parser['func1'].as_long('maxite') # dummy operations score = 100. ite = 1 while (score threshold) and (ite maxite): score /= 10 ite += 1 # dummy return return score def main(): myconfig.initialize(sys.argv[1]) if myconfig.parser['func1'].as_bool('enable'): results = func1() if __name__ == '__main__': main() - Or like this: - ### app/mainprogram_2.py import myconfig def func1(threshold=None, maxite=None): # dummy operations score = 100. ite = 1 while (score threshold) and (ite maxite): score /= 10 ite += 1 # dummy return return score def main(): myconfig.initialize(sys.argv[1]) if myconfig.parser['func1'].as_bool('enable'): # the params are in the cfg threshold = myconfig.parser['func1'].as_float('threshold') maxite = myconfig.parser['func1'].as_long('maxite') results = func1(threshold=threshold, maxite=maxite) if __name__ == '__main__': main() - In this case, program2 is easier to test/understand, but if the parameters become numerous it could be a pain... As always, I guess I'l have to decide on a case by case basis what is best. -- https://mail.python.org/mailman/listinfo/python-list
Re: attendance system in pybluez
On Sun, Aug 10, 2014 at 3:43 AM, Terry Reedy tjre...@udel.edu wrote: And if attendance was part of your grade? Then it'd be easy enough to prove that you were actually there, and therefore that the find a Bluetooth device method is flawed. ChrisA -- https://mail.python.org/mailman/listinfo/python-list
Re: how to write file into my android phone?
Chris “Kwpolska” Warrick kwpol...@gmail.com Wrote in message: On Sat, Aug 9, 2014 at 7:56 PM, luofeiyu elearn2...@gmail.com wrote: When i input usb line with my android phone into the pc , there are two disks j: and k: (type :removable disk) displayed in win7. i can get my android phone bluetooth mac address . import bluetooth nearby_devices = bluetooth.discover_devices(lookup_names = True) for addr, phoneName in nearby_devices: print(addr) it is 6C:8B:2F:CE:5B:59 Now how can i write a file into the disk j: of my android phone(bluetooth mac is 6C:8B:2F:CE:5B:59 )? -- https://mail.python.org/mailman/listinfo/python-list You mixed up two very different interfaces. Bluetooth and USB are completely separate. If you want to write a file to the USB drive, you can just open a file, using the regular open() function (specify a path somewhere benath J:\): 1) it's not necessarily j: And not necessarily a single drive. 2) the phone isn't necessarily visible on a pc as a drive at all. For example the Samsung gs4. -- DaveA -- https://mail.python.org/mailman/listinfo/python-list
Re: The right way to use config files
On 8/9/2014 2:14 PM, Fabien wrote: On 09.08.2014 19:29, Terry Reedy wrote: If possible, functions should *return* their results, or yield their results in chunks (as generators). Let the driver function decide where to put results. Aside from separating concerns, this makes testing much easier. I see. But then this is also true for parameters, right? And yet we return to my original question ;-) Let's say my configfile looks like this: - ### app/config.cfg # General params output_dir = '..' input_file = '..' # Func 1 params [func1] enable = True threshold = 0.1 maxite = 1 - And I have a myconfig module which looks like: - ### app/myconfig.py import ConfigObj parser = obj() # parser will be instanciated by initialize Try parser = object() to actually run, but the line is not needed. Instead put parser: instantiated by initialize in the docstring. def initialize(cfgfile=None): global parser parser = ConfigObj(cfgfile, file_error=True) - My main program could look like this: - ### app/mainprogram_1.py import myconfig def func1(): # the params are in the cfg threshold = myconfig.parser['func1'].as_float('threshold') maxite = myconfig.parser['func1'].as_long('maxite') # dummy operations score = 100. ite = 1 while (score threshold) and (ite maxite): score /= 10 ite += 1 # dummy return return score def main(): myconfig.initialize(sys.argv[1]) if myconfig.parser['func1'].as_bool('enable'): results = func1() if __name__ == '__main__': main() - The advantage of TDD is that it forces one to make code testable as you do. Old code may not be designed to be so easily testable, as I have learned trying to add tests to idlelib. For the above, I would consider def func1_algo(threshhold, maxite): # possible separte file score = 100. ite = 1 while (score threshold) and (ite maxite): score /= 10 ite += 1 return score def func1(): # interface wrapper threshold = myconfig.parser['func1'].as_float('threshold') maxite = myconfig.parser['func1'].as_long('maxite') return func1_algo(threshhold, maxite) This is a slight bit of extra work, but now you can separately test (and modify) the algorithm and the interfacing. Testing the algorithm is easy, which encourages testing multiple i/o pairs. for in, out in iopairs: assert func1_algo(in) == out # or self.assertEqual, or ... (or close enough for float outputs) As for the interfacing: you can write and read multiple versions of config.cfg (relatively slow), use something like unittest.mock to mock the myconfig module, or write something fairly simple (py3 code). class Entry(dict): def as_bool(self, name): s = self[name] return True if s == 'True' else False if s == 'False' else None def as_int(self, name): return int(self[name]) as_long = as_int def as_float(self, name): return float(self[name]) class Config(object): def initialize(self, argv): pass myconfig = Config() # a module is like a singleton class myconfig.initialize('a') # test that does not raise # In use for testing, uncomment the following two lines # import mainprogram_1.py as mp1 # mp1.myconfig = myconfig f1_cfg = Entry({ 'enable': 'True', 'threshold': '0.1', 'maxite': '1', }) myconfig.parser = {'func1': f1_cfg} print(myconfig.parser['func1'].as_float('threshold') == 0.1) print(myconfig.parser['func1'].as_long('maxite') == 1) print(myconfig.parser['func1'].as_bool('enable') == True) f1_cfg['maxite'] = 5 print(myconfig.parser['func1'].as_int('maxite') == 5) # prints True 4 times Notice that you inject the mock myconfig into the tested module just one. After that, you can change anything within parser or replace parser with a new dict. Or like this: - ### app/mainprogram_2.py import myconfig def func1(threshold=None, maxite=None): These should not have defaults; avoid extra work! # dummy operations score = 100. ite = 1 while (score threshold) and (ite maxite): score /= 10 ite += 1 # dummy return return score def main(): myconfig.initialize(sys.argv[1]) if myconfig.parser['func1'].as_bool('enable'): # the params are in the cfg threshold = myconfig.parser['func1'].as_float('threshold') maxite = myconfig.parser['func1'].as_long('maxite') results = func1(threshold=threshold, maxite=maxite) if __name__ == '__main__': main() - In this case, program2 is easier to test/understand, but if the parameters become numerous it could be a pain... This is equivalent to what i wrote except for putting the wrapper inline in main(). Testing is the same for either. -- Terry Jan Reedy --
Re: how to get the ordinal number in list
Roy Smith wrote: But, putting on my instructor's hat, I think it's important to answer questions at a level that can be understood by the student. Painting with a broad brush, there's three or four kinds of people asking questions on this list: [...] I think suggesting comprehensions in an answer should be reserved for people at levels 3 and 4. Maybe level 2-1/2. Certainly not level 1. Yes, this! Strongly agreed. -- Steven -- https://mail.python.org/mailman/listinfo/python-list
Ground Up Python/Xpath lessons
I need a tutorial or lesson on Xpath syntax from the ground up. I am totally confused on how to assemble an Xpath. All the //a[wizardmojo]::stuffgoeshere is confusing as hell, and all the information I find, only tells you very basic examples, they don't really teach you assuming you know nothing. Thanks in advance, Mike -- https://mail.python.org/mailman/listinfo/python-list
Fwd: How to draw a map using python
To kind whom it may concern: I want to draw a map using python, not really a map with full information, just a get together of a series of small shapes to reflect land use. The data is like below 1 2 2 3 3 22 3 3 1 1 21 1 1 1 3 33 3 3 3 4 1 Each number represents one land use type. and their positions in the matrix are their coordinates. I used VBA to do that before, the whole map consists many small square shapes representing land use, but since the data was so large, it took a long time to generate the map, also delete the map. My question are : 1. I wonder in python, is there any more fast way to generate this kind of map, as a whole, not a series of shapes, i think that would be faster?? 2. I have tried using contourf, as below, but it says out of bounds for axis 1, but actually, I printed X,Y and cordi, they have the same shape, why still out of bounds? 1. y = np.arange(0, 4 , 1) x = np.arange(0, 6 , 1) X,Y = np.meshgrid(x,y) # cordi is the matrix containing all the data# pyplot is imported before plt.contourf(X,Y, Cordi[X,Y], 8, alpha=.75, cmap='jet') 3. Some kind person has suggested me to use imshow to plot. I checked the explanation of imshow, it deals more about images not plots, and it needs a 3D array to plot, in which for each pixel it needs 3 values to show the color. I also tried, not so acceptable. The interfaces of each color are so vague, and besides, when the data is large, it just failed to present. So, if I use imshow, could I have some way to avoid those two problems? Thank you very much for answering! -- https://mail.python.org/mailman/listinfo/python-list
how to get the subject of email?
I am in python3.4 typ, data = x.con.fetch(b'1', '(RFC822)') #get the first email text = data[0][1] message = email.message_from_string(text).get('subject') Traceback (most recent call last): File stdin, line 1, in module File D:\Python34\lib\email\__init__.py, line 40, in message_from_string return Parser(*args, **kws).parsestr(s) File D:\Python34\lib\email\parser.py, line 70, in parsestr return self.parse(StringIO(text), headersonly=headersonly) TypeError: initial_value must be str or None, not bytes message = email.message_from_string(str(text)).get('subject') message # nothing displayed -- https://mail.python.org/mailman/listinfo/python-list
Re: Ground Up Python/Xpath lessons
In c9c7ee19-9808-4087-bf2c-23b47ee2d...@googlegroups.com mikemixon...@gmail.com writes: I need a tutorial or lesson on Xpath syntax from the ground up. I am totally confused on how to assemble an Xpath. All the //a[wizardmojo]::stuffgoeshere is confusing as hell, and all the information I find, only tells you very basic examples, I'm confused -- don't you *want* very basic examples? they don't really teach you assuming you know nothing. Try http://www.w3schools.com/xpath/xpath_intro.asp -- John Gordon Imagine what it must be like for a real medical doctor to gor...@panix.comwatch 'House', or a real serial killer to watch 'Dexter'. -- https://mail.python.org/mailman/listinfo/python-list
Re: how to get the subject of email?
In mailman.12805.1407635303.18130.python-l...@python.org luofeiyu elearn2...@gmail.com writes: message = email.message_from_string(str(text)).get('subject') message # nothing displayed Try using email.message_from_bytes() instead. Also have a look at http://stackoverflow.com/questions/19508393/python-email-parsing-issue for a question very similar to yours. Perhaps something in the code will help. -- John Gordon Imagine what it must be like for a real medical doctor to gor...@panix.comwatch 'House', or a real serial killer to watch 'Dexter'. -- https://mail.python.org/mailman/listinfo/python-list
Re: Ground Up Python/Xpath lessons
On Saturday, August 9, 2014 8:27:15 PM UTC-5, mikemi...@gmail.com wrote: I need a tutorial or lesson on Xpath syntax from the ground up. I am totally confused on how to assemble an Xpath. All the //a[wizardmojo]::stuffgoeshere is confusing as hell, and all the information I find, only tells you very basic examples, they don't really teach you assuming you know nothing. Thanks in advance, Mike Yes, those examples are good, for about 5 minutes, but then how I do learn to do the more advanced stuff? Like find all the a tags and then extract the href out of each one? Or look in each tr and extract all the hrefs in td 1 when td 4 contains the text 5 star rating I haven't found anything that teaches you to string together complex xpaths, just simple ones like //form[1]/input -- https://mail.python.org/mailman/listinfo/python-list
Re: Ground Up Python/Xpath lessons
mikemixon...@gmail.com writes: I need a tutorial or lesson on Xpath syntax from the ground up. I am totally confused on how to assemble an Xpath. All the //a[wizardmojo]::stuffgoeshere is confusing as hell XPath is a public standard. You can find its specification at http://www.w3.org/TR/xpath/;. In my view, it is very well written; you find there all relevant details. Of course, it is not a tutorial: the information is very concise and assumes, that the reader copes well with abstract descriptions. -- https://mail.python.org/mailman/listinfo/python-list
Re: how to get the subject of email?
message = email.message_from_bytes(text) I get it , print(message['Subject']) #can get the subject But how can i get the body content of message? no , message['Body'] or message['Content'] On 8/9/2014 7:01 PM, John Gordon wrote: In mailman.12805.1407635303.18130.python-l...@python.org luofeiyu elearn2...@gmail.com writes: message = email.message_from_string(str(text)).get('subject') message # nothing displayed Try using email.message_from_bytes() instead. Also have a look at http://stackoverflow.com/questions/19508393/python-email-parsing-issue for a question very similar to yours. Perhaps something in the code will help. -- https://mail.python.org/mailman/listinfo/python-list
Re: how to get the subject of email?
think you ,i get it . message = email.message_from_bytes(text) print(message['Subject']) #can get the subject But how can i get the body content of message? message['Body'] or message['Content'] can get none. On 8/9/2014 7:01 PM, John Gordon wrote: In mailman.12805.1407635303.18130.python-l...@python.org luofeiyu elearn2...@gmail.com writes: message = email.message_from_string(str(text)).get('subject') message # nothing displayed Try using email.message_from_bytes() instead. Also have a look at http://stackoverflow.com/questions/19508393/python-email-parsing-issue for a question very similar to yours. Perhaps something in the code will help. -- https://mail.python.org/mailman/listinfo/python-list
[issue21777] Separate out documentation of binary sequence methods
Roundup Robot added the comment: New changeset e750d2b44c1d by Nick Coghlan in branch '3.4': Issue #21777: separate docs for binary sequence methods http://hg.python.org/cpython/rev/e750d2b44c1d New changeset e205bce4cc0a by Nick Coghlan in branch 'default': Merge #21777 from 3.4 http://hg.python.org/cpython/rev/e205bce4cc0a -- nosy: +python-dev ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue21777 ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue21777] Separate out documentation of binary sequence methods
Nick Coghlan added the comment: Merged after reviews from Zach Ezio. Zach, Ezio - if there are any other refactorings from the reviews that you'd like to pursue, consider pulling them out to separate issues so we don't forget about them. -- resolution: - fixed stage: commit review - resolved status: open - closed ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue21777 ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue22161] Remove unsupported code from ctypes
Roundup Robot added the comment: New changeset 034a5f15561d by Serhiy Storchaka in branch '3.4': Issue #22161: Conformed arguments type checks in ctype to actually supported http://hg.python.org/cpython/rev/034a5f15561d New changeset 06cf4044a11a by Serhiy Storchaka in branch 'default': Issue #22161: Conformed arguments type checks in ctype to actually supported http://hg.python.org/cpython/rev/06cf4044a11a -- nosy: +python-dev ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue22161 ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue22161] Remove unsupported code from ctypes
Changes by Serhiy Storchaka storch...@gmail.com: -- resolution: - fixed stage: patch review - resolved status: open - closed ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue22161 ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue10803] ctypes: better support of bytearray objects
Serhiy Storchaka added the comment: Existing inconsistency was fixed in issue22161. Patch updated, synchronized with tip. Added new tests. -- Added file: http://bugs.python.org/file36326/ctypes_bytearray_2.patch ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue10803 ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue22147] PosixPath() constructor should not accept strings with embedded NUL bytes
Vajrasky Kok added the comment: Here is the patch. -- keywords: +patch nosy: +vajrasky Added file: http://bugs.python.org/file36327/embedded_null_in_path.patch ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue22147 ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue21965] Add support for Memory BIO to _ssl
Geert Jansen added the comment: Thanks to Ben and Glyph for their feedback. The memory BIO should allow ProactorEventLoop to support SSL. I say should because I have not looked at it myself. However, my Gruvi project is proactor (libuv) based and I have a private branch where SSL support is working using a proactor API. I need a few more days to create an updated patch. This patch will include Antoine's suggestion of passing the SSLObject instance to the servername callback, and an update to the docs. -- ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue21965 ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue14105] Breakpoints in debug lost if line is inserted; IDLE
Saimadhav Heblikar added the comment: Not sure if this consequence of the commit is intended behavior, but still placing it here. In any file, set a breakpoint on any line. Pressing Enter key anywhere after the first character, will create a new breakpoint in the next line. These lines will also get saved to the .idlerc/breakpoints.lst file. This is mostly(99.9%) Tk behavior. -- nosy: +sahutd ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue14105 ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue21725] RFC 6531 (SMTPUTF8) support in smtpd
R. David Murray added the comment: I tweaked your additions. Instead of trying to strip out the 'b' to make things look pretty, I think it is better to print them and thus make it explicit when we are dealing with binary data and when we are dealing with strings. It also clues the user in to the fact that the escaping inside the string is that used for bytes display, as opposed to string display. I also expanded the tests to include headers so that the 'X-Peer' header addition would get tested. This reveals a bug; whether it is in the tests or the code I don't know: the value of self.peer in the process_ methods is 'peer', not the expected ('b', 0). If you can look in to this issue it would be great. That looks like the last issue that needs to be addressed before commit. (Oh, yeah, and there was a bug in the original process_message code...it was printing an extra blank line at the end of the message text if there was, as there should be, a newline at the end of the message...I fixed that by switching to splitlines instead of split.) -- Added file: http://bugs.python.org/file36328/issue21725v5.3.patch ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue21725 ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue21725] RFC 6531 (SMTPUTF8) support in smtpd
Milan Oberkirch added the comment: I think that the peer arg is supposed to be set to the address of the peer connecting to our server. The value 'peer' comes from test/mock_socket.py:105 and is the best answer we can get for mock_sock.getpeername() because there is no real client when directly writing into the socket. ('b', 0) would be the address of the remote server. -- ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue21725 ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue21591] exec(a, b, c) not the same as exec a in b, c in nested functions
Dirkjan Ochtman added the comment: I can take a look at the py failure next week. Keeping the run-time compatibility code seems sensible, but I'm not sure if it'd fix the py test? I don't think reverting the changes at this point is warranted. -- ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue21591 ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue14105] Breakpoints in debug lost if line is inserted; IDLE
Terry J. Reedy added the comment: On 8/9/2014 10:13 AM, Saimadhav Heblikar wrote: Saimadhav Heblikar added the comment: Not sure if this consequence of the commit is intended behavior, It is. In any file, set a breakpoint on any line. Pressing Enter key anywhere after the first character, will create a new breakpoint in the next line. Pressing any normal key within a tagged slice inserts the corresponding character within the slice. If the character happens to be \n, then the *one* slice encompasses one more line than it did before. A BREAK tag on line n encompasses one complete line, including terminal \n. In slice terms, n.0:(n+1).0. An xml version might look like the following. BREAKThis is something. This is something else /BREAK Insert \n after 'some' and we have BREAKThis is some thing. This is something else /BREAK The tag now encompasses two complete lines (including, importantly, two \ns). This is standard slice insertion behavior, which tk provides us. There is no new slice created. These lines will also get saved to the .idlerc/breakpoints.lst file. PyShellEditorWindow.store_file_breaks calls .update_breakpoints This sends text.tag_ranges(BREAK) to .ranges_to_linenumbers. This specifically accounts for possible insertions with this loop for each tag range. while lineno end: # lineno initially start line lines.append(lineno) lineno += 1 When I initially read the tag setting code, I wondered why include \n, why not the following? BREAKThis is something. This is something else/BREAK Possible insertion of \n is an answer. The comment block for store_file_breaks addresses some of these issues, and needs revision after the patch. I have been thinking that PyShellEditorWindow, later renamed EditorWindow*, should be BreakpointEditorWindow and moved to debugger.py.# * not to be confused with EditorWindow.EditorWindow, which should really be called BaseEditorWindow. # after applying either of your patches, at least locally. -- ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue14105 ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue22176] update internal libffi copy to 3.1, introducing AArch64 and POWER ELF ABIv2
New submission from Matthias Klose: tracking the import of libffi 3.1 -- components: ctypes messages: 225109 nosy: doko priority: normal severity: normal status: open title: update internal libffi copy to 3.1, introducing AArch64 and POWER ELF ABIv2 versions: Python 3.4, Python 3.5 ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue22176 ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue14105] Breakpoints in debug lost if line is inserted; IDLE
Terry J. Reedy added the comment: Forgot to mention: after inserting \n, the breakpoint tag can be cleared from either line independently. Tagging complete lines makes this easy. If a line is split into three and the middle line untagged, then the first and third are left separately tagged. -- ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue14105 ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue21725] RFC 6531 (SMTPUTF8) support in smtpd
R. David Murray added the comment: OK, it's a bug in mock_socket, then. getpeername should be returning a tuple (address, port). I went ahead and fixed it, and committed the patch. Thanks Milan! Sorry the reviews were so delayed. -- resolution: - fixed stage: patch review - resolved status: open - closed ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue21725 ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue22176] update internal libffi copy to 3.1, introducing AArch64 and POWER ELF ABIv2
Roundup Robot added the comment: New changeset f73c8cf6261f by doko in branch '3.4': - Issue #22176: Update the ctypes module's libffi to v3.1. This release http://hg.python.org/cpython/rev/f73c8cf6261f New changeset 0fef0afb9d19 by doko in branch 'default': - Issue #22176: Update the ctypes module's libffi to v3.1. This release http://hg.python.org/cpython/rev/0fef0afb9d19 -- nosy: +python-dev ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue22176 ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue22176] update internal libffi copy to 3.1, introducing AArch64 and POWER ELF ABIv2
Roundup Robot added the comment: New changeset 269ec4c568bd by doko in branch '3.4': - Issue #22176: Add src/x86/win32.S for x86 libffi builds. http://hg.python.org/cpython/rev/269ec4c568bd -- ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue22176 ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue22177] Incorrect version reported after downgrade
New submission from jp: After downgrading from version 2.7.8 to 2.7.5 on Win7 x86 32bit Python, the interpreter continues to report version 2.7.8. I have verified that the installation folder has the correct files belonging to 2.7.5 as evidenced by python.exe having a 2013 timestamp. Ran python -V at windows CMD and sys.version in interpreter, both report 2.7.8. -- messages: 225114 nosy: jpe5605 priority: normal severity: normal status: open title: Incorrect version reported after downgrade type: behavior versions: Python 2.7 ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue22177 ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue22176] update internal libffi copy to 3.1, introducing AArch64 and POWER ELF ABIv2
Roundup Robot added the comment: New changeset 4d3f960c26f5 by doko in branch '3.4': - Issue #22176: Fix build failure on ARM with -Werror=declaration-after-statement http://hg.python.org/cpython/rev/4d3f960c26f5 -- ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue22176 ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue22177] Incorrect version reported after downgrade
jp added the comment: Forget to mention this downgrade was installed over the existing python installation. -- ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue22177 ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue22177] Incorrect version reported after downgrade
Ezio Melotti added the comment: Have you checked if there are pyc files left around by the previous installation? Have you specified the full path to python.exe from cmd while running python -V? If you start the interpreter and print sys.version what do you get? Does anything change if you reload(sys)? -- nosy: +ezio.melotti ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue22177 ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue14944] Setup Usage documentation for pydoc, idle 2to3
Mark Lawrence added the comment: I'm assuming that this still applies to 3.4 and 2.7. -- nosy: +BreamoreBoy versions: +Python 3.5 -Python 3.3 ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue14944 ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue6858] This is a python file, apply syntax highlighting
Changes by Mark Lawrence breamore...@yahoo.co.uk: -- versions: +Python 2.7, Python 3.4, Python 3.5 -Python 3.2, Python 3.3 ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue6858 ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue22177] Incorrect version reported after downgrade
jp added the comment: Have you checked if there are pyc files left around by the previous installation? -- Yes, hundreds! After making a backup, i deleted all 900+ occurrences of *.pyc in c:\python27 and it still reports 2.7.8. Have you specified the full path to python.exe from cmd while running python -V?-- Yes, i've attached the console output If you start the interpreter and print sys.version what do you get? Does anything change if you reload(sys)? -- 2.7.8 again, no. -- Added file: http://bugs.python.org/file36329/console.txt ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue22177 ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue16893] Create IDLE help.txt from Doc/library/idle.rst
Changes by Mark Lawrence breamore...@yahoo.co.uk: -- versions: +Python 3.5 -Python 3.3 ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue16893 ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue21591] exec(a, b, c) not the same as exec a in b, c in nested functions
Nick Coghlan added the comment: Agreed reverting isn't necessary - main thing is to figure out what went wrong in the py test suite and come up with a new test case that covers it. The reason I suspect it's the missing runtime check that's causing the py problem is because (as far as I am aware), Jinja2 generates AST constructs directly and compiles those, and thus may be relying on the runtime check. It's just a theory, though. -- ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue21591 ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue21965] Add support for Memory BIO to _ssl
Changes by Glyph Lefkowitz gl...@twistedmatrix.com: -- nosy: -glyph ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue21965 ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue21591] exec(a, b, c) not the same as exec a in b, c in nested functions
Roundup Robot added the comment: New changeset 0e9b023078e6 by Benjamin Peterson in branch '2.7': restore runtime exec test (#21591) http://hg.python.org/cpython/rev/0e9b023078e6 -- ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue21591 ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue21121] -Werror=declaration-after-statement is added even for extension modules through setup.py
Roundup Robot added the comment: New changeset 2a3538f14948 by Benjamin Peterson in branch '3.4': add -Werror=declaration-after-statement only to stdlib extension modules (closes #21121) http://hg.python.org/cpython/rev/2a3538f14948 New changeset a5368cfbea0e by Benjamin Peterson in branch 'default': merge 3.4 (#21121) http://hg.python.org/cpython/rev/a5368cfbea0e -- nosy: +python-dev resolution: - fixed stage: commit review - resolved status: open - closed ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue21121 ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue22174] property doc fixes
Raymond Hettinger added the comment: Also, please don't add the extra whitespace to the docstring. It is intentionally compact because of the differing needs of various IDEs and help utlities. -- assignee: docs@python - rhettinger nosy: +rhettinger ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue22174 ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue22174] property doc fixes
diana added the comment: This whitespace? Or did you mean something else? class C: def __init__(self): self._x = None def getx(self): return self._x def setx(self, value): self._x = value def delx(self): del self._x x = property(getx, setx, delx, I'm the 'x' property.) versus: class C: def __init__(self): self._x = None def getx(self): return self._x def setx(self, value): self._x = value def delx(self): del self._x x = property(getx, setx, delx, I'm the 'x' property.) I added it to be consistent with the rest of the code snippets in the property docs. For example: class C: def __init__(self): self._x = None @property def x(self): I'm the 'x' property. return self._x @x.setter def x(self, value): self._x = value @x.deleter def x(self): del self._x Of the three code snippets in the property docs, that first one is the only one that doesn't have whitespace between the methods. That first code snippet also has inconsistent whitespace within itself (__init__ vs the rest of methods). Anyhoo, that was my reasoning, but that's largely beside the point. I will happily drop it and leave it as-is. What really prompted me to submit a patch was this paragraph: If given, doc will be the docstring of the property attribute. Otherwise, the property will copy fget‘s docstring (if it exists). This makes it possible to create read-only properties easily using property() as a decorator: I now understand the original intent, but I don't think it's clear as-is. I also find it a bit odd that 'fget', 'fset', 'fdel' are all defined in the first sentence of the docs, but 'doc' isn't. It then launches into an example that uses 'doc' (still as of yet undefined), before defining 'doc' later on in the read-only properties part. I'll think on it a bit some more -- feel free to close this in the mean time. It's been this way for a better part of a decade, so perhaps it's just me ;) Cheers, --diana -- ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue22174 ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com