Re: any json data validation library recommendation? (Reposting on Python-Lists Prohitibited)
On Thursday, October 6, 2016 at 7:20:58 AM UTC+1, Lawrence D’Oliveiro wrote: > What action are users supposed to take on such errors, other than include > them in a bug report? By users I mean API users (developers). Most common action would be to add a missing field, correct typo or change value type. Failing validation is usually user error, and rarely leads to reporting a bug. -- https://mail.python.org/mailman/listinfo/python-list
any json data validation library recommendation?
Hi I'm writing json data validation tool in a language other than python, but knowing that there is plenty of good tools for it, I am looking for inspiration here. I am aware of json schema standard, but on its own its rather verbose and I'd rather have models defined in code (directly or via some DSL). Can anyone recommend library that provides good API for declaring data schemas, so I could see how it could be done? (Doing it is not a problem. Doing it in a way that's convenient for users, readable and generates good error messages is something I care about). Thanks -- Maciej Dziardziel fied...@gmail.com -- https://mail.python.org/mailman/listinfo/python-list
Python package index in elasticsearch
Hi Being frustrated with speed and inflexibility of pip search, I played with elasticsearch and set up my own index. Maybe someone will find it useful too. Site:http://pypisearch.linuxcoder.co.uk Code: https://github.com/Fiedzia/pypisearch Full lucene syntax is allowed. Note: indexing is in progress, but over 60% of pypi packages are there, it should get to 100% within max few hours. Having the basics working, I hope to polish it soon. Maciej Dziardziel fied...@gmail.com -- https://mail.python.org/mailman/listinfo/python-list
Re: PEP8 and 4 spaces
> Surely the issue of mixing tabs and spaces is much more important than > > working systems? :) Python 3 considers tabs as an error and refuses to work. -- https://mail.python.org/mailman/listinfo/python-list
Re: python 3.44 float addition bug?
On Saturday, June 21, 2014 1:57:19 AM UTC+1, FraserL wrote: > I'm not hugely accustomed to Python, but this seems crazy to me. Floating points values use finite amount of memory, and cannot accurately represent infinite amount of numbers, they are only approximations. This is limitation of float type and applies to any languages that uses types supported directly by cpu. To deal with it you can either use decimal.Decimal type that operates using decimal system and saves you from such surprises (but it will be much slower and incompatible with c code that doesn't handle decimals or converts them to floats) or use epsilon for every comparison and rounding/formatting with limited precision for displaying. Few more details are here: http://floating-point-gui.de/errors/comparison/ -- https://mail.python.org/mailman/listinfo/python-list
Re: pypi - package metdata
On Wednesday, June 18, 2014 9:12:46 PM UTC+1, Mark Lawrence wrote: > Why not use google and do a site specific search of pypi? I am looking for good use of elasticsearch I have there, rather then quick way of finding something once quickly. Neither pypi nor google provide faceting for example. I've found that (confusingly) json api for pypi doesn't do anything useful, but xmlrpc provides more options, and its good enough for me. -- https://mail.python.org/mailman/listinfo/python-list
pypi - package metdata
I wasn't quiet happy with the way search on pypi works, so I've got an idea of getting all package metadata from pypi and do search locally. The only problem is that I can't figure out where to get the data from. I tried to use bandersnatch to set up mirror, but all I've got was a mixture of egg, whl and exe files. Egg and whl are useful maybe, but I guess its not exactly what I want. Then I've found api: https://pypi.python.org/simple/ provides list of packages, and I can use json api to get metadata for each of them. -- https://mail.python.org/mailman/listinfo/python-list
Re: pypi - package metdata
On Wednesday, June 18, 2014 8:21:12 PM UTC+1, Maciej Dziardziel wrote: > I wasn't quiet happy with the way search on pypi works, > > so I've got an idea of getting all package metadata from pypi > > and do search locally. The only problem is that I can't figure out > > where to get the data from. I tried to use bandersnatch to > > set up mirror, but all I've got was a mixture of egg, whl and exe files. > > Egg and whl are useful maybe, but I guess its not exactly what I want. > > Then I've found api: > > https://pypi.python.org/simple/ provides list of packages, > > and I can use json api to get metadata for each of them. (Click post to fast, so I am continuing.) So its doable, but I am really hoping for a better way. I assume pypi would ban me quickly for making thousands of requests, and I'd love to be able to update index daily or weekly. Is there something I am missing? -- https://mail.python.org/mailman/listinfo/python-list
Re: Why this code works in python3, but not python 2:
On Thursday, July 4, 2013 5:05:23 AM UTC+1, alex23 wrote: > It was an explicit syntax change for Python3. You can read about the > reasoning behind it here: > > http://www.python.org/dev/peps/pep-3102/ Thanks, that was helpful. Maciej Dziardziel -- http://mail.python.org/mailman/listinfo/python-list
Why this code works in python3, but not python 2:
Out of curiosity: Does anyone know why the code below is valid in python3, but not python2: def foo(*args, bar=1, **kwargs): pass -- Maciej Dziardziel -- http://mail.python.org/mailman/listinfo/python-list
Re: Emphasizing a gtk.Label
ravenheart wrote: > I want to give some emphasis to a Label from gtk, without breaking gnome > theme (i.e. not changing colors, etc) > I think bolding it would be a good option (could be also underscoring > but don't like it at all). > What would be the best solution? How to do it? I have found how to > change colors and underscoring but nothing else. > Thanks. Just set text to " whatever". -- Maciej "Fiedzia" Dziardziel ([EMAIL PROTECTED]) Inside his head is a little dust particle with a sign that says 'Space for Rent' -Caitieboo -- http://mail.python.org/mailman/listinfo/python-list
Re: matplotlib
[EMAIL PROTECTED] wrote: > Can somebody give some quick pointers to start off with matplotlib. > > Thanks http://matplotlib.sourceforge.net/tutorial.html -- Maciej "Fiedzia" Dziardziel ([EMAIL PROTECTED]) If you can read this, you are in phaser range. -- http://mail.python.org/mailman/listinfo/python-list
Re: python for flash drives
Putty wrote: > Is there such a thing as a special version of python that I can run > more efficiently from a flash drive? google for movable python (or similar) -- Maciej "Fiedzia" Dziardziel ([EMAIL PROTECTED]) In the land of the blind, the one eyed man is king. -- http://mail.python.org/mailman/listinfo/python-list
Re: Using Which Version of Linux
blahman ([EMAIL PROTECTED]) wrote: > ok, i m going to use Linux for my Python Programs, mainly because i > need to see what will these fork() and exec() do. So, can anyone tell > me which flavour of linux i should use, some say that Debian is more > programmer friendly, or shold i use fedora, or Solaris. Because these > three are the only ones i know of that are popular and free. A standard answer is - use that one, which is known to your friends, so they can help you. Actually all Linux distros come with python and huge amount of additional modules, so choose any. Fedora, Mandrake, Suse and Ubuntu willi be easier for begginers, as they are targeted on inexperienced Linux users (what doesn't mean they cannot be used by experienced), Debian requires some knowledge (well, way more then other distros) but i like it for its clarity, wonderful package manager apt and control i have over it, it is also well documented and popular. I suggest first use Knoppix - Debian based distro, that boots from cd, doesn't require installation and contains tons of software, including python of course. Solaris is a different os, has nothing to do with Linux. -- Maciej "Fiedzia" Dziardziel (fiedzia (at) fiedzia (dot) prv (dot) pl) www.fiedzia.prv.pl It is my fondest hope that you are reading these while you should be working. Isn't that what the net's really about anyways? Sort of a place to go 'researching' while you should be getting stuff done! -- http://mail.python.org/mailman/listinfo/python-list
Re: Fork() and exec() dont work
blahman ([EMAIL PROTECTED]) wrote: > i m using Windows XP, and by tomorrow i will have have fedora core > installed too. the problem is, when i use these "fork() and exec()" my > windows doesnt do anything, python gives an error about the module, > the kind of error when u know u r wrong. > > is it because these commands work on linux? as documentation says: fork( ) Fork a child process. Return 0 in the child, the child's process id in the parent. Availability: Macintosh, Unix. > if so, is it better for me to stick with fedora for my python programs > or use windows? You can achive the same thing in windows by taking different approach, but i would say that Linux is way more programmer-friendly (especially Debian ;-) -- Maciej "Fiedzia" Dziardziel (fiedzia (at) fiedzia (dot) prv (dot) pl) www.fiedzia.prv.pl When tempted to fight fire with fire, remember that the Fire Department usually uses water. -- http://mail.python.org/mailman/listinfo/python-list
Re: Automatically creating a HOME environ variable on Windows?
Jorgen Grahn wrote: >> Best solution would be to have portable function that returns >> user home directory and knows about all platfom quirks. > > Why is that better than Python creating a HOME in os.environ, if it > doesn't > already exist? I can think of a few reasons it's better, and a few > reasons it's worse. First, it is possible that HOME viariable already exists and has different meaning, (if python is used as embedded scripting language it can be defined by application), Second, there is a group of path related functions in os.path (or ntpath), including expanduser, and its better to use function than relay on some interpreter behaviour that may be different on jython or ironpython. -- Maciej "Fiedzia" Dziardziel (fiedzia (at) fiedzia (dot) prv (dot) pl) www.fiedzia.prv.pl How come in Scooby Doo Fred and Daphne were always on the same team and Velma, Scooby and Shaggy were always on the same team? Doesn't seem quite right now that you think about it, does it? -- http://mail.python.org/mailman/listinfo/python-list
Re: Automatically creating a HOME environ variable on Windows?
[EMAIL PROTECTED] wrote: > Cool, even better. So what's best, having code to add HOME > (=USERPROFILE) to os.environ, or change the various places that HOME is > used to check for USERPROFILE? Best solution would be to have portable function that returns user home directory and knows about all platfom quirks. -- Maciej "Fiedzia" Dziardziel (fiedzia (at) fiedzia (dot) prv (dot) pl) www.fiedzia.prv.pl If you lost your left arm, your right arm would be left. -- http://mail.python.org/mailman/listinfo/python-list
Re: tool for syntax coloring in html
Xah Lee wrote: > in some online documentations, for examples: > > http://perldoc.perl.org/perlref.html > http://www.ccs.neu.edu/home/dorai/t-y-scheme/t-y-scheme-Z-H-17.html > http://www.haskell.org/hawiki/HaskellDemo > > the codes are syntax colored. > > Is there a tool that produce codes in html with syntax coloring? It is and its called highlight (available in most linux distributions) -- Maciej "Fiedzia" Dziardziel (fiedzia (at) fiedzia (dot) prv (dot) pl) www.fiedzia.prv.pl Gravity isn't MY fault--I voted for velcro! -- http://mail.python.org/mailman/listinfo/python-list
Re: subprocess exiting in an incomprehensible fashion
Will wrote: > After the first number is input, the subprocess is exiting after the > first communicate. I do not understand why. As help(calc.communicate) says: Read data from stdout and stderr, until end-of-file is reached. Wait for process to _terminate_. > Any help would be much appreciated. I have been hunting quite a bit for > he answer to no avail. Simplest solution: #!/usr/bin/python2.4 import subprocess calc = subprocess.Popen("dc", stdin=subprocess.PIPE, stdout=subprocess.PIPE, stderr=subprocess.STDOUT) max = 5 for value in range(1, max): calc.stdin.write("%d\n" % value) if value > 1: calc.stdin.write("*\n") calc.stdin.write("p\n") calc.stdin.write("q\n") calc.stdin.flush() status = calc.wait() print calc.stdout.read() -- Maciej "Fiedzia" Dziardziel (fiedzia (at) fiedzia (dot) prv (dot) pl) www.fiedzia.prv.pl -- http://mail.python.org/mailman/listinfo/python-list
Re: Help with language, dev tool selection
[EMAIL PROTECTED] wrote: > 1)What programming language to use This is trivial task, whatever language you choose, will do it. Python too, and its also simple and popular, so i can recommend it. > 2)What development tools to use You don't need nothing beyond python interpreter. > 3)Tips on how to code the solution Read the python tutorial (www.python.org) and thats probably all you need to know. > For each record I have to create an html file that will be named as the > name of the town (i.e. Sarajevo.html). The content of the file will be > rather simple; in the first row it will contain the header (i.e. > "This page displays longitude-latitude information") - The second > row will have the following word: "Grad" - and the third row will > contain the name of the city and the fourth row will have the > longitude-latitude info. Its maybe 10-20 lines of trivial code, so i suggest you to read python tutorial, unless its only do-it-once operation. Do you really need to create 30k files? this will take a lot of time (creating a file is time-consuming operation on creation, sending them to server too) and disk space greedy - even if file has 300 bytes, it may take 4kb or more on disk, depending on filesystem and its settings. Perhaps collecting names starting with the same letter in single file will be enough. -- Maciej "Fiedzia" Dziardziel (fiedzia (at) fiedzia (dot) prv (dot) pl) www.fiedzia.prv.pl Ankh if you love Isis. -- http://mail.python.org/mailman/listinfo/python-list
Re: Forcing a stack trace from the command line?
Willie Walker wrote: > Any advice would be greatly appreciated. Perhaps strace will tell you something. -- Maciej "Fiedzia" Dziardziel (fiedzia (at) fiedzia (dot) prv (dot) pl) www.fiedzia.prv.pl 'Not all who wander are lost.' - J.R.R. Tolkien, The Fellowship of the Ring -- http://mail.python.org/mailman/listinfo/python-list
Re: ezPyCrypto
[EMAIL PROTECTED] wrote: > Hi!! > > I finally decided to use ezPyCrypto for my project but I can't download > it from http://www.freenet.org.nz/ezPyCrypto/ ... Check this link now, it works for me. -- Maciej "Fiedzia" Dziardziel (fiedzia (at) fiedzia (dot) prv (dot) pl) www.fiedzia.prv.pl Confession is good for the soul only in the sense that a tweed coat is good for dandruff - it is a palliative rather than a remedy. - Peter DeVries -- http://mail.python.org/mailman/listinfo/python-list
Re: newbie question: convert a list to one string
[EMAIL PROTECTED] wrote: > H! > > I'm searching for the fastest way to convert a list to one big string. > > For example: > test = ['test','test2','test3'] '-'.join(test) -- Maciej "Fiedzia" Dziardziel (fiedzia (at) fiedzia (dot) prv (dot) pl) www.fiedzia.prv.pl Stewardesses is the longest word that is typed with only the left hand. -- http://mail.python.org/mailman/listinfo/python-list
Re: distributing scripts
Anand S Bisen wrote: > Hello, > > What is a good way to distributing python scripts as a package. Since > lately i am facing lots of issues with my python scripts not being able > to run properly due to either (old python 2.2 at the client machine) or > missing module. Is there a way by which i can solve these issues > revolving around my scripts ??? You can use cxFreeze (http://starship.python.net/crew/atuining/cx_Freeze/) to freeze python interpreter and all required modules. -- Maciej "Fiedzia" Dziardziel (fiedzia (at) fiedzia (dot) prv (dot) pl) www.fiedzia.prv.pl Patience comes to those who wait. -- http://mail.python.org/mailman/listinfo/python-list
Re: Read / Write image file
codecraig wrote: > I have a image file on my pc, say a .jpg. Basically I want to setup a > client/server socket, and I want the client to read in the jpg and send > it to the server, where the server can write that data into a new file > on the server. > > I tried just doing something like.. > > x = open("abc.jpg") > y = x.read() > tmp = open("newFile.jpg", "w") > tmp.write(y) > tmp.close() > x.close() > > ...but that doesn't give me a copy of abc.jpg > > any ideas? Thanks Give us more details. The code above works well for me. (python2.3). -- Maciej "Fiedzia" Dziardziel (fiedzia (at) fiedzia (dot) prv (dot) pl) www.fiedzia.prv.pl -- http://mail.python.org/mailman/listinfo/python-list
Re: delete will assure file is deleted?
[EMAIL PROTECTED] wrote: > Hello, > > If I use os.remove(fileName), does it always assure that the code will > move to the next code only if the fileName is deleted completely? Yes, it will be deleted, but not necessary completly. Deleting isn't equal to erasing file's content, so it might be possible to recover deleted file, plus on some systems deleted files are kept for those processes (and only for them), who are still using them, and disappear when everyone close them. -- Maciej "Fiedzia" Dziardziel (fiedzia (at) fiedzia (dot) prv (dot) pl) www.fiedzia.prv.pl Giraffiti: Concrete art spray-painted very, very high. -- http://mail.python.org/mailman/listinfo/python-list
Re: PyGTK vs. wxPython
dcrespo wrote: > Hi all... > > I think wxPython is much better than PyGTK. First of all, PyGTK needs > the GTK runtime installed, whereas wxPython is entirely Python's > modules, so It facilitates the apps' distribution. As already mentioned, it is not true. You will still need GTK (on Linux, not on Windows). > Also, PyGTK uses > specific controls or widgets of GTK, while wxPython uses native > controls of the platform where the app is running. Which has both pros and cons. wx unification isn't perfect (i had some problems with drawing that required some workarounds specific to a platform), it also doesn't allow you to really (or at least easy) use platform specific functionality (GTK app can be easily convert to GNOME app). > I'm learning both, but at a slow step, so I want to know all the > comments about this subject in this group. Go to www.pygtk.org, there are many tutorials, faq and other documentation and try it. > I heard about Glade to make the graphic layout of the app and then > export it as XML. Then, it connects to PyGTK. The problem I see is that > What if you want to refer to a state of a specific radiobutton of a > radobutton's group? It seems to be very troublesome. Do not listen, just test it. For me glade is the best way to define user interface. This is the way GUI should be created IMHO. You can access any widget just by calling its name - you will find details in any glade tutorial. > Please, post any comments about the pros and cons of each library, and > the proper way to construct the graphic layout (generating XML through > Glade, or by hand-code). Thanks. I don't have much experience with GTK on Windows, but i really like on Linux, way more then wx. It works great, is well documented (including python specific issues) and possible GNOME integration might be great help. -- Maciej "Fiedzia" Dziardziel (fiedzia (at) fiedzia (dot) prv (dot) pl) www.fiedzia.prv.pl Music is the art of thinking with sounds. -- http://mail.python.org/mailman/listinfo/python-list