Search Results

Search found 55 results on 3 pages for 'pep'.

Page 1/3 | 1 2 3  | Next Page >

  • Experience of Python's “PEP-302 New Import Hooks”

    - by Koichi Sasada
    I'm one of the developers of Ruby (CRuby). We are working on Ruby 2.0 release (planned to release 2012/Feb). Python has "PEP302: New Import Hooks" (2003): This PEP proposes to add a new set of import hooks that offer better customization of the Python import mechanism. Contrary to the current import hook, a new-style hook can be injected into the existing scheme, allowing for a finer grained control of how modules are found and how they are loaded. We are considering introducing a feature similar to PEP302 into Ruby 2.0 (CRuby 2.0). I want to make a proposal which can persuade Matz. Currently, CRuby can load scripts from only file systems in a standard way. If you have any experience or consideration about PEP 302, please share. Example: It's a great spec. No need to change it. It is almost good, but it has this problem... If I could go back to 2003, then I would change the spec to... I'm sorry if such a question is not suitable for here. I posted here because I'm not sure that I can ask this question at python-dev (of course, the list is not for cruby development). This post is moved from http://stackoverflow.com/questions/11188229/experience-of-pythons-pep-302-new-import-hooks.

    Read the article

  • XEP-0080 User Location in Smack Library.

    - by Kristof
    Hi, I would like to create a simple XMPP client in java that shares his location (XEP-0080) with other clients. I already know I can use the smack library for XMPP and that it supports PEP, which is needed for XEP-0080. Does anyone have an example how to implement this or any pointers, i don't find anything using google. thanks in advance.

    Read the article

  • Which implementation of OrderedDict should be used in python2.6?

    - by Jorge Vargas
    As some of you may know in python2.7/3.2 we'll get OrderedDict with PEP372 however one of the reason the PEP existed was because everyone did their own implementation and they were all sightly incompatible. So which one of the 8 current implementations link text is backwards compatible with the 2.7 odict from python 2.7 in a way we can start using that now and depend on 2.7 in a couple of months?

    Read the article

  • How do you PEP 8-name a class whose name is an acronym?

    - by Arrieta
    I try to adhere to the style guide for Python code (also known as PEP 8). Accordingly, the preferred way to name a class is using CamelCase: Almost without exception, class names use the CapWords convention. Classes for internal use have a leading underscore in addition. How can I be consistent with PEP 8 if my class name is formed by two acronyms (which in proper English should be capitalized). For instance, if my class name was 'NASA JPL', what would you name it?: class NASAJPL(): # 1 class NASA_JPL(): # 2 class NasaJpl(): # 3 I am using #1, but it looks weird; #3 looks weird too, and #2 seems to violate PEP 8. Thoughts?

    Read the article

  • nightmare with relative imports, how does pep 366 work?

    - by pygabriel
    I have a "canonical file structure" like that (I'm giving sensible names to ease the reading): mainpack/ __main__.py __init__.py - helpers/ __init__.py path.py - network/ __init__.py clientlib.py server.py - gui/ __init__.py mainwindow.py controllers.py In this structure, for example modules contained in each package may want to access the helpers utilities through relative imports in something like: # network/clientlib.py from ..helpers.path import create_dir The program is runned "as a script" using the __main__.py file in this way: python mainpack/ Trying to follow the PEP 366 I've put in __main__.py these lines: ___package___ = "mainpack" from .network.clientlib import helloclient But when running: $ python mainpack Traceback (most recent call last): File "/usr/lib/python2.6/runpy.py", line 122, in _run_module_as_main "__main__", fname, loader, pkg_name) File "/usr/lib/python2.6/runpy.py", line 34, in _run_code exec code in run_globals File "path/mainpack/__main__.py", line 2, in <module> from .network.clientlib import helloclient SystemError: Parent module 'mainpack' not loaded, cannot perform relative import What's wrong? What is the correct way to handle and effectively use relative imports? I've tried also to add the current directory to the PYTHONPATH, nothing changes.

    Read the article

  • Python Core Library and PEP8

    - by Szymon Guz
    I was trying to understand why Python is said to be a beautiful language. I was directed to the beauty of PEP 8... and it was strange. In fact it says that you can use any convention you want, just be consistent... and suddenly I found some strange things in the core library: request() getresponse() set_debuglevel() endheaders() http://docs.python.org/py3k/library/http.client.html The below functions are new in the Python 3.1. What part of PEP 8 convention is used here? popitem() move_to_end() http://docs.python.org/py3k/library/collections.html So my question is: is PEP 8 used in the core library, or not? Why is it like that? Is there the same situation as in PHP where I cannot just remember the name of the function because there are possible all ways of writing the name? Why PEP 8 is not used in the core library even for the new functions?

    Read the article

  • Python alignment of assignments (style)

    - by ikaros45
    I really like following style standards, as those specified in PEP 8. I have a linter that checks it automatically, and definitely my code is much better because of that. There is just one point in PEP 8, the E251 & E221 don't feel very good. Coming from a JavaScript background, I used to align the variable assignments as following: var var1 = 1234; var2 = 54; longer_name = 'hi'; var lol = { 'that' : 65, 'those' : 87, 'other_thing' : true }; And in my humble opinion, this improves readability dramatically. Problem is, this is dis-recommended by PEP 8. With dictionaries, is not that bad because spaces are allowed after the colon: dictionary = { 'something': 98, 'some_other_thing': False } I can "live" with variable assignments without alignment, but what I don't like at all is not to be able to pass named arguments in a function call, like this: some_func(length= 40, weight= 900, lol= 'troll', useless_var= True, intelligence=None) So, what I end up doing is using a dictionary, as following: specs = { 'length': 40, 'weight': 900, 'lol': 'troll', 'useless_var': True, 'intelligence': None } some_func(**specs) or just simply some_func(**{'length': 40, 'weight': 900, 'lol': 'troll', 'useless_var': True, 'intelligence': None}) But I have the feeling this work around is just worse than ignoring the PEP 8 E251 / E221. What is the best practice?

    Read the article

  • Generic dataset handling library

    - by Pep.
    Hello, I want to build a generic Perl module for handling and analysing biomedical character separated datasets and which can, most certain, be used on any kind of datasets that contain a mixture of categorical (A,B,C,..) and continuous (1.2,3,881..) and identifier (XXX1,XXX2...). The plan is to have people initialize the module and then use some arguments to point to the data file(s), the place were the analysis reports should be placed and the structure of the data. By structure of data I mean which variable is in which place and its name/type. And this is where I need some enlightenment. I am baffled how to do this in a clean way. Obviously, having people create a simple schema file, be it XML or some other format would be the cleanest but maybe not all people enjoy doing something like this. The solutions I can think of are: Create a configuration file in XML or similar and with a prespecified format. Pass the information during initialization of the module. Use the first row of the data as headers and try to guess types (ouch) Surely there must be a "canonical" way of doing this that is also usable and efficient. Thanks p.

    Read the article

  • How can I build a generic dataset-handling Perl library?

    - by Pep.
    Hello, I want to build a generic Perl module for handling and analysing biomedical character separated datasets and which can, most certain, be used on any kind of datasets that contain a mixture of categorical (A,B,C,..) and continuous (1.2,3,881..) and identifier (XXX1,XXX2...). The plan is to have people initialize the module and then use some arguments to point to the data file(s), the place were the analysis reports should be placed and the structure of the data. By structure of data I mean which variable is in which place and its name/type. And this is where I need some enlightenment. I am baffled how to do this in a clean way. Obviously, having people create a simple schema file, be it XML or some other format would be the cleanest but maybe not all people enjoy doing something like this. The solutions I can think of are: Create a configuration file in XML or similar and with a prespecified format. Pass the information during initialization of the module. Use the first row of the data as headers and try to guess types (ouch) Surely there must be a "canonical" way of doing this that is also usable and efficient. Thanks p.

    Read the article

  • Working with sets of rows in (My)SQL and comparing values

    - by Pep.
    Hello, I am trying to figure out the SQL for doing some relatively simple operations on sets of records in a table but I am stuck. Consider a table with multiple rows per item, all identified by a common key. For example: serial model color XX1 A blue XX2 A blue XX3 A green XX5 B red XX6 B blue XX1 B blue What I would for example want to do is: Assuming that all model A rows must have the same color, find the rows which dont. (for example, XX3 is green). Assuming that a given serial number can only point to a single type of model, find out the rows which that does not occur (for example XX1 points both to A and B) These are all simple logically things to do. To abstract it, I want to know how to group things by using a single key (or combination of keys) and then compare the values of those records. Should I use a join on the same table? should i use some sort of array or similar? thanks for your help

    Read the article

  • What to put in a python module docstring?

    - by 007brendan
    Ok, so I've read both PEP 8 and PEP 257, and I've written lots of docstrings for functions and classes, but I'm a little unsure about what should go in a module docstring. I figured, at a minimum, it should document the functions and classes that the module exports, but I've also seen a few modules that list author names, copyright information, etc. Does anyone have an example of how a good python docstring should be structured?

    Read the article

  • How to integrate pep8.py in Eclipse?

    - by DZPM
    A little background: PEP 8 is the Style Guide for Python Code. It contains the conventions all python programmers should follow. pep8.py is a (very useful) script that checks the code formating of a given python script, according to PEP 8. Eclipse is a great IDE. With the Pydev extension, it that can be used to develop Python I run pep8.py manually when I'm scripting, but with bigger projects I prefer to use Eclipse. It would be really useful to integrate pep8.py in Eclipse/Pydev, so it can be run automatically in all the files in the project, and point to the lines containing the warnings. Maybe there is an obvious way to do it, but I haven't found it yet. Question is: How to integrate pep8.py in Eclipse?

    Read the article

  • Dealing with missing messages in JavaScript when using BOSH

    - by JamieD
    We recently went into private beta on our flagship product and had a small launch event. Unfortunately the venue had a terrible wireless connection and packets were being dropped left right and centre causing havoc with out system, basically it wasn't able to work at all! Luckily we were able to switch to a different network and rescue the demo. This highlighted something that I knew was already an issue but hadn't appreciated quite how much of an issue it could be. Our system relies heavily on BOSH and has a rather large JavaScript code base which now works rather well under good network conditions. However we need to make it work well under bad network conditions as well. Due to the way that XMPP works, a fire and forget system, it's not easy to tell if a message you sent, or were supposed to receive, was actually sent or received. For instance, we have an offer system, one user will send an offer to another over BOSH. When this message is received by the server a message is published to the offering users offers_sent PEP node and a similar message to the receiving users offers_received PEP node. While the sending user is able to tell if their offer was send (relatively) easily, if the notification to the receiving user is never received that user will never know it missed a message. A little about out JavaScript setup, it has 4 main layers: StropheJS An MVC framework for dealing with low level tasks and to build on top of An application layer which contains the app logic routes, controllers models etc. as well as a browser cache of the model data A UI layer that receives events and publishes events to and from the application layer One way to solve the missing messages issue would be to periodically check the PEP nodes for new data that the browser doesn't know about. If a new message was discovered the browsers cache would be invalidated and all new data would be requested from the server. I'm not sure this is the best way to go and it also doesn't cover all situations. We certainly don't want to get into the situation where we are sending messages to confirm the previous message was received at it's destination as this would double the network traffic. With the number of real time websites growing daily this is an issue that must have been encountered by other developers, it would be interesting to see how it's been solved by others. As far as I can see there are two situations in which messages go missing: On poor connections messages are not sent or received due to the packets being dropped Involving navigating between pages, a message is received by the browser but is not fully processed and stored in the local cache before the page is unloaded. Or a message is added to the send queue but never sent before the page is unloaded I suspect the hardest issue to solve will be number 2. Any thoughts on the subject would be much appreciated.

    Read the article

  • Python code formatting

    - by Curious2learn
    In response to another question of mine, someone suggested that I avoid long lines in the code and to use PEP-8 rules when writing Python code. One of the PEP-8 rules suggested avoiding lines which are longer than 80 characters. I changed a lot of my code to comply with this requirement without any problems. However, changing the following line in the manner shown below breaks the code. Any ideas why? Does it have to do with the fact that what follows return command has to be in a single line? The line longer that 80 characters: def __str__(self): return "Car Type \n"+"mpg: %.1f \n" % self.mpg + "hp: %.2f \n" %(self.hp) + "pc: %i \n" %self.pc + "unit cost: $%.2f \n" %(self.cost) + "price: $%.2f "%(self.price) The line changed by using Enter key and Spaces as necessary: def __str__(self): return "Car Type \n"+"mpg: %.1f \n" % self.mpg + "hp: %.2f \n" %(self.hp) + "pc: %i \n" %self.pc + "unit cost: $%.2f \n" %(self.cost) + "price: $%.2f "%(self.price)

    Read the article

  • Why connection in Python's DB-API does not have "begin" operation?

    - by newtover
    Working with cursors in mysql-python I used to call "BEGIN;", "COMMIT;", and "ROLLBACK;" explicitly as follows: try: cursor.execute("BEGIN;") # some statements cursor.execute("COMMIT;") except: cursor.execute("ROLLBACK;") then, I found out that the underlying connection object has the corresponding methods: try: cursor.connection.begin() # some statements cursor.connection.commit() except: cursor.connection.rollback() Inspecting the DB-API PEP I found out that it does not mention the begin() method for the connection object, even for the extensions. Mysql-python, by the way, throws the Deprecation Warning, when you use the method. sqlite3.connection, for example, does not have the methd at all. And the question is why there is no such method in the PEP? Is the statement somehow optional, is it enough to invoke commit() instead?

    Read the article

  • How important is it to use short names for Python packages and modules?

    - by Dan
    PEP 8 says that Python package and module names should be short, since some file systems will truncate long names. And I'm trying to follow Python conventions in a new project. But I really like long, descriptive names. So I'm wondering, how short do names need to be to comply with PEP 8. And does anyone really worry about this anymore? I'm tempted to ignore this recommendation, and use longer names, thinking this isn't all that relevant anymore. Does anyone think this recommendation is still worth following? If yes, why? And how short is short enough?

    Read the article

  • How can I keep current with Python coding style?

    - by vartec
    I've been using Python since version 2.2. I do pick up new language constructs like for example with statement or dictionary/set comprehensions. However, I've realized that even though I'm being consistent with PEP-8, for existing constructs I'm using old style, rather than new style (for example except Exception, e instead of except Exception as e). Is there a resource which would have either most current style guide, or even better a list of changes in Python's coding style?

    Read the article

  • Concrete examples of Python's "only one way to do it" maxim

    - by Charles Roper
    I am learning Python and am intrigued by the following point in PEP 20 The Zen of Python: There should be one-- and preferably only one --obvious way to do it. Although that way may not be obvious at first unless you're Dutch. Could anyone offer any concrete examples of this maxim? I am particularly interested in the contrast to other languages such as Ruby. Part of the Ruby design philosophy (originating with Perl, I think?) is that multiple ways of doing it is A Good Thing. Can anyone offer some examples showing the pros and cons of each approach. Note, I'm not after an answer to which is better (which is probably too subjective to ever be answered), but rather an unbiased comparison of the two styles.

    Read the article

  • 2010 SQLPeople Person of the Year

    - by andyleonard
    Introduction Back in 2010, I started recognizing the SQLPeople Person of the Year. It's been a tradition ever since. "But Andy, you're writing this in 2010." Yep. Good eye, Pep. The Award Goes To: Steve Jones ( Blog | @way0utwest ). I am not a DBA - I'm a database developer. I joke and say I look like the world's greatest DBA when there's no contention, the jobs are finishing successfully, queries return data quickly and accurately, and the backups succeed. But anyone looks like the world's greatest...(read more)

    Read the article

  • Naming conventions used for variables and functions in C

    - by Zel
    While coding a large project in C I came upon a problem. If I keep on writing more code then there will be a time when it will be difficult for me to organize the code. I mean that the naming for functions and variables for different parts of the program may seem to be mixed up. So I was thinking whether there are useful naming conventions that I can use for C variables and functions? Most languages suggest a naming convention. But for C the only thing I have read so far is the names should be descriptive for code readability. EDIT: Examples of some examples of suggested naming conventions: Python's PEP 8 Java Tutorial I read some more naming conventions for java somewhere but couldn't remember where.

    Read the article

  • Potential annoyances of tab delimited Python source?

    - by user86432
    I want to start a new project, and I want this to be my first Python project. I was looking through the style guide, http://www.python.org/dev/peps/pep-0008/, which "strongly recommends" using a 4-spaces indentation style for new projects. But I just hate this idea! In my opinion, tabs are better for this purpose. What annoyances could crop up one day if another developer wanted to work on my tab-delimited files?

    Read the article

  • Until when will Python 2.5 be supported?

    - by Emilien
    Apparently Python only supports 2 minor versions (like 2.X), so that would mean Python 2.5 would get phased out when Python 2.7 comes out (in June 2010?) Is this correct? PEP 356 -- Python 2.5 Release Schedule doesn't give much answers to this question.

    Read the article

1 2 3  | Next Page >