Skip to main content
Search type Search syntax
Tags [tag]
Exact "words here"
Author user:1234
user:me (yours)
Score score:3 (3+)
score:0 (none)
Answers answers:3 (3+)
answers:0 (none)
isaccepted:yes
hasaccepted:no
inquestion:1234
Views views:250
Code code:"if (foo != bar)"
Sections title:apples
body:"apples oranges"
URL url:"*.example.com"
Saves in:saves
Status closed:yes
duplicate:no
migrated:no
wiki:no
Types is:question
is:answer
Exclude -[tag]
-apples
For more details on advanced search visit our help page
Results tagged with
Search options answers only not deleted user 24208

JSON (JavaScript Object Notation) aka the Fat Free Alternative to XML is a lightweight data exchange format inspired by JavaScript object literals. It is often used with JavaScript, Ajax, and RESTful web services but is completely language independent.

10 votes

Current ISS latitude / longitude position

The code is clean and understandable. There are only minor improvements that we can apply. use more descriptive variable names: latitude_direction and longitude_direction instead of lat_dir and lon_ …
alecxe's user avatar
  • 17.3k
7 votes
Accepted

Insert data to PostgreSQL

In this case, you should be able to pass your data list of dictionaries directly to executemany() specifying dictionary-based query placeholders: import psycopg2 from psycopg2.extras import Json def … insert_into_table(data): # preparing geometry json data for insertion for item in data: item['geom'] = Json(item['geometry']) with psycopg2.connect(database='testdb', user='postgres …
alecxe's user avatar
  • 17.3k
2 votes

Validating a CSV list of contacts and convert it to JSON

I think most of us eventually encounter a CSV to JSON converter problem in our careers. …
alecxe's user avatar
  • 17.3k
4 votes
Accepted

Track changes inside a directory

You've done a great job documenting your code. Here are a few code style and code organization things I would work on: read arguments either inside the main_loop() function, or inside the if __name …
alecxe's user avatar
  • 17.3k
2 votes
Accepted

Serializing output of a match result web scraper

library" functions - beware of God objects (it's not really an issue now, just something that may happen if the class is gonna grow this way) if performance matters, look into using faster third-party JSON
alecxe's user avatar
  • 17.3k
2 votes
Accepted

Small module for getting JSON to work with in Python

self.session = requests.Session() self.profile_url = "https://api.chess.com/pub/player/{username}".format(username=self.username) try: if self.session.get(self.profile_url).json … raise ValueError("User '{username}' not found.".format(username=self.username)) except KeyError: pass def get_monthly_archives(self, year, month): """Returns a JSON
alecxe's user avatar
  • 17.3k
5 votes

Optimise many namedtuple assignment statements

What if, instead of multiple variables, you would define a list of names, which you then use to create a dictionary of names to Unit instances which are initialized using dictionary unpacking: names …
alecxe's user avatar
  • 17.3k
3 votes
Accepted

Small DSL: Converting JSON to MSSQL query

Something along these lines (please test thoroughly): def process(data, parameters={}): """ :param data: JSON Object (dict). :param parameters: dict. …
alecxe's user avatar
  • 17.3k
4 votes
Accepted

pyvdp - Python library for Visa Developer Program

The code overall looks clean, there will always be debates on writing classes or not (both approaches have great reasoning behind them, of course): Stop Writing Classes (PyCon 2012) Start Writing M …
alecxe's user avatar
  • 17.3k
3 votes
Accepted

Currency Converter in Python 3

Code Style Improvements "Flat is better than nested". You can make an early exit in case of invalid input: import sys try: amount = float(input("Enter amount: ")) except ValueError: print( …
alecxe's user avatar
  • 17.3k
2 votes
Accepted

Scraper for parsing email-ID using email sending button

Here are the few improvements I would apply: match the "Email" links directly via //div[@class='businessCapsule--callToAction']//a[. = 'Email']/@href XPath expression - note how I'm matching the lin …
alecxe's user avatar
  • 17.3k
11 votes
Accepted

A minimal CLI password storage and retrieval manager

I would pinpoint the major problems in the code which I would address first: do not manually handle provided command-line arguments - there is a great built-in module for it - argparse. It would ser …
alecxe's user avatar
  • 17.3k